From 6f5111ac2711a41e504fc395f8867e6d9ba21bfc Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 29 Apr 2013 11:26:36 -0700 Subject: [PATCH 001/796] Initial commit --- .gitignore | 6 ++++++ README.md | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..0f182a0349c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.class + +# Package Files # +*.jar +*.war +*.ear diff --git a/README.md b/README.md new file mode 100644 index 000000000000..82864cb1dc39 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +tutorials +========= + +Baeldung tutorials From 3ac30cd89f8165d9e991bf5fce2ebc2bb365b71b Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 29 Apr 2013 21:37:10 +0300 Subject: [PATCH 002/796] initial work on spring-mvc sample --- spring-mvc/.classpath | 37 ++++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 ++ spring-mvc/.gitignore | 13 +++ spring-mvc/.project | 60 ++++++++++ spring-mvc/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 +++++++++++++++ spring-mvc/.settings/org.eclipse.jdt.ui.prefs | 55 +++++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 31 ++++++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 +++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-mvc/.springBeans | 14 +++ spring-mvc/pom.xml | 105 ++++++++++++++++++ spring-mvc/src/main/resources/logback.xml | 60 ++++++++++ .../src/main/resources/webSecurityConfig.xml | 36 ++++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 ++ spring-mvc/src/main/webapp/WEB-INF/web.xml | 54 +++++++++ spring-mvc/src/test/resources/.gitignore | 13 +++ web/.springBeans | 13 +++ 24 files changed, 644 insertions(+) create mode 100644 spring-mvc/.classpath create mode 100644 spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-mvc/.gitignore create mode 100644 spring-mvc/.project create mode 100644 spring-mvc/.settings/.jsdtscope create mode 100644 spring-mvc/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-mvc/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-mvc/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-mvc/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-mvc/.settings/org.eclipse.wst.common.component create mode 100644 spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-mvc/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-mvc/.springBeans create mode 100644 spring-mvc/pom.xml create mode 100644 spring-mvc/src/main/resources/logback.xml create mode 100644 spring-mvc/src/main/resources/webSecurityConfig.xml create mode 100644 spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-mvc/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-mvc/src/test/resources/.gitignore create mode 100644 web/.springBeans diff --git a/spring-mvc/.classpath b/spring-mvc/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-mvc/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-mvc/.gitignore b/spring-mvc/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc/.project b/spring-mvc/.project new file mode 100644 index 000000000000..90b8ccd78f8f --- /dev/null +++ b/spring-mvc/.project @@ -0,0 +1,60 @@ + + + spring-mvc + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc/.settings/.jsdtscope b/spring-mvc/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-mvc/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-mvc/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc/.settings/org.eclipse.jdt.ui.prefs b/spring-mvc/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-mvc/.settings/org.eclipse.m2e.core.prefs b/spring-mvc/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs b/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..c28f646be673 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.common.component @@ -0,0 +1,31 @@ + + + + + + + + uses + + + uses + + + uses + + + uses + + + uses + + + uses + + + uses + + + + + diff --git a/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-mvc/.settings/org.eclipse.wst.validation.prefs b/spring-mvc/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-mvc/.springBeans b/spring-mvc/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-mvc/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml new file mode 100644 index 000000000000..d2007ffe976e --- /dev/null +++ b/spring-mvc/pom.xml @@ -0,0 +1,105 @@ + + 4.0.0 + org.baeldung + spring-mvc + spring-mvc + war + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/resources/logback.xml b/spring-mvc/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-mvc/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/resources/webSecurityConfig.xml b/spring-mvc/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-mvc/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..9d89410f99de --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,54 @@ + + + + spring-mvc + + + org.rest.common.log.LogContextInitializer + + + + + userDetailsFilter + com.launchpad.frontend.web.filter.UserDetailsFilter + + + userDetailsFilter + clientapp + + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.rest.common.spring com.launchpad.frontend.spring com.launchpad.cloud.s3.spring com.launchpad.sec.api.spring com.launchpad.provisioning.api.spring + + + spring.profiles.active + sec_client,client + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + + + mvc + *.html + + + + index.html + + + \ No newline at end of file diff --git a/spring-mvc/src/test/resources/.gitignore b/spring-mvc/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/web/.springBeans b/web/.springBeans new file mode 100644 index 000000000000..b854542b588b --- /dev/null +++ b/web/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + From 45c0260fc51bc1bb32d9bd96673785834f327bd1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 29 Apr 2013 21:43:51 +0300 Subject: [PATCH 003/796] mvc work --- .../org.eclipse.wst.common.component | 21 ---------- spring-mvc/pom.xml | 38 ++++++++++++++++++- .../spring/web/config/ClientWebConfig.java | 34 +++++++++++++++++ 3 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc/.settings/org.eclipse.wst.common.component index c28f646be673..dcefbbc2aca6 100644 --- a/spring-mvc/.settings/org.eclipse.wst.common.component +++ b/spring-mvc/.settings/org.eclipse.wst.common.component @@ -4,27 +4,6 @@ - - uses - - - uses - - - uses - - - uses - - - uses - - - uses - - - uses - diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index d2007ffe976e..aeb0e7f9fbd6 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.baeldung spring-mvc @@ -7,6 +8,19 @@ + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + @@ -102,4 +116,26 @@ + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + 0.1-SNAPSHOT \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2446e7b614cf --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,34 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +// @ComponentScan("org.package1.to.scan.web") +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file From 16e74dcca4856c27af3f6cd5ca3bb3d187f6bfd2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 29 Apr 2013 22:06:30 +0300 Subject: [PATCH 004/796] minor web.xml work --- spring-mvc/src/main/webapp/WEB-INF/web.xml | 32 +++++++--------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index 9d89410f99de..6ab6f3db011f 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -1,38 +1,25 @@ - spring-mvc - - - org.rest.common.log.LogContextInitializer - - - - - userDetailsFilter - com.launchpad.frontend.web.filter.UserDetailsFilter - - - userDetailsFilter - clientapp - + Spring MVC Application contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + contextConfigLocation - org.rest.common.spring com.launchpad.frontend.spring com.launchpad.cloud.s3.spring com.launchpad.sec.api.spring com.launchpad.provisioning.api.spring - - - spring.profiles.active - sec_client,client + org.package1.to.scan org.package2.to.scan + org.springframework.web.context.ContextLoaderListener @@ -41,6 +28,7 @@ mvc org.springframework.web.servlet.DispatcherServlet + 1 mvc From 35fbbd7822410d63ef12e8804ddedc9a2236363d Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 12:20:25 +0300 Subject: [PATCH 005/796] minor cleanup --- spring-mvc/.settings/org.eclipse.wst.common.component | 6 +++--- .../org/baeldung/spring/web/config/ClientWebConfig.java | 6 ++++++ spring-mvc/src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc/.settings/org.eclipse.wst.common.component index dcefbbc2aca6..9784ac36ee68 100644 --- a/spring-mvc/.settings/org.eclipse.wst.common.component +++ b/spring-mvc/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2446e7b614cf..93b0f9be79c2 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -14,6 +14,12 @@ // @ComponentScan("org.package1.to.scan.web") public class ClientWebConfig extends WebMvcConfigurerAdapter { + public ClientWebConfig() { + super(); + } + + // API + @Override public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index 6ab6f3db011f..a8e377b131b3 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -17,7 +17,7 @@ contextConfigLocation - org.package1.to.scan org.package2.to.scan + org.baeldung.spring.web.config From a568f9877f8947bdb35c62161a05b0860a1e53ea Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 13:04:07 +0300 Subject: [PATCH 006/796] doc work --- README.md | 7 +++++-- spring-mvc/README.md | 4 ++++ spring-mvc/pom.xml | 3 ++- .../org/baeldung/spring/web/config/ClientWebConfig.java | 1 - spring-mvc/src/main/webapp/WEB-INF/web.xml | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 spring-mvc/README.md diff --git a/README.md b/README.md index 82864cb1dc39..bae1a993f761 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -tutorials +Spring Tutorials ========= -Baeldung tutorials +Spring MVC +========= +[Spring MVC Example with Java based Configuration](http://www.baeldung.com/spring-mvc-java-configuration) + diff --git a/spring-mvc/README.md b/spring-mvc/README.md new file mode 100644 index 000000000000..82864cb1dc39 --- /dev/null +++ b/spring-mvc/README.md @@ -0,0 +1,4 @@ +tutorials +========= + +Baeldung tutorials diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index aeb0e7f9fbd6..3700a428ddb4 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -3,6 +3,8 @@ 4.0.0 org.baeldung spring-mvc + 0.1-SNAPSHOT + spring-mvc war @@ -137,5 +139,4 @@ - 0.1-SNAPSHOT \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 93b0f9be79c2..2758a707e6bc 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -11,7 +11,6 @@ @EnableWebMvc @Configuration -// @ComponentScan("org.package1.to.scan.web") public class ClientWebConfig extends WebMvcConfigurerAdapter { public ClientWebConfig() { diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index a8e377b131b3..ba2bb591ed01 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -32,7 +32,7 @@ mvc - *.html + / From 3ee550c7d31dacd0a866793f393f54eb476a4b51 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 13:04:57 +0300 Subject: [PATCH 007/796] doc work --- spring-mvc/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-mvc/README.md b/spring-mvc/README.md index 82864cb1dc39..afb2185d6002 100644 --- a/spring-mvc/README.md +++ b/spring-mvc/README.md @@ -1,4 +1,3 @@ -tutorials +Spring MVC with Java Configuration ========= -Baeldung tutorials From b72a865367fc6501c7562931acf3b6cc82dd4c50 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 18:04:57 +0300 Subject: [PATCH 008/796] spring mvc work --- {spring-mvc => spring-mvc-java}/.classpath | 0 ...e.wst.jsdt.core.javascriptValidator.launch | 0 .../resources => spring-mvc-java}/.gitignore | 0 spring-mvc-java/.project | 60 ++++++++ .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 0 ....eclipse.wst.common.project.facet.core.xml | 0 ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 spring-mvc-java/.springBeans | 14 ++ {spring-mvc => spring-mvc-java}/README.md | 0 {spring-mvc => spring-mvc-java}/pom.xml | 0 .../spring/web/config/ClientWebConfig.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 spring-mvc-java/src/test/resources/.gitignore | 13 ++ spring-mvc-xml/.classpath | 37 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-mvc-xml/.gitignore | 13 ++ spring-mvc-xml/.project | 60 ++++++++ spring-mvc-xml/.project~ | 60 ++++++++ spring-mvc-xml/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 +++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-mvc-xml/.springBeans | 14 ++ spring-mvc-xml/README.md | 3 + spring-mvc-xml/README.md~ | 4 + spring-mvc-xml/pom.xml | 142 ++++++++++++++++++ .../spring/web/config/ClientWebConfig.java | 39 +++++ spring-mvc-xml/src/main/resources/logback.xml | 60 ++++++++ .../src/main/resources/webSecurityConfig.xml | 36 +++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 42 ++++++ spring-mvc-xml/src/test/resources/.gitignore | 13 ++ spring-mvc/.gitignore | 14 +- spring-mvc/.project | 2 +- spring-mvc/.springBeans | 1 - 55 files changed, 830 insertions(+), 15 deletions(-) rename {spring-mvc => spring-mvc-java}/.classpath (100%) rename {spring-mvc => spring-mvc-java}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-mvc/src/test/resources => spring-mvc-java}/.gitignore (100%) create mode 100644 spring-mvc-java/.project rename {spring-mvc => spring-mvc-java}/.settings/.jsdtscope (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.common.component (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-mvc => spring-mvc-java}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) create mode 100644 spring-mvc-java/.springBeans rename {spring-mvc => spring-mvc-java}/README.md (100%) rename {spring-mvc => spring-mvc-java}/pom.xml (100%) rename {spring-mvc => spring-mvc-java}/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java (100%) rename {spring-mvc => spring-mvc-java}/src/main/resources/logback.xml (100%) rename {spring-mvc => spring-mvc-java}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-mvc => spring-mvc-java}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc => spring-mvc-java}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc => spring-mvc-java}/src/main/webapp/WEB-INF/web.xml (100%) create mode 100644 spring-mvc-java/src/test/resources/.gitignore create mode 100644 spring-mvc-xml/.classpath create mode 100644 spring-mvc-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-mvc-xml/.gitignore create mode 100644 spring-mvc-xml/.project create mode 100644 spring-mvc-xml/.project~ create mode 100644 spring-mvc-xml/.settings/.jsdtscope create mode 100644 spring-mvc-xml/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-mvc-xml/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-mvc-xml/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-mvc-xml/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.common.component create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-mvc-xml/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-mvc-xml/.springBeans create mode 100644 spring-mvc-xml/README.md create mode 100644 spring-mvc-xml/README.md~ create mode 100644 spring-mvc-xml/pom.xml create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-mvc-xml/src/main/resources/logback.xml create mode 100644 spring-mvc-xml/src/main/resources/webSecurityConfig.xml create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-mvc-xml/src/test/resources/.gitignore diff --git a/spring-mvc/.classpath b/spring-mvc-java/.classpath similarity index 100% rename from spring-mvc/.classpath rename to spring-mvc-java/.classpath diff --git a/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-mvc-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-mvc-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-mvc/src/test/resources/.gitignore b/spring-mvc-java/.gitignore similarity index 100% rename from spring-mvc/src/test/resources/.gitignore rename to spring-mvc-java/.gitignore diff --git a/spring-mvc-java/.project b/spring-mvc-java/.project new file mode 100644 index 000000000000..46209afeadc7 --- /dev/null +++ b/spring-mvc-java/.project @@ -0,0 +1,60 @@ + + + spring-mvc-java + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc/.settings/.jsdtscope b/spring-mvc-java/.settings/.jsdtscope similarity index 100% rename from spring-mvc/.settings/.jsdtscope rename to spring-mvc-java/.settings/.jsdtscope diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.jdt.core.prefs rename to spring-mvc-java/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-mvc/.settings/org.eclipse.jdt.ui.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.jdt.ui.prefs rename to spring-mvc-java/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-mvc/.settings/org.eclipse.m2e.core.prefs b/spring-mvc-java/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.m2e.core.prefs rename to spring-mvc-java/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs b/spring-mvc-java/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.m2e.wtp.prefs rename to spring-mvc-java/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc-java/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.common.component rename to spring-mvc-java/.settings/org.eclipse.wst.common.component diff --git a/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-mvc-java/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-mvc-java/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-mvc-java/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-mvc-java/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-mvc/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-java/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.validation.prefs rename to spring-mvc-java/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-mvc-java/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-mvc-java/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-mvc-java/.springBeans b/spring-mvc-java/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-mvc-java/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-mvc/README.md b/spring-mvc-java/README.md similarity index 100% rename from spring-mvc/README.md rename to spring-mvc-java/README.md diff --git a/spring-mvc/pom.xml b/spring-mvc-java/pom.xml similarity index 100% rename from spring-mvc/pom.xml rename to spring-mvc-java/pom.xml diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java similarity index 100% rename from spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java diff --git a/spring-mvc/src/main/resources/logback.xml b/spring-mvc-java/src/main/resources/logback.xml similarity index 100% rename from spring-mvc/src/main/resources/logback.xml rename to spring-mvc-java/src/main/resources/logback.xml diff --git a/spring-mvc/src/main/resources/webSecurityConfig.xml b/spring-mvc-java/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-mvc/src/main/resources/webSecurityConfig.xml rename to spring-mvc-java/src/main/resources/webSecurityConfig.xml diff --git a/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc-java/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-mvc/src/main/webapp/WEB-INF/web.xml rename to spring-mvc-java/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-java/src/test/resources/.gitignore b/spring-mvc-java/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc-java/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-xml/.classpath b/spring-mvc-xml/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-mvc-xml/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-mvc-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-mvc-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-mvc-xml/.gitignore b/spring-mvc-xml/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc-xml/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-xml/.project b/spring-mvc-xml/.project new file mode 100644 index 000000000000..6cdb4e0e5194 --- /dev/null +++ b/spring-mvc-xml/.project @@ -0,0 +1,60 @@ + + + spring-mvc-xml + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc-xml/.project~ b/spring-mvc-xml/.project~ new file mode 100644 index 000000000000..90b8ccd78f8f --- /dev/null +++ b/spring-mvc-xml/.project~ @@ -0,0 +1,60 @@ + + + spring-mvc + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc-xml/.settings/.jsdtscope b/spring-mvc-xml/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-mvc-xml/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-mvc-xml/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-xml/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc-xml/.settings/org.eclipse.jdt.ui.prefs b/spring-mvc-xml/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-mvc-xml/.settings/org.eclipse.m2e.core.prefs b/spring-mvc-xml/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-mvc-xml/.settings/org.eclipse.m2e.wtp.prefs b/spring-mvc-xml/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-xml/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9784ac36ee68 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc-xml/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-mvc-xml/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-mvc-xml/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-mvc-xml/.springBeans b/spring-mvc-xml/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-mvc-xml/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md new file mode 100644 index 000000000000..afb2185d6002 --- /dev/null +++ b/spring-mvc-xml/README.md @@ -0,0 +1,3 @@ +Spring MVC with Java Configuration +========= + diff --git a/spring-mvc-xml/README.md~ b/spring-mvc-xml/README.md~ new file mode 100644 index 000000000000..82864cb1dc39 --- /dev/null +++ b/spring-mvc-xml/README.md~ @@ -0,0 +1,4 @@ +tutorials +========= + +Baeldung tutorials diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml new file mode 100644 index 000000000000..3700a428ddb4 --- /dev/null +++ b/spring-mvc-xml/pom.xml @@ -0,0 +1,142 @@ + + 4.0.0 + org.baeldung + spring-mvc + 0.1-SNAPSHOT + + spring-mvc + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2758a707e6bc --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/logback.xml b/spring-mvc-xml/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-mvc-xml/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/test/resources/.gitignore b/spring-mvc-xml/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc-xml/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc/.gitignore b/spring-mvc/.gitignore index 83c05e60c802..5e56e040ec09 100644 --- a/spring-mvc/.gitignore +++ b/spring-mvc/.gitignore @@ -1,13 +1 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file +/bin diff --git a/spring-mvc/.project b/spring-mvc/.project index 90b8ccd78f8f..46209afeadc7 100644 --- a/spring-mvc/.project +++ b/spring-mvc/.project @@ -1,6 +1,6 @@ - spring-mvc + spring-mvc-java diff --git a/spring-mvc/.springBeans b/spring-mvc/.springBeans index 7623a7e88836..b854542b588b 100644 --- a/spring-mvc/.springBeans +++ b/spring-mvc/.springBeans @@ -7,7 +7,6 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml From 6e30401cba47bbcf326e8f27e32d65a4dd556503 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 18:05:56 +0300 Subject: [PATCH 009/796] minor cleanup --- spring-mvc-java/pom.xml | 4 ++-- spring-mvc-xml/README.md~ | 4 ---- spring-mvc-xml/pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 spring-mvc-xml/README.md~ diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 3700a428ddb4..bb983b43e6f0 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-mvc + spring-mvc-java 0.1-SNAPSHOT - spring-mvc + spring-mvc-java war diff --git a/spring-mvc-xml/README.md~ b/spring-mvc-xml/README.md~ deleted file mode 100644 index 82864cb1dc39..000000000000 --- a/spring-mvc-xml/README.md~ +++ /dev/null @@ -1,4 +0,0 @@ -tutorials -========= - -Baeldung tutorials diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 3700a428ddb4..ecde675bfcd4 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -2,10 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-mvc 0.1-SNAPSHOT - spring-mvc + spring-mvc-xml war @@ -139,4 +138,5 @@ + spring-mvc-xml \ No newline at end of file From 433bd4682d8b9b2208573aa677577e0df9d5a96a Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 30 Apr 2013 18:09:37 +0300 Subject: [PATCH 010/796] cleanup work --- spring-mvc-xml/src/main/webapp/WEB-INF/web.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index ba2bb591ed01..d1256535ab4a 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -9,15 +9,9 @@ Spring MVC Application - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - contextConfigLocation - org.baeldung.spring.web.config + /WEB-INF/mvc-servlet.xml From 2d258c1002d19e766ef70490169643c598fb58dd Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 15:05:25 +0300 Subject: [PATCH 011/796] removing unnecessary artifacts --- spring-mvc/.gitignore | 1 - spring-mvc/.project | 60 ----------------------------------------- spring-mvc/.springBeans | 13 --------- web/.springBeans | 13 --------- 4 files changed, 87 deletions(-) delete mode 100644 spring-mvc/.gitignore delete mode 100644 spring-mvc/.project delete mode 100644 spring-mvc/.springBeans delete mode 100644 web/.springBeans diff --git a/spring-mvc/.gitignore b/spring-mvc/.gitignore deleted file mode 100644 index 5e56e040ec09..000000000000 --- a/spring-mvc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin diff --git a/spring-mvc/.project b/spring-mvc/.project deleted file mode 100644 index 46209afeadc7..000000000000 --- a/spring-mvc/.project +++ /dev/null @@ -1,60 +0,0 @@ - - - spring-mvc-java - - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature - - diff --git a/spring-mvc/.springBeans b/spring-mvc/.springBeans deleted file mode 100644 index b854542b588b..000000000000 --- a/spring-mvc/.springBeans +++ /dev/null @@ -1,13 +0,0 @@ - - - 1 - - - - - - - - - - diff --git a/web/.springBeans b/web/.springBeans deleted file mode 100644 index b854542b588b..000000000000 --- a/web/.springBeans +++ /dev/null @@ -1,13 +0,0 @@ - - - 1 - - - - - - - - - - From 9d0902f273cd0fef2a02a73c702a8a58e798fdb2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 15:12:58 +0300 Subject: [PATCH 012/796] initial work on login tutorial --- spring-security-login/.classpath | 37 ++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-login/.gitignore | 13 ++ spring-security-login/.project | 60 ++++++ spring-security-login/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 +++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-login/.springBeans | 14 ++ spring-security-login/README.md | 3 + spring-security-login/pom.xml | 192 ++++++++++++++++++ .../spring/web/config/ClientWebConfig.java | 39 ++++ .../src/main/resources/logback.xml | 60 ++++++ .../src/main/resources/webSecurityConfig.xml | 36 ++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 42 ++++ .../src/test/resources/.gitignore | 13 ++ 25 files changed, 727 insertions(+) create mode 100644 spring-security-login/.classpath create mode 100644 spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-login/.gitignore create mode 100644 spring-security-login/.project create mode 100644 spring-security-login/.settings/.jsdtscope create mode 100644 spring-security-login/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-login/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-login/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-login/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-login/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-login/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-login/.springBeans create mode 100644 spring-security-login/README.md create mode 100644 spring-security-login/pom.xml create mode 100644 spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-security-login/src/main/resources/logback.xml create mode 100644 spring-security-login/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-security-login/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-login/src/test/resources/.gitignore diff --git a/spring-security-login/.classpath b/spring-security-login/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-security-login/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-login/.gitignore b/spring-security-login/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-login/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-login/.project b/spring-security-login/.project new file mode 100644 index 000000000000..1ba7568736b9 --- /dev/null +++ b/spring-security-login/.project @@ -0,0 +1,60 @@ + + + spring-security-login + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-security-login/.settings/.jsdtscope b/spring-security-login/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-security-login/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-security-login/.settings/org.eclipse.jdt.core.prefs b/spring-security-login/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-login/.settings/org.eclipse.jdt.ui.prefs b/spring-security-login/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-login/.settings/org.eclipse.m2e.core.prefs b/spring-security-login/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-login/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-login/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-login/.settings/org.eclipse.wst.common.component b/spring-security-login/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9784ac36ee68 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-login/.settings/org.eclipse.wst.validation.prefs b/spring-security-login/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-login/.springBeans b/spring-security-login/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-login/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-login/README.md b/spring-security-login/README.md new file mode 100644 index 000000000000..7cc97242ec04 --- /dev/null +++ b/spring-security-login/README.md @@ -0,0 +1,3 @@ +Spring Security Login +========= + diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml new file mode 100644 index 000000000000..ebc03d974f3f --- /dev/null +++ b/spring-security-login/pom.xml @@ -0,0 +1,192 @@ + + 4.0.0 + org.baeldung + spring-security-login + 0.1-SNAPSHOT + + spring-security-login + war + + + + + + + org.springframework.security + spring-security-core + ${org.springframework.security.version} + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + 3.1.4.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2758a707e6bc --- /dev/null +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-login/src/main/resources/logback.xml b/spring-security-login/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-security-login/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/web.xml b/spring-security-login/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-security-login/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-security-login/src/test/resources/.gitignore b/spring-security-login/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-login/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 1083636ca29e6734a69818841e59367a07e1e492 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 15:27:45 +0300 Subject: [PATCH 013/796] security work --- spring-security-login/pom.xml | 5 +++ .../spring/web/config/SecSecurityConfig.java | 14 ++++++++ .../src/main/resources/webSecurityConfig.xml | 35 +++++++------------ .../src/main/webapp/WEB-INF/web.xml | 10 ++++++ 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index ebc03d974f3f..76a023e4ca50 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -22,6 +22,11 @@ spring-security-web ${org.springframework.security.version} + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java new file mode 100644 index 000000000000..65a571c71589 --- /dev/null +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 5569cc69508a..2b38e4cf17e7 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -1,36 +1,27 @@ - - - - - - - - + - - - - - - + - + - + - - - - - + + + + + + \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/web.xml b/spring-security-login/src/main/webapp/WEB-INF/web.xml index ba2bb591ed01..23e0e8c1d7b0 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-login/src/main/webapp/WEB-INF/web.xml @@ -35,6 +35,16 @@ / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + index.html From 2dbcc247618a6fdf418b7f5357c524c5b465bed6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 15:39:36 +0300 Subject: [PATCH 014/796] initial login page --- spring-security-login/pom.xml | 5 ----- .../org/baeldung/spring/web/config/ClientWebConfig.java | 1 + .../src/main/webapp/WEB-INF/view/login.jsp | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 spring-security-login/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index 76a023e4ca50..c3ed1ebb2d77 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -12,11 +12,6 @@ - - org.springframework.security - spring-security-core - ${org.springframework.security.version} - org.springframework.security spring-security-web diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2758a707e6bc..b13c73dce375 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -23,6 +23,7 @@ public ClientWebConfig() { public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); + registry.addViewController("/login.html"); registry.addViewController("/sample.html"); } diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..b026d0df44b3 --- /dev/null +++ b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,7 @@ + + + + +

Login

+ + \ No newline at end of file From 2f9a99654ebb1827883639ee2dfb9dfb3ce1b8f3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 16:13:33 +0300 Subject: [PATCH 015/796] login worj --- .../org.eclipse.wst.common.component | 6 +++--- spring-security-login/pom.xml | 2 +- .../spring/web/config/ClientWebConfig.java | 2 +- .../src/main/resources/webSecurityConfig.xml | 4 +--- .../WEB-INF/view/{sample.jsp => homepage.jsp} | 0 .../src/main/webapp/WEB-INF/view/login.jsp | 19 +++++++++++++++++++ 6 files changed, 25 insertions(+), 8 deletions(-) rename spring-security-login/src/main/webapp/WEB-INF/view/{sample.jsp => homepage.jsp} (100%) diff --git a/spring-security-login/.settings/org.eclipse.wst.common.component b/spring-security-login/.settings/org.eclipse.wst.common.component index 9784ac36ee68..c42e29f80edc 100644 --- a/spring-security-login/.settings/org.eclipse.wst.common.component +++ b/spring-security-login/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index c3ed1ebb2d77..d8cecabcdb63 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -120,7 +120,7 @@
- spring-mvc + spring-security-login src/main/resources diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index b13c73dce375..4aadc3a48c92 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -24,7 +24,7 @@ public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); registry.addViewController("/login.html"); - registry.addViewController("/sample.html"); + registry.addViewController("/homepage.html"); } @Bean diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 2b38e4cf17e7..7079e0e04b39 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -9,11 +9,9 @@ - - - diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp index b026d0df44b3..d64f1e2f62dd 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp @@ -3,5 +3,24 @@

Login

+ +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+ \ No newline at end of file From a21d9e45387b3b6e36b73b7c0a01614dfb0c204c Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 16:20:41 +0300 Subject: [PATCH 016/796] project work --- spring-security-login/.classpath | 6 ------ spring-security-login/.project | 1 - spring-security-login/.settings/.jsdtscope | 7 ------- spring-security-login/.settings/org.eclipse.jdt.core.prefs | 4 ++++ .../org.eclipse.wst.common.project.facet.core.xml | 1 - .../src/main/webapp/WEB-INF/view/login.jsp | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/spring-security-login/.classpath b/spring-security-login/.classpath index eed10d8a8b04..5dea19367768 100644 --- a/spring-security-login/.classpath +++ b/spring-security-login/.classpath @@ -6,12 +6,6 @@ - - - - - - diff --git a/spring-security-login/.project b/spring-security-login/.project index 1ba7568736b9..49eecbd6a380 100644 --- a/spring-security-login/.project +++ b/spring-security-login/.project @@ -54,7 +54,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature org.zeroturnaround.eclipse.jrebelNature
diff --git a/spring-security-login/.settings/.jsdtscope b/spring-security-login/.settings/.jsdtscope index b46b9207a89e..7b3f0c8b9fae 100644 --- a/spring-security-login/.settings/.jsdtscope +++ b/spring-security-login/.settings/.jsdtscope @@ -1,12 +1,5 @@ - - - - - - - diff --git a/spring-security-login/.settings/org.eclipse.jdt.core.prefs b/spring-security-login/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..723e5b12451a 100644 --- a/spring-security-login/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-login/.settings/org.eclipse.jdt.core.prefs @@ -6,7 +6,11 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore diff --git a/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml index a67649dfa5ae..b46bc511b943 100644 --- a/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,5 @@ - diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp index d64f1e2f62dd..ba8b7748042b 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp @@ -4,7 +4,7 @@

Login

-
+ From bcc0338f7a75066e8b7a8b7d4be2f5a5812740ea Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 May 2013 16:59:54 +0300 Subject: [PATCH 017/796] login work --- .../src/main/resources/webSecurityConfig.xml | 8 ++++++-- .../src/main/webapp/WEB-INF/view/login.jsp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 7079e0e04b39..6394c926995b 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -9,8 +9,12 @@ - + diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp index ba8b7748042b..013ceccb4e4d 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp @@ -4,7 +4,7 @@

Login

- +
From dfd157bb9db0d69608e83114ad1ae543681b88f3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 21:38:51 +0300 Subject: [PATCH 018/796] initial work on DAO - spring with hibernate --- spring-hibernate-dao/.classpath | 37 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-hibernate-dao/.gitignore | 13 ++ spring-hibernate-dao/.project | 60 ++++++++ spring-hibernate-dao/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 ++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-hibernate-dao/.springBeans | 14 ++ spring-hibernate-dao/README.md | 3 + spring-hibernate-dao/pom.xml | 133 ++++++++++++++++++ .../spring/web/config/PersistenceConfig.java | 14 ++ .../src/main/resources/logback.xml | 60 ++++++++ .../src/main/resources/webSecurityConfig.xml | 36 +++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 42 ++++++ .../src/test/resources/.gitignore | 13 ++ 25 files changed, 643 insertions(+) create mode 100644 spring-hibernate-dao/.classpath create mode 100644 spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-hibernate-dao/.gitignore create mode 100644 spring-hibernate-dao/.project create mode 100644 spring-hibernate-dao/.settings/.jsdtscope create mode 100644 spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.common.component create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-hibernate-dao/.springBeans create mode 100644 spring-hibernate-dao/README.md create mode 100644 spring-hibernate-dao/pom.xml create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java create mode 100644 spring-hibernate-dao/src/main/resources/logback.xml create mode 100644 spring-hibernate-dao/src/main/resources/webSecurityConfig.xml create mode 100644 spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-hibernate-dao/src/test/resources/.gitignore diff --git a/spring-hibernate-dao/.classpath b/spring-hibernate-dao/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-hibernate-dao/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-hibernate-dao/.gitignore b/spring-hibernate-dao/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-hibernate-dao/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-hibernate-dao/.project b/spring-hibernate-dao/.project new file mode 100644 index 000000000000..2335f700600c --- /dev/null +++ b/spring-hibernate-dao/.project @@ -0,0 +1,60 @@ + + + spring-hibernate-dao + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-hibernate-dao/.settings/.jsdtscope b/spring-hibernate-dao/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-hibernate-dao/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs b/spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs b/spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs b/spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9784ac36ee68 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-hibernate-dao/.springBeans b/spring-hibernate-dao/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-hibernate-dao/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-hibernate-dao/README.md b/spring-hibernate-dao/README.md new file mode 100644 index 000000000000..afb2185d6002 --- /dev/null +++ b/spring-hibernate-dao/README.md @@ -0,0 +1,3 @@ +Spring MVC with Java Configuration +========= + diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate-dao/pom.xml new file mode 100644 index 000000000000..3f5af7099049 --- /dev/null +++ b/spring-hibernate-dao/pom.xml @@ -0,0 +1,133 @@ + + 4.0.0 + org.baeldung + spring-hibernate-dao + 0.1-SNAPSHOT + + spring-hibernate-dao + war + + + + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-entitymanager + 4.2.1.Final + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java new file mode 100644 index 000000000000..b3348756e79c --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Configuration; + +@Configuration +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/resources/logback.xml b/spring-hibernate-dao/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-hibernate-dao/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/resources/webSecurityConfig.xml b/spring-hibernate-dao/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-hibernate-dao/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/test/resources/.gitignore b/spring-hibernate-dao/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-hibernate-dao/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From e8ffb362e6a6293e9884113bc1bb8238b7ef52ea Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:36:14 +0300 Subject: [PATCH 019/796] persistence work --- spring-hibernate-dao/pom.xml | 8 +- .../persistence/config/PersistenceConfig.java | 73 +++++++++++++++++++ .../spring/persistence/dao/FooDao.java | 14 ++++ .../spring/persistence/model/Foo.java | 8 ++ .../spring/web/config/PersistenceConfig.java | 14 ---- .../resources/persistence-mysql.properties | 10 +++ .../src/main/webapp/WEB-INF/web.xml | 64 ++++++++-------- 7 files changed, 143 insertions(+), 48 deletions(-) create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java delete mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java create mode 100644 spring-hibernate-dao/src/main/resources/persistence-mysql.properties diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate-dao/pom.xml index 3f5af7099049..ff6b79458063 100644 --- a/spring-hibernate-dao/pom.xml +++ b/spring-hibernate-dao/pom.xml @@ -24,12 +24,18 @@ + + + + + org.hibernate - hibernate-entitymanager + hibernate-core 4.2.1.Final + diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java new file mode 100644 index 000000000000..33833f364cf9 --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -0,0 +1,73 @@ +package org.baeldung.spring.persistence.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public AnnotationSessionFactoryBean alertsSessionFactory() { + final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.rest" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); + dataSource.setUrl(env.getProperty("jdbc.url")); + dataSource.setUsername(env.getProperty("jdbc.user")); + dataSource.setPassword(env.getProperty("jdbc.pass")); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(alertsSessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java new file mode 100644 index 000000000000..a497d14dd48c --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.persistence.dao; + +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao { + + public FooDao() { + super(); + } + + // API + +} diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java new file mode 100644 index 000000000000..01a3693325ad --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.model; + +import javax.persistence.Entity; + +@Entity +public class Foo { + // +} diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java deleted file mode 100644 index b3348756e79c..000000000000 --- a/spring-hibernate-dao/src/main/java/org/baeldung/spring/web/config/PersistenceConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring.web.config; - -import org.springframework.context.annotation.Configuration; - -@Configuration -public class PersistenceConfig { - - public PersistenceConfig() { - super(); - } - - // API - -} \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/resources/persistence-mysql.properties b/spring-hibernate-dao/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..a1ff997616ae --- /dev/null +++ b/spring-hibernate-dao/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml index ba2bb591ed01..7e3d3b3181dc 100644 --- a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml @@ -1,42 +1,40 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring.web.config - + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.persistence.config + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + - - index.html - + + index.html + \ No newline at end of file From 8c497f4e1967875c097c077e775bd19868250a5d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:38:57 +0300 Subject: [PATCH 020/796] eclipse cleanup --- spring-hibernate-dao/.classpath | 9 +- ...e.wst.jsdt.core.javascriptValidator.launch | 7 -- .../.settings/org.eclipse.jdt.core.prefs | 89 +------------------ .../org.eclipse.wst.common.component | 6 +- spring-hibernate-dao/pom.xml | 2 +- 5 files changed, 8 insertions(+), 105 deletions(-) delete mode 100644 spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-hibernate-dao/.classpath b/spring-hibernate-dao/.classpath index eed10d8a8b04..270b2f28fc7b 100644 --- a/spring-hibernate-dao/.classpath +++ b/spring-hibernate-dao/.classpath @@ -6,12 +6,6 @@ - - - - - - @@ -22,7 +16,7 @@ - + @@ -30,7 +24,6 @@ - diff --git a/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch deleted file mode 100644 index 627021fb9640..000000000000 --- a/spring-hibernate-dao/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..45a6e0e0d5a1 100644 --- a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs @@ -1,91 +1,8 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=error -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=error -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component index 9784ac36ee68..a4e21eb5728e 100644 --- a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate-dao/pom.xml index ff6b79458063..f72835845ebd 100644 --- a/spring-hibernate-dao/pom.xml +++ b/spring-hibernate-dao/pom.xml @@ -68,7 +68,7 @@ - spring-mvc + spring-hibernate-dao src/main/resources From debee3bf5c874e6075120b192294a78716993494 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:40:30 +0300 Subject: [PATCH 021/796] eclipse cleanup --- spring-hibernate-dao/.classpath | 7 +++++++ .../.settings/org.eclipse.jdt.core.prefs | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/spring-hibernate-dao/.classpath b/spring-hibernate-dao/.classpath index 270b2f28fc7b..721d2ae4b77a 100644 --- a/spring-hibernate-dao/.classpath +++ b/spring-hibernate-dao/.classpath @@ -16,6 +16,12 @@ + + + + + + @@ -24,6 +30,7 @@ + diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs index 45a6e0e0d5a1..62492222ad2e 100644 --- a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 From 015050f9288e84c0bfc82604e9ceebdab56cddce Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:44:39 +0300 Subject: [PATCH 022/796] persistence work --- spring-hibernate-dao/pom.xml | 284 +++++++++--------- .../persistence/config/PersistenceConfig.java | 10 +- .../src/main/webapp/WEB-INF/web.xml | 26 +- 3 files changed, 167 insertions(+), 153 deletions(-) diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate-dao/pom.xml index f72835845ebd..3eee87711757 100644 --- a/spring-hibernate-dao/pom.xml +++ b/spring-hibernate-dao/pom.xml @@ -1,139 +1,151 @@ - 4.0.0 - org.baeldung - spring-hibernate-dao - 0.1-SNAPSHOT - - spring-hibernate-dao - war - - - - - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - - - - - - org.hibernate - hibernate-core - 4.2.1.Final - - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-hibernate-dao - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.2.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.4 - - 1.8.0 - 1.8.9 - - + 4.0.0 + org.baeldung + spring-hibernate-dao + 0.1-SNAPSHOT + + spring-hibernate-dao + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + + + + com.google.guava + guava + 14.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate-dao + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + \ No newline at end of file diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 33833f364cf9..fa7138f74249 100644 --- a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -15,6 +15,8 @@ import org.springframework.orm.hibernate4.HibernateTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.google.common.base.Preconditions; + @Configuration @EnableTransactionManagement @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) @@ -40,10 +42,10 @@ public AnnotationSessionFactoryBean alertsSessionFactory() { @Bean public DataSource restDataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); - dataSource.setUrl(env.getProperty("jdbc.url")); - dataSource.setUsername(env.getProperty("jdbc.user")); - dataSource.setPassword(env.getProperty("jdbc.pass")); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); return dataSource; } diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml index 7e3d3b3181dc..ebe53ec4c065 100644 --- a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml @@ -22,19 +22,19 @@ org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + + + + + + + + - - index.html - + + + \ No newline at end of file From 480edf4a3c9ce53c3977e0e143915a1b427a64a2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:45:59 +0300 Subject: [PATCH 023/796] initial service work --- .../spring/persistence/dao/FooDao.java | 2 +- .../spring/persistence/dao/IFooDao.java | 5 +++++ .../persistence/service/FooService.java | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java create mode 100644 spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index a497d14dd48c..a59bb30f48b1 100644 --- a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -3,7 +3,7 @@ import org.springframework.stereotype.Repository; @Repository -public class FooDao { +public class FooDao implements IFooDao { public FooDao() { super(); diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..91d44f5f6bfb --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -0,0 +1,5 @@ +package org.baeldung.spring.persistence.dao; + +public interface IFooDao { + // +} diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java new file mode 100644 index 000000000000..cda31a0e86ef --- /dev/null +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.IFooDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + @Autowired + private IFooDao fooDao; + + public FooService() { + super(); + } + + // API + +} From 38803691b9ea787294ba6aba13c36161896d6f78 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 May 2013 22:53:36 +0300 Subject: [PATCH 024/796] further config --- spring-hibernate-dao/pom.xml | 16 +++++++++---- .../persistence/config/PersistenceConfig.java | 12 ++++++---- .../spring/persistence/model/Foo.java | 23 +++++++++++++++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate-dao/pom.xml index 3eee87711757..d60e33bcd210 100644 --- a/spring-hibernate-dao/pom.xml +++ b/spring-hibernate-dao/pom.xml @@ -29,16 +29,22 @@ - - - - - + + org.hibernate + hibernate-entitymanager + 4.2.1.Final + org.hibernate hibernate-core 4.2.1.Final + + mysql + mysql-connector-java + 5.1.25 + runtime + diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index fa7138f74249..7e8a78b0c4c9 100644 --- a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -8,17 +8,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean; import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) public class PersistenceConfig { @@ -30,10 +32,10 @@ public PersistenceConfig() { } @Bean - public AnnotationSessionFactoryBean alertsSessionFactory() { - final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.rest" }); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; @@ -53,7 +55,7 @@ public DataSource restDataSource() { @Bean public HibernateTransactionManager transactionManager() { final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(alertsSessionFactory().getObject()); + txManager.setSessionFactory(sessionFactory().getObject()); return txManager; } diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 01a3693325ad..8842c26d95b1 100644 --- a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -1,8 +1,31 @@ package org.baeldung.spring.persistence.model; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; @Entity public class Foo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + public Foo() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + // + } From f6c7a693528b6717f650cd62e40862ab8c7862dc Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 01:36:56 +0300 Subject: [PATCH 025/796] rename --- spring-hibernate-dao/.project | 2 +- .../org.eclipse.wst.common.component | 6 +-- .../src/main/webapp/WEB-INF/web.xml | 49 +++++-------------- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/spring-hibernate-dao/.project b/spring-hibernate-dao/.project index 2335f700600c..320788977023 100644 --- a/spring-hibernate-dao/.project +++ b/spring-hibernate-dao/.project @@ -1,6 +1,6 @@ - spring-hibernate-dao + spring-hibernate4-dao diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component index a4e21eb5728e..2746e4b44396 100644 --- a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate-dao/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml index ebe53ec4c065..e0de9aefd45a 100644 --- a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml +++ b/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml @@ -1,40 +1,17 @@ - - - Spring MVC Application - - - - contextClass - + + Spring MVC Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.persistence.config - - - - org.springframework.web.context.ContextLoaderListener - - - - - - - - - - - - - - - - - + + + contextConfigLocation + org.baeldung.spring.persistence.config + + + org.springframework.web.context.ContextLoaderListener + \ No newline at end of file From aff48b8bb0d10e091f4d18191d72fb43d4d74bb5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 01:38:26 +0300 Subject: [PATCH 026/796] rename --- {spring-hibernate-dao => spring-hibernate4-dao}/.classpath | 0 {spring-hibernate-dao => spring-hibernate4-dao}/.gitignore | 0 {spring-hibernate-dao => spring-hibernate4-dao}/.project | 0 .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../.settings/org.eclipse.wst.common.component | 0 .../.settings/org.eclipse.wst.common.project.facet.core.xml | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.container | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.name | 0 .../.settings/org.eclipse.wst.validation.prefs | 0 .../.settings/org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 {spring-hibernate-dao => spring-hibernate4-dao}/README.md | 0 {spring-hibernate-dao => spring-hibernate4-dao}/pom.xml | 6 +++--- .../spring/persistence/config/PersistenceConfig.java | 0 .../java/org/baeldung/spring/persistence/dao/FooDao.java | 0 .../java/org/baeldung/spring/persistence/dao/IFooDao.java | 0 .../java/org/baeldung/spring/persistence/model/Foo.java | 0 .../org/baeldung/spring/persistence/service/FooService.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/persistence-mysql.properties | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 29 files changed, 3 insertions(+), 3 deletions(-) rename {spring-hibernate-dao => spring-hibernate4-dao}/.classpath (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.gitignore (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.project (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/.jsdtscope (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.common.component (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/.springBeans (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/README.md (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/pom.xml (97%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/java/org/baeldung/spring/persistence/model/Foo.java (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/java/org/baeldung/spring/persistence/service/FooService.java (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/resources/logback.xml (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/resources/persistence-mysql.properties (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-hibernate-dao => spring-hibernate4-dao}/src/test/resources/.gitignore (100%) diff --git a/spring-hibernate-dao/.classpath b/spring-hibernate4-dao/.classpath similarity index 100% rename from spring-hibernate-dao/.classpath rename to spring-hibernate4-dao/.classpath diff --git a/spring-hibernate-dao/.gitignore b/spring-hibernate4-dao/.gitignore similarity index 100% rename from spring-hibernate-dao/.gitignore rename to spring-hibernate4-dao/.gitignore diff --git a/spring-hibernate-dao/.project b/spring-hibernate4-dao/.project similarity index 100% rename from spring-hibernate-dao/.project rename to spring-hibernate4-dao/.project diff --git a/spring-hibernate-dao/.settings/.jsdtscope b/spring-hibernate4-dao/.settings/.jsdtscope similarity index 100% rename from spring-hibernate-dao/.settings/.jsdtscope rename to spring-hibernate4-dao/.settings/.jsdtscope diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4-dao/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.jdt.core.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs b/spring-hibernate4-dao/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.jdt.ui.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs b/spring-hibernate4-dao/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.m2e.core.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs b/spring-hibernate4-dao/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.m2e.wtp.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate4-dao/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.common.component rename to spring-hibernate4-dao/.settings/org.eclipse.wst.common.component diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-hibernate4-dao/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-hibernate4-dao/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate4-dao/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.validation.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-hibernate4-dao/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-hibernate-dao/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-hibernate4-dao/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-hibernate-dao/.springBeans b/spring-hibernate4-dao/.springBeans similarity index 100% rename from spring-hibernate-dao/.springBeans rename to spring-hibernate4-dao/.springBeans diff --git a/spring-hibernate-dao/README.md b/spring-hibernate4-dao/README.md similarity index 100% rename from spring-hibernate-dao/README.md rename to spring-hibernate4-dao/README.md diff --git a/spring-hibernate-dao/pom.xml b/spring-hibernate4-dao/pom.xml similarity index 97% rename from spring-hibernate-dao/pom.xml rename to spring-hibernate4-dao/pom.xml index d60e33bcd210..ca2aacde8e65 100644 --- a/spring-hibernate-dao/pom.xml +++ b/spring-hibernate4-dao/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-hibernate-dao + spring-hibernate4-dao 0.1-SNAPSHOT - spring-hibernate-dao + spring-hibernate4-dao war @@ -86,7 +86,7 @@ - spring-hibernate-dao + spring-hibernate4-dao src/main/resources diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java similarity index 100% rename from spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java similarity index 100% rename from spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java similarity index 100% rename from spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java rename to spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java similarity index 100% rename from spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java diff --git a/spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java similarity index 100% rename from spring-hibernate-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java diff --git a/spring-hibernate-dao/src/main/resources/logback.xml b/spring-hibernate4-dao/src/main/resources/logback.xml similarity index 100% rename from spring-hibernate-dao/src/main/resources/logback.xml rename to spring-hibernate4-dao/src/main/resources/logback.xml diff --git a/spring-hibernate-dao/src/main/resources/persistence-mysql.properties b/spring-hibernate4-dao/src/main/resources/persistence-mysql.properties similarity index 100% rename from spring-hibernate-dao/src/main/resources/persistence-mysql.properties rename to spring-hibernate4-dao/src/main/resources/persistence-mysql.properties diff --git a/spring-hibernate-dao/src/main/resources/webSecurityConfig.xml b/spring-hibernate4-dao/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-hibernate-dao/src/main/resources/webSecurityConfig.xml rename to spring-hibernate4-dao/src/main/resources/webSecurityConfig.xml diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate4-dao/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-hibernate-dao/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-hibernate4-dao/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate4-dao/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-hibernate-dao/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-hibernate4-dao/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate4-dao/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-hibernate-dao/src/main/webapp/WEB-INF/web.xml rename to spring-hibernate4-dao/src/main/webapp/WEB-INF/web.xml diff --git a/spring-hibernate-dao/src/test/resources/.gitignore b/spring-hibernate4-dao/src/test/resources/.gitignore similarity index 100% rename from spring-hibernate-dao/src/test/resources/.gitignore rename to spring-hibernate4-dao/src/test/resources/.gitignore From a468d634f047b08e9e8ff60f85a7a1f57a99c688 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 01:39:02 +0300 Subject: [PATCH 027/796] rename --- spring-hibernate4-dao/.classpath | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spring-hibernate4-dao/.classpath b/spring-hibernate4-dao/.classpath index 721d2ae4b77a..9c9f508af047 100644 --- a/spring-hibernate4-dao/.classpath +++ b/spring-hibernate4-dao/.classpath @@ -16,12 +16,6 @@ - - - - - - From 5ac1e624297c12acc029c5ecc7f235e1a99f55e9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 17:34:38 +0300 Subject: [PATCH 028/796] hibernate 3 work --- spring-hibernate3-dao/.classpath | 31 ++++ spring-hibernate3-dao/.gitignore | 13 ++ spring-hibernate3-dao/.project | 60 +++++++ spring-hibernate3-dao/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-hibernate3-dao/.springBeans | 14 ++ spring-hibernate3-dao/README.md | 3 + spring-hibernate3-dao/pom.xml | 152 ++++++++++++++++++ .../persistence/config/PersistenceConfig.java | 77 +++++++++ .../spring/persistence/dao/FooDao.java | 14 ++ .../spring/persistence/dao/IFooDao.java | 5 + .../spring/persistence/model/Foo.java | 31 ++++ .../persistence/service/FooService.java | 19 +++ .../src/main/resources/logback.xml | 60 +++++++ .../resources/persistence-mysql.properties | 10 ++ .../src/main/resources/webSecurityConfig.xml | 36 +++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 17 ++ .../src/test/resources/.gitignore | 13 ++ 29 files changed, 687 insertions(+) create mode 100644 spring-hibernate3-dao/.classpath create mode 100644 spring-hibernate3-dao/.gitignore create mode 100644 spring-hibernate3-dao/.project create mode 100644 spring-hibernate3-dao/.settings/.jsdtscope create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.common.component create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-hibernate3-dao/.springBeans create mode 100644 spring-hibernate3-dao/README.md create mode 100644 spring-hibernate3-dao/pom.xml create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java create mode 100644 spring-hibernate3-dao/src/main/resources/logback.xml create mode 100644 spring-hibernate3-dao/src/main/resources/persistence-mysql.properties create mode 100644 spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml create mode 100644 spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-hibernate3-dao/src/test/resources/.gitignore diff --git a/spring-hibernate3-dao/.classpath b/spring-hibernate3-dao/.classpath new file mode 100644 index 000000000000..9c9f508af047 --- /dev/null +++ b/spring-hibernate3-dao/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-hibernate3-dao/.gitignore b/spring-hibernate3-dao/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-hibernate3-dao/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-hibernate3-dao/.project b/spring-hibernate3-dao/.project new file mode 100644 index 000000000000..8aa9e7ad5822 --- /dev/null +++ b/spring-hibernate3-dao/.project @@ -0,0 +1,60 @@ + + + spring-hibernate3-dao + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-hibernate3-dao/.settings/.jsdtscope b/spring-hibernate3-dao/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-hibernate3-dao/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..62492222ad2e --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs b/spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs b/spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs b/spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate3-dao/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..557fa1bf21e8 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-hibernate3-dao/.springBeans b/spring-hibernate3-dao/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-hibernate3-dao/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-hibernate3-dao/README.md b/spring-hibernate3-dao/README.md new file mode 100644 index 000000000000..afb2185d6002 --- /dev/null +++ b/spring-hibernate3-dao/README.md @@ -0,0 +1,3 @@ +Spring MVC with Java Configuration +========= + diff --git a/spring-hibernate3-dao/pom.xml b/spring-hibernate3-dao/pom.xml new file mode 100644 index 000000000000..8458cd7b729b --- /dev/null +++ b/spring-hibernate3-dao/pom.xml @@ -0,0 +1,152 @@ + + 4.0.0 + org.baeldung + spring-hibernate3-dao + 0.1-SNAPSHOT + + spring-hibernate3-dao + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 3.6.10.Final + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate3-dao + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java new file mode 100644 index 000000000000..13922658a607 --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -0,0 +1,77 @@ +package org.baeldung.spring.persistence.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate3.HibernateTransactionManager; +import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public AnnotationSessionFactoryBean sessionFactory() { + final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java new file mode 100644 index 000000000000..a59bb30f48b1 --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.persistence.dao; + +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao implements IFooDao { + + public FooDao() { + super(); + } + + // API + +} diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..91d44f5f6bfb --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -0,0 +1,5 @@ +package org.baeldung.spring.persistence.dao; + +public interface IFooDao { + // +} diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java new file mode 100644 index 000000000000..8842c26d95b1 --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -0,0 +1,31 @@ +package org.baeldung.spring.persistence.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + public Foo() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + // + +} diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java new file mode 100644 index 000000000000..cda31a0e86ef --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.IFooDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + @Autowired + private IFooDao fooDao; + + public FooService() { + super(); + } + + // API + +} diff --git a/spring-hibernate3-dao/src/main/resources/logback.xml b/spring-hibernate3-dao/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-hibernate3-dao/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/resources/persistence-mysql.properties b/spring-hibernate3-dao/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..a1ff997616ae --- /dev/null +++ b/spring-hibernate3-dao/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml b/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..e0de9aefd45a --- /dev/null +++ b/spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + Spring MVC Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.persistence.config + + + org.springframework.web.context.ContextLoaderListener + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/test/resources/.gitignore b/spring-hibernate3-dao/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-hibernate3-dao/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From c3dd5900dcc9a4566ca6705ebaa6d586315fe8f4 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 17:49:00 +0300 Subject: [PATCH 029/796] hibernate proxy enabled --- spring-hibernate3-dao/pom.xml | 5 +++++ .../spring/persistence/config/PersistenceConfig.java | 2 ++ spring-hibernate4-dao/pom.xml | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spring-hibernate3-dao/pom.xml b/spring-hibernate3-dao/pom.xml index 8458cd7b729b..d2adea1f25ce 100644 --- a/spring-hibernate3-dao/pom.xml +++ b/spring-hibernate3-dao/pom.xml @@ -34,6 +34,11 @@ hibernate-core 3.6.10.Final
+ + org.javassist + javassist + 3.17.1-GA + mysql mysql-connector-java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 13922658a607..f6a0e0d76faf 100644 --- a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -69,6 +69,8 @@ final Properties hibernateProperties() { return new Properties() { { setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // setProperty("hibernate.globally_quoted_identifiers", "true"); // note: necessary in launchpad-storage, but causing problems here } diff --git a/spring-hibernate4-dao/pom.xml b/spring-hibernate4-dao/pom.xml index ca2aacde8e65..940289493dc9 100644 --- a/spring-hibernate4-dao/pom.xml +++ b/spring-hibernate4-dao/pom.xml @@ -31,13 +31,13 @@ org.hibernate - hibernate-entitymanager + hibernate-core 4.2.1.Final - org.hibernate - hibernate-core - 4.2.1.Final + org.javassist + javassist + 3.17.1-GA mysql From 174f3fcc3e18ff8c96cff854609ce775c862a976 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 17:51:11 +0300 Subject: [PATCH 030/796] config fix --- .../baeldung/spring/persistence/config/PersistenceConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 7e8a78b0c4c9..3157c92e9924 100644 --- a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -69,6 +69,8 @@ final Properties hibernateProperties() { return new Properties() { { setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // setProperty("hibernate.globally_quoted_identifiers", "true"); // note: necessary in launchpad-storage, but causing problems here } From 4f0baa25c95ea18ff89e336be6be262019626190 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 20:58:56 +0300 Subject: [PATCH 031/796] xml configuration introduced --- .../persistence/config/PersistenceConfig.java | 3 +- .../config/PersistenceXmlConfig.java | 18 ++++++++++ .../src/main/resources/persistenceConfig.xml | 35 ++++++++++++++++++ .../src/main/resources/webSecurityConfig.xml | 36 ------------------- 4 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java create mode 100644 spring-hibernate3-dao/src/main/resources/persistenceConfig.xml delete mode 100644 spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index f6a0e0d76faf..e8f448f4c2e6 100644 --- a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -18,7 +17,7 @@ import com.google.common.base.Preconditions; -@Configuration +// @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java new file mode 100644 index 000000000000..d8791b6bcc7b --- /dev/null +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.spring.persistence.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ImportResource({ "classpath:persistenceConfig.xml" }) +public class PersistenceXmlConfig { + + public PersistenceXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/resources/persistenceConfig.xml b/spring-hibernate3-dao/src/main/resources/persistenceConfig.xml new file mode 100644 index 000000000000..0dc729f815dd --- /dev/null +++ b/spring-hibernate3-dao/src/main/resources/persistenceConfig.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml b/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 5569cc69508a..000000000000 --- a/spring-hibernate3-dao/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From a7ea6c8a826a9a1571666218c1b55afb91117a2a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 May 2013 21:21:30 +0300 Subject: [PATCH 032/796] mainly doc work --- spring-hibernate3-dao/README.md | 2 +- .../baeldung/spring/persistence/config/PersistenceConfig.java | 4 ++-- spring-hibernate4-dao/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-hibernate3-dao/README.md b/spring-hibernate3-dao/README.md index afb2185d6002..89dd04db8206 100644 --- a/spring-hibernate3-dao/README.md +++ b/spring-hibernate3-dao/README.md @@ -1,3 +1,3 @@ -Spring MVC with Java Configuration +Hibernate 3 with Spring ========= diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index e8f448f4c2e6..b59ea8e3414e 100644 --- a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -33,7 +33,7 @@ public PersistenceConfig() { @Bean public AnnotationSessionFactoryBean sessionFactory() { final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); + sessionFactory.setDataSource(dataSource()); sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); @@ -41,7 +41,7 @@ public AnnotationSessionFactoryBean sessionFactory() { } @Bean - public DataSource restDataSource() { + public DataSource dataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); diff --git a/spring-hibernate4-dao/README.md b/spring-hibernate4-dao/README.md index afb2185d6002..12eb079c88b1 100644 --- a/spring-hibernate4-dao/README.md +++ b/spring-hibernate4-dao/README.md @@ -1,3 +1,3 @@ -Spring MVC with Java Configuration +Hibernate 4 with Spring ========= From a79e53e49106346a2392b47f3cba885c0a78e60a Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 7 May 2013 12:35:44 +0300 Subject: [PATCH 033/796] minor eclipse work --- spring-hibernate4-dao/.classpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-hibernate4-dao/.classpath b/spring-hibernate4-dao/.classpath index 9c9f508af047..593395a46e93 100644 --- a/spring-hibernate4-dao/.classpath +++ b/spring-hibernate4-dao/.classpath @@ -16,7 +16,7 @@ - + From 68c266c38543b7bb20c0b726b89fa80e3513979c Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 7 May 2013 12:37:22 +0300 Subject: [PATCH 034/796] minor eclipse work --- spring-hibernate3-dao/.classpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-hibernate3-dao/.classpath b/spring-hibernate3-dao/.classpath index 9c9f508af047..593395a46e93 100644 --- a/spring-hibernate3-dao/.classpath +++ b/spring-hibernate3-dao/.classpath @@ -16,7 +16,7 @@ - + From 93ad11b90ab606ee853c46579fcf5f61057f37e7 Mon Sep 17 00:00:00 2001 From: Eugen Date: Thu, 9 May 2013 17:11:44 +0300 Subject: [PATCH 035/796] minor doc work --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bae1a993f761..92e85d956fd3 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,19 @@ Spring Tutorials Spring MVC ========= -[Spring MVC Example with Java based Configuration](http://www.baeldung.com/spring-mvc-java-configuration) +[Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) + + +Spring Persistence +========= +[Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) + + +Spring Security +========= +[Spring Security Login](http://www.baeldung.com/spring-security-login) + + + + From 15ec7c16120042a20392bf5c604f49ad2188266a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 May 2013 14:27:39 +0300 Subject: [PATCH 036/796] persistence work and tutorial renaming --- .../.classpath | 0 .../.gitignore | 0 .../.project | 0 .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 0 ....eclipse.wst.common.project.facet.core.xml | 0 ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 .../README.md | 0 .../pom.xml | 0 .../persistence/config/PersistenceConfig.java | 0 .../config/PersistenceXmlConfig.java | 0 .../spring/persistence/dao/FooDao.java | 0 .../spring/persistence/dao/IFooDao.java | 0 .../spring/persistence/model/Foo.java | 0 .../persistence/service/FooService.java | 0 .../src/main/resources/logback.xml | 0 .../resources/persistence-mysql.properties | 0 .../src/main/resources/persistenceConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 .../.classpath | 0 .../.gitignore | 0 .../.project | 2 +- .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 6 ++-- ....eclipse.wst.common.project.facet.core.xml | 0 ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 .../README.md | 0 .../pom.xml | 6 ++-- .../config/HibernateXmlConfig.java | 18 ++++++++++ .../persistence/config/PersistenceConfig.java | 0 .../spring/persistence/dao/FooDao.java | 0 .../spring/persistence/dao/IFooDao.java | 0 .../spring/persistence/model/Foo.java | 0 .../persistence/service/FooService.java | 0 .../src/main/resources/hibernate4Config.xml | 35 +++++++++++++++++++ .../src/main/resources/logback.xml | 0 .../resources/persistence-mysql.properties | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 61 files changed, 60 insertions(+), 7 deletions(-) rename {spring-hibernate3-dao => spring-hibernate3}/.classpath (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.gitignore (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.project (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/.jsdtscope (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.common.component (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-hibernate3-dao => spring-hibernate3}/.springBeans (100%) rename {spring-hibernate3-dao => spring-hibernate3}/README.md (100%) rename {spring-hibernate3-dao => spring-hibernate3}/pom.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/model/Foo.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/java/org/baeldung/spring/persistence/service/FooService.java (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/resources/logback.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/resources/persistence-mysql.properties (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/resources/persistenceConfig.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-hibernate3-dao => spring-hibernate3}/src/test/resources/.gitignore (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.classpath (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.gitignore (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.project (98%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/.jsdtscope (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.common.component (78%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-hibernate4-dao => spring-hibernate4}/.springBeans (100%) rename {spring-hibernate4-dao => spring-hibernate4}/README.md (100%) rename {spring-hibernate4-dao => spring-hibernate4}/pom.xml (97%) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java rename {spring-hibernate4-dao => spring-hibernate4}/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/java/org/baeldung/spring/persistence/model/Foo.java (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/java/org/baeldung/spring/persistence/service/FooService.java (100%) create mode 100644 spring-hibernate4/src/main/resources/hibernate4Config.xml rename {spring-hibernate4-dao => spring-hibernate4}/src/main/resources/logback.xml (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/resources/persistence-mysql.properties (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-hibernate4-dao => spring-hibernate4}/src/test/resources/.gitignore (100%) diff --git a/spring-hibernate3-dao/.classpath b/spring-hibernate3/.classpath similarity index 100% rename from spring-hibernate3-dao/.classpath rename to spring-hibernate3/.classpath diff --git a/spring-hibernate3-dao/.gitignore b/spring-hibernate3/.gitignore similarity index 100% rename from spring-hibernate3-dao/.gitignore rename to spring-hibernate3/.gitignore diff --git a/spring-hibernate3-dao/.project b/spring-hibernate3/.project similarity index 100% rename from spring-hibernate3-dao/.project rename to spring-hibernate3/.project diff --git a/spring-hibernate3-dao/.settings/.jsdtscope b/spring-hibernate3/.settings/.jsdtscope similarity index 100% rename from spring-hibernate3-dao/.settings/.jsdtscope rename to spring-hibernate3/.settings/.jsdtscope diff --git a/spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.jdt.core.prefs rename to spring-hibernate3/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs b/spring-hibernate3/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.jdt.ui.prefs rename to spring-hibernate3/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs b/spring-hibernate3/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.m2e.core.prefs rename to spring-hibernate3/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs b/spring-hibernate3/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.m2e.wtp.prefs rename to spring-hibernate3/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate3/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.common.component rename to spring-hibernate3/.settings/org.eclipse.wst.common.component diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-hibernate3/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-hibernate3/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-hibernate3/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-hibernate3/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-hibernate3/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-hibernate3/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate3/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.validation.prefs rename to spring-hibernate3/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-hibernate3/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-hibernate3-dao/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-hibernate3/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-hibernate3-dao/.springBeans b/spring-hibernate3/.springBeans similarity index 100% rename from spring-hibernate3-dao/.springBeans rename to spring-hibernate3/.springBeans diff --git a/spring-hibernate3-dao/README.md b/spring-hibernate3/README.md similarity index 100% rename from spring-hibernate3-dao/README.md rename to spring-hibernate3/README.md diff --git a/spring-hibernate3-dao/pom.xml b/spring-hibernate3/pom.xml similarity index 100% rename from spring-hibernate3-dao/pom.xml rename to spring-hibernate3/pom.xml diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java diff --git a/spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java similarity index 100% rename from spring-hibernate3-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java diff --git a/spring-hibernate3-dao/src/main/resources/logback.xml b/spring-hibernate3/src/main/resources/logback.xml similarity index 100% rename from spring-hibernate3-dao/src/main/resources/logback.xml rename to spring-hibernate3/src/main/resources/logback.xml diff --git a/spring-hibernate3-dao/src/main/resources/persistence-mysql.properties b/spring-hibernate3/src/main/resources/persistence-mysql.properties similarity index 100% rename from spring-hibernate3-dao/src/main/resources/persistence-mysql.properties rename to spring-hibernate3/src/main/resources/persistence-mysql.properties diff --git a/spring-hibernate3-dao/src/main/resources/persistenceConfig.xml b/spring-hibernate3/src/main/resources/persistenceConfig.xml similarity index 100% rename from spring-hibernate3-dao/src/main/resources/persistenceConfig.xml rename to spring-hibernate3/src/main/resources/persistenceConfig.xml diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-hibernate3-dao/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate3/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-hibernate3-dao/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-hibernate3/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate3/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-hibernate3-dao/src/main/webapp/WEB-INF/web.xml rename to spring-hibernate3/src/main/webapp/WEB-INF/web.xml diff --git a/spring-hibernate3-dao/src/test/resources/.gitignore b/spring-hibernate3/src/test/resources/.gitignore similarity index 100% rename from spring-hibernate3-dao/src/test/resources/.gitignore rename to spring-hibernate3/src/test/resources/.gitignore diff --git a/spring-hibernate4-dao/.classpath b/spring-hibernate4/.classpath similarity index 100% rename from spring-hibernate4-dao/.classpath rename to spring-hibernate4/.classpath diff --git a/spring-hibernate4-dao/.gitignore b/spring-hibernate4/.gitignore similarity index 100% rename from spring-hibernate4-dao/.gitignore rename to spring-hibernate4/.gitignore diff --git a/spring-hibernate4-dao/.project b/spring-hibernate4/.project similarity index 98% rename from spring-hibernate4-dao/.project rename to spring-hibernate4/.project index 320788977023..233d73c017ac 100644 --- a/spring-hibernate4-dao/.project +++ b/spring-hibernate4/.project @@ -1,6 +1,6 @@ - spring-hibernate4-dao + spring-hibernate4 diff --git a/spring-hibernate4-dao/.settings/.jsdtscope b/spring-hibernate4/.settings/.jsdtscope similarity index 100% rename from spring-hibernate4-dao/.settings/.jsdtscope rename to spring-hibernate4/.settings/.jsdtscope diff --git a/spring-hibernate4-dao/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.jdt.core.prefs rename to spring-hibernate4/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-hibernate4-dao/.settings/org.eclipse.jdt.ui.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.jdt.ui.prefs rename to spring-hibernate4/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-hibernate4-dao/.settings/org.eclipse.m2e.core.prefs b/spring-hibernate4/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.m2e.core.prefs rename to spring-hibernate4/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-hibernate4-dao/.settings/org.eclipse.m2e.wtp.prefs b/spring-hibernate4/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.m2e.wtp.prefs rename to spring-hibernate4/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.common.component b/spring-hibernate4/.settings/org.eclipse.wst.common.component similarity index 78% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.common.component rename to spring-hibernate4/.settings/org.eclipse.wst.common.component index 2746e4b44396..619260207900 100644 --- a/spring-hibernate4-dao/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate4/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-hibernate4/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-hibernate4/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-hibernate4/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-hibernate4/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-hibernate4/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-hibernate4/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate4/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.validation.prefs rename to spring-hibernate4/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-hibernate4-dao/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-hibernate4/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-hibernate4-dao/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-hibernate4/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-hibernate4-dao/.springBeans b/spring-hibernate4/.springBeans similarity index 100% rename from spring-hibernate4-dao/.springBeans rename to spring-hibernate4/.springBeans diff --git a/spring-hibernate4-dao/README.md b/spring-hibernate4/README.md similarity index 100% rename from spring-hibernate4-dao/README.md rename to spring-hibernate4/README.md diff --git a/spring-hibernate4-dao/pom.xml b/spring-hibernate4/pom.xml similarity index 97% rename from spring-hibernate4-dao/pom.xml rename to spring-hibernate4/pom.xml index 940289493dc9..c7171e0acdc5 100644 --- a/spring-hibernate4-dao/pom.xml +++ b/spring-hibernate4/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-hibernate4-dao + spring-hibernate4 0.1-SNAPSHOT - spring-hibernate4-dao + spring-hibernate4 war @@ -86,7 +86,7 @@ - spring-hibernate4-dao + spring-hibernate4 src/main/resources diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java new file mode 100644 index 000000000000..51fbcd27c16d --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.spring.persistence.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ImportResource({ "classpath:hibernate4Config.xml" }) +public class HibernateXmlConfig { + + public HibernateXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java similarity index 100% rename from spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java similarity index 100% rename from spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java similarity index 100% rename from spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java similarity index 100% rename from spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java diff --git a/spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java similarity index 100% rename from spring-hibernate4-dao/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml new file mode 100644 index 000000000000..f35de2a4c5db --- /dev/null +++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-hibernate4-dao/src/main/resources/logback.xml b/spring-hibernate4/src/main/resources/logback.xml similarity index 100% rename from spring-hibernate4-dao/src/main/resources/logback.xml rename to spring-hibernate4/src/main/resources/logback.xml diff --git a/spring-hibernate4-dao/src/main/resources/persistence-mysql.properties b/spring-hibernate4/src/main/resources/persistence-mysql.properties similarity index 100% rename from spring-hibernate4-dao/src/main/resources/persistence-mysql.properties rename to spring-hibernate4/src/main/resources/persistence-mysql.properties diff --git a/spring-hibernate4-dao/src/main/resources/webSecurityConfig.xml b/spring-hibernate4/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-hibernate4-dao/src/main/resources/webSecurityConfig.xml rename to spring-hibernate4/src/main/resources/webSecurityConfig.xml diff --git a/spring-hibernate4-dao/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-hibernate4-dao/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-hibernate4-dao/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-hibernate4-dao/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-hibernate4-dao/src/main/webapp/WEB-INF/web.xml b/spring-hibernate4/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-hibernate4-dao/src/main/webapp/WEB-INF/web.xml rename to spring-hibernate4/src/main/webapp/WEB-INF/web.xml diff --git a/spring-hibernate4-dao/src/test/resources/.gitignore b/spring-hibernate4/src/test/resources/.gitignore similarity index 100% rename from spring-hibernate4-dao/src/test/resources/.gitignore rename to spring-hibernate4/src/test/resources/.gitignore From aaa1111c79adaf21b718b84a64db8131b63fc032 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 May 2013 16:43:45 +0300 Subject: [PATCH 037/796] initial exception work --- .../.classpath | 31 ++++ .../.gitignore | 13 ++ spring-beandefinitionstoreexception/.project | 60 +++++++ .../.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + .../.springBeans | 14 ++ spring-beandefinitionstoreexception/README.md | 3 + spring-beandefinitionstoreexception/pom.xml | 157 ++++++++++++++++++ .../config/HibernateXmlConfig.java | 18 ++ .../persistence/config/PersistenceConfig.java | 79 +++++++++ .../spring/persistence/dao/FooDao.java | 14 ++ .../spring/persistence/dao/IFooDao.java | 5 + .../spring/persistence/model/Foo.java | 31 ++++ .../persistence/service/FooService.java | 19 +++ .../src/main/resources/hibernate4Config.xml | 35 ++++ .../src/main/resources/logback.xml | 60 +++++++ .../resources/persistence-mysql.properties | 10 ++ .../src/main/resources/webSecurityConfig.xml | 36 ++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 17 ++ .../src/test/resources/.gitignore | 13 ++ 31 files changed, 747 insertions(+) create mode 100644 spring-beandefinitionstoreexception/.classpath create mode 100644 spring-beandefinitionstoreexception/.gitignore create mode 100644 spring-beandefinitionstoreexception/.project create mode 100644 spring-beandefinitionstoreexception/.settings/.jsdtscope create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-beandefinitionstoreexception/.springBeans create mode 100644 spring-beandefinitionstoreexception/README.md create mode 100644 spring-beandefinitionstoreexception/pom.xml create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java create mode 100644 spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml create mode 100644 spring-beandefinitionstoreexception/src/main/resources/logback.xml create mode 100644 spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties create mode 100644 spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml create mode 100644 spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-beandefinitionstoreexception/src/test/resources/.gitignore diff --git a/spring-beandefinitionstoreexception/.classpath b/spring-beandefinitionstoreexception/.classpath new file mode 100644 index 000000000000..593395a46e93 --- /dev/null +++ b/spring-beandefinitionstoreexception/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-beandefinitionstoreexception/.gitignore b/spring-beandefinitionstoreexception/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-beandefinitionstoreexception/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/.project b/spring-beandefinitionstoreexception/.project new file mode 100644 index 000000000000..bb38a257540a --- /dev/null +++ b/spring-beandefinitionstoreexception/.project @@ -0,0 +1,60 @@ + + + spring-beandefinitionstoreexception + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-beandefinitionstoreexception/.settings/.jsdtscope b/spring-beandefinitionstoreexception/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..62492222ad2e --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..bb5464963efb --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-beandefinitionstoreexception/.springBeans b/spring-beandefinitionstoreexception/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-beandefinitionstoreexception/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-beandefinitionstoreexception/README.md b/spring-beandefinitionstoreexception/README.md new file mode 100644 index 000000000000..12eb079c88b1 --- /dev/null +++ b/spring-beandefinitionstoreexception/README.md @@ -0,0 +1,3 @@ +Hibernate 4 with Spring +========= + diff --git a/spring-beandefinitionstoreexception/pom.xml b/spring-beandefinitionstoreexception/pom.xml new file mode 100644 index 000000000000..02cd5f48c9f6 --- /dev/null +++ b/spring-beandefinitionstoreexception/pom.xml @@ -0,0 +1,157 @@ + + 4.0.0 + org.baeldung + spring-beandefinitionstoreexception + 0.1-SNAPSHOT + + spring-beandefinitionstoreexception + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-beandefinitionstoreexception + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java new file mode 100644 index 000000000000..51fbcd27c16d --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.spring.persistence.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ImportResource({ "classpath:hibernate4Config.xml" }) +public class HibernateXmlConfig { + + public HibernateXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java new file mode 100644 index 000000000000..3157c92e9924 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.spring.persistence.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java new file mode 100644 index 000000000000..a59bb30f48b1 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.persistence.dao; + +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao implements IFooDao { + + public FooDao() { + super(); + } + + // API + +} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..91d44f5f6bfb --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -0,0 +1,5 @@ +package org.baeldung.spring.persistence.dao; + +public interface IFooDao { + // +} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java new file mode 100644 index 000000000000..8842c26d95b1 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -0,0 +1,31 @@ +package org.baeldung.spring.persistence.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + public Foo() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + // + +} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java new file mode 100644 index 000000000000..cda31a0e86ef --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.IFooDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + @Autowired + private IFooDao fooDao; + + public FooService() { + super(); + } + + // API + +} diff --git a/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml b/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml new file mode 100644 index 000000000000..f35de2a4c5db --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/resources/logback.xml b/spring-beandefinitionstoreexception/src/main/resources/logback.xml new file mode 100644 index 000000000000..976d267d7d16 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + /var/log/launchpad/launchpad_web.log + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + ERROR + + email-smtp.us-east-1.amazonaws.com + AKIAJI6XLSOAQX3IW6HQ + AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED + true + hanriseldon@gmail.com + info@applieddatalabs.com + TESTING: %logger{20} - %m + + web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n + + + 1000 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties b/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..a1ff997616ae --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml b/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..e0de9aefd45a --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + Spring MVC Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.persistence.config + + + org.springframework.web.context.ContextLoaderListener + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/test/resources/.gitignore b/spring-beandefinitionstoreexception/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-beandefinitionstoreexception/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From fdfb24d960ea252b96cff6b213fe3e492413cf2a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 May 2013 17:04:57 +0300 Subject: [PATCH 038/796] mvc work to replicate the error --- spring-beandefinitionstoreexception/pom.xml | 22 +----- .../config/HibernateXmlConfig.java | 18 ----- .../persistence/config/PersistenceConfig.java | 79 ------------------- .../spring/persistence/dao/FooDao.java | 14 ---- .../spring/persistence/dao/IFooDao.java | 5 -- .../spring/persistence/model/Foo.java | 31 -------- .../persistence/service/FooService.java | 19 ----- .../spring/web/config/ClientWebConfig.java | 39 +++++++++ .../src/main/resources/hibernate4Config.xml | 35 -------- .../resources/persistence-mysql.properties | 10 --- .../src/main/webapp/WEB-INF/web.xml | 55 +++++++++---- 11 files changed, 81 insertions(+), 246 deletions(-) delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java delete mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java create mode 100644 spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java delete mode 100644 spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml delete mode 100644 spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties diff --git a/spring-beandefinitionstoreexception/pom.xml b/spring-beandefinitionstoreexception/pom.xml index 02cd5f48c9f6..b5f593a1f1b9 100644 --- a/spring-beandefinitionstoreexception/pom.xml +++ b/spring-beandefinitionstoreexception/pom.xml @@ -18,34 +18,16 @@
org.springframework - spring-orm + spring-webmvc ${org.springframework.version} + org.springframework spring-context ${org.springframework.version} - - - - org.hibernate - hibernate-core - 4.2.1.Final - - - org.javassist - javassist - 3.17.1-GA - - - mysql - mysql-connector-java - 5.1.25 - runtime - - diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java deleted file mode 100644 index 51fbcd27c16d..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung.spring.persistence.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) -@ImportResource({ "classpath:hibernate4Config.xml" }) -public class HibernateXmlConfig { - - public HibernateXmlConfig() { - super(); - } - -} \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java deleted file mode 100644 index 3157c92e9924..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.baeldung.spring.persistence.config; - -import java.util.Properties; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import com.google.common.base.Preconditions; - -@Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) -public class PersistenceConfig { - - @Autowired - private Environment env; - - public PersistenceConfig() { - super(); - } - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public DataSource restDataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); - dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); - dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); - dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); - - return dataSource; - } - - @Bean - public HibernateTransactionManager transactionManager() { - final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); - - return txManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; - } -} \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java deleted file mode 100644 index a59bb30f48b1..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao implements IFooDao { - - public FooDao() { - super(); - } - - // API - -} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java deleted file mode 100644 index 91d44f5f6bfb..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -public interface IFooDao { - // -} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java deleted file mode 100644 index 8842c26d95b1..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.spring.persistence.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Foo { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - public Foo() { - super(); - } - - // API - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - // - -} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java deleted file mode 100644 index cda31a0e86ef..000000000000 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.spring.persistence.service; - -import org.baeldung.spring.persistence.dao.IFooDao; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - @Autowired - private IFooDao fooDao; - - public FooService() { - super(); - } - - // API - -} diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2758a707e6bc --- /dev/null +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml b/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml deleted file mode 100644 index f35de2a4c5db..000000000000 --- a/spring-beandefinitionstoreexception/src/main/resources/hibernate4Config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - ${hibernate.hbm2ddl.auto} - ${hibernate.dialect} - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties b/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties deleted file mode 100644 index a1ff997616ae..000000000000 --- a/spring-beandefinitionstoreexception/src/main/resources/persistence-mysql.properties +++ /dev/null @@ -1,10 +0,0 @@ -# jdbc.X -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml index e0de9aefd45a..ba2bb591ed01 100644 --- a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml +++ b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml @@ -1,17 +1,42 @@ - - Spring MVC Application - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring.persistence.config - - - org.springframework.web.context.ContextLoaderListener - + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + \ No newline at end of file From 80c15f30f394cbc940b2a9f3c3fed526593fb9f2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 May 2013 23:59:10 +0300 Subject: [PATCH 039/796] exception work --- .../spring/web/config/ClientWebConfig.java | 35 ++++++++++--------- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 ++- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2758a707e6bc..ba82fef1017e 100644 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -11,29 +11,30 @@ @EnableWebMvc @Configuration +// @ImportResource("beans.xml") public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + registry.addViewController("/sample.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..0e0ded0a71cb 100644 --- a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file From e23d9ce1ef292b0f1a19e9f6075327989a0e1b24 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 12 May 2013 11:15:16 +0300 Subject: [PATCH 040/796] cleanup work, initial work on new project --- .../.settings/.jsdtscope | 12 -- .../.settings/org.eclipse.jdt.core.prefs | 12 -- spring-beandefinitionstoreexception/README.md | 3 - spring-beandefinitionstoreexception/pom.xml | 139 ------------- .../src/main/resources/webSecurityConfig.xml | 36 ---- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 - .../.classpath | 2 +- ...e.wst.jsdt.core.javascriptValidator.launch | 7 + .../.gitignore | 0 .../.project | 3 +- .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 +++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 6 +- ....eclipse.wst.common.project.facet.core.xml | 1 - ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 spring-security-basic-auth/README.md | 3 + spring-security-basic-auth/pom.xml | 192 ++++++++++++++++++ .../spring/web/config/ClientWebConfig.java | 36 ++-- .../spring/web/config/SecSecurityConfig.java | 14 ++ .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 29 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/view/login.jsp | 26 +++ .../src/main/webapp/WEB-INF/web.xml | 10 + .../src/test/resources/.gitignore | 0 33 files changed, 410 insertions(+), 232 deletions(-) delete mode 100644 spring-beandefinitionstoreexception/.settings/.jsdtscope delete mode 100644 spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs delete mode 100644 spring-beandefinitionstoreexception/README.md delete mode 100644 spring-beandefinitionstoreexception/pom.xml delete mode 100644 spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml delete mode 100644 spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.classpath (93%) create mode 100644 spring-security-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.gitignore (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.project (94%) create mode 100644 spring-security-basic-auth/.settings/.jsdtscope create mode 100644 spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.common.component (65%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.common.project.facet.core.xml (76%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/.springBeans (100%) create mode 100644 spring-security-basic-auth/README.md create mode 100644 spring-security-basic-auth/pom.xml rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java (54%) create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/src/main/resources/logback.xml (100%) create mode 100644 spring-security-basic-auth/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml rename spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp => spring-security-basic-auth/src/main/webapp/WEB-INF/view/homepage.jsp (100%) create mode 100644 spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/src/main/webapp/WEB-INF/web.xml (80%) rename {spring-beandefinitionstoreexception => spring-security-basic-auth}/src/test/resources/.gitignore (100%) diff --git a/spring-beandefinitionstoreexception/.settings/.jsdtscope b/spring-beandefinitionstoreexception/.settings/.jsdtscope deleted file mode 100644 index b46b9207a89e..000000000000 --- a/spring-beandefinitionstoreexception/.settings/.jsdtscope +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs b/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62492222ad2e..000000000000 --- a/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-beandefinitionstoreexception/README.md b/spring-beandefinitionstoreexception/README.md deleted file mode 100644 index 12eb079c88b1..000000000000 --- a/spring-beandefinitionstoreexception/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Hibernate 4 with Spring -========= - diff --git a/spring-beandefinitionstoreexception/pom.xml b/spring-beandefinitionstoreexception/pom.xml deleted file mode 100644 index b5f593a1f1b9..000000000000 --- a/spring-beandefinitionstoreexception/pom.xml +++ /dev/null @@ -1,139 +0,0 @@ - - 4.0.0 - org.baeldung - spring-beandefinitionstoreexception - 0.1-SNAPSHOT - - spring-beandefinitionstoreexception - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - com.google.guava - guava - 14.0.1 - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-beandefinitionstoreexception - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.2.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.4 - - 1.8.0 - 1.8.9 - - - - \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml b/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 5569cc69508a..000000000000 --- a/spring-beandefinitionstoreexception/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index 0e0ded0a71cb..000000000000 --- a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/.classpath b/spring-security-basic-auth/.classpath similarity index 93% rename from spring-beandefinitionstoreexception/.classpath rename to spring-security-basic-auth/.classpath index 593395a46e93..5dea19367768 100644 --- a/spring-beandefinitionstoreexception/.classpath +++ b/spring-security-basic-auth/.classpath @@ -16,7 +16,7 @@ - + diff --git a/spring-security-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-beandefinitionstoreexception/.gitignore b/spring-security-basic-auth/.gitignore similarity index 100% rename from spring-beandefinitionstoreexception/.gitignore rename to spring-security-basic-auth/.gitignore diff --git a/spring-beandefinitionstoreexception/.project b/spring-security-basic-auth/.project similarity index 94% rename from spring-beandefinitionstoreexception/.project rename to spring-security-basic-auth/.project index bb38a257540a..49eecbd6a380 100644 --- a/spring-beandefinitionstoreexception/.project +++ b/spring-security-basic-auth/.project @@ -1,6 +1,6 @@ - spring-beandefinitionstoreexception + spring-security-login @@ -54,7 +54,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-security-basic-auth/.settings/.jsdtscope b/spring-security-basic-auth/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-basic-auth/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs b/spring-security-basic-auth/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.jdt.ui.prefs rename to spring-security-basic-auth/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs b/spring-security-basic-auth/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.core.prefs rename to spring-security-basic-auth/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-basic-auth/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.m2e.wtp.prefs rename to spring-security-basic-auth/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component similarity index 65% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component rename to spring-security-basic-auth/.settings/org.eclipse.wst.common.component index bb5464963efb..c42e29f80edc 100644 --- a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.component +++ b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-basic-auth/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 76% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-security-basic-auth/.settings/org.eclipse.wst.common.project.facet.core.xml index a67649dfa5ae..b46bc511b943 100644 --- a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-security-basic-auth/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,5 @@ - diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-security-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-security-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs b/spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.validation.prefs rename to spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-basic-auth/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-beandefinitionstoreexception/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-security-basic-auth/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-beandefinitionstoreexception/.springBeans b/spring-security-basic-auth/.springBeans similarity index 100% rename from spring-beandefinitionstoreexception/.springBeans rename to spring-security-basic-auth/.springBeans diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md new file mode 100644 index 000000000000..7cc97242ec04 --- /dev/null +++ b/spring-security-basic-auth/README.md @@ -0,0 +1,3 @@ +Spring Security Login +========= + diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml new file mode 100644 index 000000000000..d8cecabcdb63 --- /dev/null +++ b/spring-security-basic-auth/pom.xml @@ -0,0 +1,192 @@ + + 4.0.0 + org.baeldung + spring-security-login + 0.1-SNAPSHOT + + spring-security-login + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-login + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + 3.1.4.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java similarity index 54% rename from spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index ba82fef1017e..4aadc3a48c92 100644 --- a/spring-beandefinitionstoreexception/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -11,30 +11,30 @@ @EnableWebMvc @Configuration -// @ImportResource("beans.xml") public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java new file mode 100644 index 000000000000..65a571c71589 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-beandefinitionstoreexception/src/main/resources/logback.xml b/spring-security-basic-auth/src/main/resources/logback.xml similarity index 100% rename from spring-beandefinitionstoreexception/src/main/resources/logback.xml rename to spring-security-basic-auth/src/main/resources/logback.xml diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..6394c926995b --- /dev/null +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp b/spring-security-basic-auth/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-security-basic-auth/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..013ceccb4e4d --- /dev/null +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,26 @@ + + + + +

Login

+ + + +
+ + + + + + + + + + + +
User:
Password:
+ +
+ + + \ No newline at end of file diff --git a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml similarity index 80% rename from spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml rename to spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index ba2bb591ed01..23e0e8c1d7b0 100644 --- a/spring-beandefinitionstoreexception/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -35,6 +35,16 @@ / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + index.html diff --git a/spring-beandefinitionstoreexception/src/test/resources/.gitignore b/spring-security-basic-auth/src/test/resources/.gitignore similarity index 100% rename from spring-beandefinitionstoreexception/src/test/resources/.gitignore rename to spring-security-basic-auth/src/test/resources/.gitignore From 6531ae264d0415579b026d384a0c406b563aeef2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 12 May 2013 11:17:06 +0300 Subject: [PATCH 041/796] project cleanup work --- spring-security-basic-auth/.project | 2 +- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-security-basic-auth/pom.xml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-security-basic-auth/.project b/spring-security-basic-auth/.project index 49eecbd6a380..f2aa3ca83eb0 100644 --- a/spring-security-basic-auth/.project +++ b/spring-security-basic-auth/.project @@ -1,6 +1,6 @@ - spring-security-login + spring-security-basic-auth diff --git a/spring-security-basic-auth/.settings/org.eclipse.wst.common.component b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component index c42e29f80edc..83a7bf94e7a2 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.wst.common.component +++ b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index d8cecabcdb63..fa41a090e6ed 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-login + spring-security-basic-auth 0.1-SNAPSHOT - spring-security-login + spring-security-basic-auth war @@ -120,7 +120,7 @@ - spring-security-login + spring-security-basic-auth src/main/resources From 04da22438dc3608d0832fc655cb2b771f8631a9c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 12 May 2013 11:20:31 +0300 Subject: [PATCH 042/796] basic auth work --- .../src/main/resources/webSecurityConfig.xml | 36 ++++++++----------- .../src/main/webapp/WEB-INF/view/login.jsp | 26 -------------- 2 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index 6394c926995b..d2a28094461e 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -1,29 +1,23 @@ - - - - + + + - + + + - - - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 013ceccb4e4d..000000000000 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,26 +0,0 @@ - - - - -

Login

- -
- - - - - - - - - - - - - -
User:
Password:
- -
- - - \ No newline at end of file From d49f3686e4926335ba532b1fe0ac95035f333476 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 14 May 2013 18:25:34 +0300 Subject: [PATCH 043/796] doc work --- spring-mvc-java/README.md | 2 +- spring-mvc-xml/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index afb2185d6002..1abc096086ed 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -1,3 +1,3 @@ -Spring MVC with Java Configuration +[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) ========= diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index afb2185d6002..1abc096086ed 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,3 +1,3 @@ -Spring MVC with Java Configuration +[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) ========= From 158195c7207e8d7cb7072f375a309572ba1cda1d Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 15 May 2013 18:03:51 +0300 Subject: [PATCH 044/796] logging fixes and new project --- .../src/main/resources/logback.xml | 40 ----- .../src/main/resources/logback.xml | 40 ----- .../src/main/resources/logback.xml | 40 ----- .../src/main/resources/webSecurityConfig.xml | 36 ----- spring-mvc-xml/src/main/resources/logback.xml | 40 ----- spring-mvc/.classpath | 37 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-mvc/.gitignore | 13 ++ spring-mvc/.project | 60 ++++++++ spring-mvc/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 +++++++++++ spring-mvc/.settings/org.eclipse.jdt.ui.prefs | 55 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-mvc/.springBeans | 14 ++ spring-mvc/README.md | 3 + spring-mvc/pom.xml | 142 ++++++++++++++++++ .../spring/web/config/ClientWebConfig.java | 39 +++++ .../spring/web/controller/FooController.java | 21 +++ spring-mvc/src/main/resources/logback.xml | 20 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + spring-mvc/src/main/webapp/WEB-INF/web.xml | 42 ++++++ spring-mvc/src/test/resources/.gitignore | 13 ++ .../src/main/resources/logback.xml | 40 ----- .../src/main/resources/logback.xml | 40 ----- 32 files changed, 622 insertions(+), 276 deletions(-) delete mode 100644 spring-mvc-java/src/main/resources/webSecurityConfig.xml create mode 100644 spring-mvc/.classpath create mode 100644 spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-mvc/.gitignore create mode 100644 spring-mvc/.project create mode 100644 spring-mvc/.settings/.jsdtscope create mode 100644 spring-mvc/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-mvc/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-mvc/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-mvc/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-mvc/.settings/org.eclipse.wst.common.component create mode 100644 spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-mvc/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-mvc/.springBeans create mode 100644 spring-mvc/README.md create mode 100644 spring-mvc/pom.xml create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java create mode 100644 spring-mvc/src/main/resources/logback.xml create mode 100644 spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-mvc/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-mvc/src/test/resources/.gitignore diff --git a/spring-hibernate3/src/main/resources/logback.xml b/spring-hibernate3/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-hibernate3/src/main/resources/logback.xml +++ b/spring-hibernate3/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file diff --git a/spring-hibernate4/src/main/resources/logback.xml b/spring-hibernate4/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-hibernate4/src/main/resources/logback.xml +++ b/spring-hibernate4/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file diff --git a/spring-mvc-java/src/main/resources/logback.xml b/spring-mvc-java/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-mvc-java/src/main/resources/logback.xml +++ b/spring-mvc-java/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file diff --git a/spring-mvc-java/src/main/resources/webSecurityConfig.xml b/spring-mvc-java/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 5569cc69508a..000000000000 --- a/spring-mvc-java/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/logback.xml b/spring-mvc-xml/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-mvc-xml/src/main/resources/logback.xml +++ b/spring-mvc-xml/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file diff --git a/spring-mvc/.classpath b/spring-mvc/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-mvc/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-mvc/.gitignore b/spring-mvc/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc/.project b/spring-mvc/.project new file mode 100644 index 000000000000..90b8ccd78f8f --- /dev/null +++ b/spring-mvc/.project @@ -0,0 +1,60 @@ + + + spring-mvc + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc/.settings/.jsdtscope b/spring-mvc/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-mvc/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-mvc/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc/.settings/org.eclipse.jdt.ui.prefs b/spring-mvc/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-mvc/.settings/org.eclipse.m2e.core.prefs b/spring-mvc/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs b/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9784ac36ee68 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-mvc/.settings/org.eclipse.wst.validation.prefs b/spring-mvc/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-mvc/.springBeans b/spring-mvc/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-mvc/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-mvc/README.md b/spring-mvc/README.md new file mode 100644 index 000000000000..1abc096086ed --- /dev/null +++ b/spring-mvc/README.md @@ -0,0 +1,3 @@ +[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) +========= + diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml new file mode 100644 index 000000000000..bb983b43e6f0 --- /dev/null +++ b/spring-mvc/pom.xml @@ -0,0 +1,142 @@ + + 4.0.0 + org.baeldung + spring-mvc-java + 0.1-SNAPSHOT + + spring-mvc-java + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2758a707e6bc --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java new file mode 100644 index 000000000000..ad03a4ac2f78 --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -0,0 +1,21 @@ +package org.baeldung.spring.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class FooController { + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/foos") + public String getFoos() { + System.out.println("simplePattern method was called"); + return "someResult"; + + } +} diff --git a/spring-mvc/src/main/resources/logback.xml b/spring-mvc/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-mvc/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-mvc/src/test/resources/.gitignore b/spring-mvc/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/resources/logback.xml b/spring-security-basic-auth/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-security-basic-auth/src/main/resources/logback.xml +++ b/spring-security-basic-auth/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file diff --git a/spring-security-login/src/main/resources/logback.xml b/spring-security-login/src/main/resources/logback.xml index 976d267d7d16..1146dade632e 100644 --- a/spring-security-login/src/main/resources/logback.xml +++ b/spring-security-login/src/main/resources/logback.xml @@ -1,7 +1,5 @@ - - web - %date [%thread] %-5level %logger{36} - %message%n @@ -9,42 +7,6 @@ - - /var/log/launchpad/launchpad_web.log - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - ERROR - - email-smtp.us-east-1.amazonaws.com - AKIAJI6XLSOAQX3IW6HQ - AuSWMdcNObKqGGT550SR/6vDrgh50vxgFrqZHwR2tTED - true - hanriseldon@gmail.com - info@applieddatalabs.com - TESTING: %logger{20} - %m - - web - |${launchpad.origin}| %date [%thread] %-5level %logger{36} - %message%n - - - 1000 - - - - - - - - - - - @@ -53,8 +15,6 @@ - - \ No newline at end of file From 55a545749ae62a44eb487297acc8eb8ffb2f1450 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 15 May 2013 18:09:36 +0300 Subject: [PATCH 045/796] minor fixes --- spring-mvc/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index bb983b43e6f0..3700a428ddb4 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-mvc-java + spring-mvc 0.1-SNAPSHOT - spring-mvc-java + spring-mvc war From b30b2ffc1e9fe81af11c8f783493fd28ebb9bbcd Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 15 May 2013 18:24:42 +0300 Subject: [PATCH 046/796] minor mapping work --- .../spring/web/config/ClientWebConfig.java | 39 ------------------- .../baeldung/spring/web/config/MvcConfig.java | 16 ++++++++ .../spring/web/controller/FooController.java | 2 +- 3 files changed, 17 insertions(+), 40 deletions(-) delete mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java deleted file mode 100644 index 2758a707e6bc..000000000000 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.baeldung.spring.web.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@EnableWebMvc -@Configuration -public class ClientWebConfig extends WebMvcConfigurerAdapter { - - public ClientWebConfig() { - super(); - } - - // API - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/sample.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } -} \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java new file mode 100644 index 000000000000..093a785b48be --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +@EnableWebMvc +@Configuration +@ComponentScan({ "org.baeldung.spring.web.controller" }) +public class MvcConfig { + + public MvcConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java index ad03a4ac2f78..a2628cbbbf28 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -16,6 +16,6 @@ public FooController() { public String getFoos() { System.out.println("simplePattern method was called"); return "someResult"; - } + } From 4a1370d1dd7984515887c396fda27a854f681205 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 15 May 2013 18:52:45 +0300 Subject: [PATCH 047/796] minor fixes --- .../spring/web/controller/FooController.java | 18 ++++++++++++++++-- spring-mvc/src/main/webapp/WEB-INF/web.xml | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java index a2628cbbbf28..3698cc24d597 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -2,6 +2,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; @Controller public class FooController { @@ -13,9 +15,21 @@ public FooController() { // API @RequestMapping(value = "/foos") + @ResponseBody public String getFoos() { - System.out.println("simplePattern method was called"); - return "someResult"; + return "Get some Foos"; + } + + @RequestMapping(value = "/foos", method = RequestMethod.POST) + @ResponseBody + public String getFoosPost() { + return "Post some Foos"; + } + + @RequestMapping(value = "/foos", method = RequestMethod.POST, headers = "key=val") + @ResponseBody + public String getFoosWithHeader() { + return "Get some Foos with Header"; } } diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index ba2bb591ed01..5c163a20ad57 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -36,7 +36,7 @@ - index.html + \ No newline at end of file From b7d6a5377a2f3a823e406fa4bb2aef0fb46120fa Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 15 May 2013 22:39:23 +0300 Subject: [PATCH 048/796] mapping work --- .../baeldung/spring/web/config/MvcConfig.java | 6 +- .../spring/web/controller/BarController.java | 37 ++++++++ .../spring/web/controller/FooController.java | 93 ++++++++++++++----- 3 files changed, 110 insertions(+), 26 deletions(-) create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java index 093a785b48be..1325da321df3 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java @@ -9,8 +9,8 @@ @ComponentScan({ "org.baeldung.spring.web.controller" }) public class MvcConfig { - public MvcConfig() { - super(); - } + public MvcConfig() { + super(); + } } \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java new file mode 100644 index 000000000000..def8ffd11e68 --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java @@ -0,0 +1,37 @@ +package org.baeldung.spring.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class BarController { + + public BarController() { + super(); + } + + // API + + // with @RequestParam + + @RequestMapping(value = "/bars") + @ResponseBody + public String getBarBySimplePathWithRequestParam(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + + @RequestMapping(value = "/bars", params = "id") + @ResponseBody + public String getBarBySimplePathWithExplicitRequestParam(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + + @RequestMapping(value = "/bars", params = { "id", "second" }) + @ResponseBody + public String getBarBySimplePathWithExplicitRequestParams(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + +} diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java index 3698cc24d597..2f86327fc8ce 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -1,6 +1,7 @@ package org.baeldung.spring.web.controller; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -8,28 +9,74 @@ @Controller public class FooController { - public FooController() { - super(); - } - - // API - - @RequestMapping(value = "/foos") - @ResponseBody - public String getFoos() { - return "Get some Foos"; - } - - @RequestMapping(value = "/foos", method = RequestMethod.POST) - @ResponseBody - public String getFoosPost() { - return "Post some Foos"; - } - - @RequestMapping(value = "/foos", method = RequestMethod.POST, headers = "key=val") - @ResponseBody - public String getFoosWithHeader() { - return "Get some Foos with Header"; - } + public FooController() { + super(); + } + + // API + + // by paths + + @RequestMapping(value = "/foos") + @ResponseBody + public String getFoosBySimplePath() { + return "Simple Get some Foos"; + } + + // @RequestMapping(value = "/foos") + // @ResponseBody + // public String getFoosByAdvancedPath() { + // return "Advanced Get some Foos"; + // } + + // with @PathVariable + + @RequestMapping(value = "/foos/{id}") + @ResponseBody + public String getFoosBySimplePathWithPathVariable(@PathVariable("id") final long id) { + return "Get a specific Foo with id=" + id; + } + + // other HTTP verbs + + @RequestMapping(value = "/foos", method = RequestMethod.POST) + @ResponseBody + public String postFoos() { + return "Post some Foos"; + } + + // with headers + + @RequestMapping(value = "/foos", headers = "key=val") + @ResponseBody + public String getFoosWithHeader() { + return "Get some Foos with Header"; + } + + @RequestMapping(value = "/foos", headers = { "key1=val1", "key2=val2" }) + @ResponseBody + public String getFoosWithHeaders() { + return "Get some Foos with Header"; + } + + // advanced - multiple mappings + + @RequestMapping(value = { "/advanced/bars", "/advanced/foos" }) + @ResponseBody + public String getFoosOrBarsByPath() { + return "Advanced - Get some Foos or Bars"; + } + + @RequestMapping(value = "*") + @ResponseBody + public String getFallback() { + return "Fallback for GET Requests"; + } + + @RequestMapping(value = "*", method = { RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public String allFallback() { + return "Fallback for All Requests"; + } } From 0f71d7d2b8ea7af8e30ca664cd70ee5300f74d5e Mon Sep 17 00:00:00 2001 From: Eugen Date: Thu, 16 May 2013 17:33:00 +0300 Subject: [PATCH 049/796] minor mapping work --- .../spring/web/controller/BarController.java | 9 +++++++ .../spring/web/controller/FooController.java | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java index def8ffd11e68..4c2202791ca1 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java @@ -1,6 +1,7 @@ package org.baeldung.spring.web.controller; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -34,4 +35,12 @@ public String getBarBySimplePathWithExplicitRequestParams(@RequestParam("id") fi return "Get a specific Bar with id=" + id; } + // with @PathVariable + + @RequestMapping(value = "/bars/{numericId:[\\d]+}") + @ResponseBody + public String getBarsBySimplePathWithPathVariable(@PathVariable final long numericId) { + return "Get a specific Bar with id=" + numericId; + } + } diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java index 2f86327fc8ce..32019a4571b7 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -23,20 +23,20 @@ public String getFoosBySimplePath() { return "Simple Get some Foos"; } - // @RequestMapping(value = "/foos") - // @ResponseBody - // public String getFoosByAdvancedPath() { - // return "Advanced Get some Foos"; - // } - // with @PathVariable @RequestMapping(value = "/foos/{id}") @ResponseBody - public String getFoosBySimplePathWithPathVariable(@PathVariable("id") final long id) { + public String getFoosBySimplePathWithPathVariable(@PathVariable final long id) { return "Get a specific Foo with id=" + id; } + @RequestMapping(value = "/foos/{fooid}/bar/{barid}") + @ResponseBody + public String getFoosBySimplePathWithPathVariables(@PathVariable final long fooid, @PathVariable final long barid) { + return "Get a specific Bar with id=" + barid + " from a Foo with id=" + fooid; + } + // other HTTP verbs @RequestMapping(value = "/foos", method = RequestMethod.POST) @@ -59,6 +59,12 @@ public String getFoosWithHeaders() { return "Get some Foos with Header"; } + @RequestMapping(value = "/foos", produces = { "application/json", "application/xml" }) + @ResponseBody + public String getFoosAsJsonFromREST() { + return "Get some Foos with Header Exact"; + } + // advanced - multiple mappings @RequestMapping(value = { "/advanced/bars", "/advanced/foos" }) @@ -79,4 +85,10 @@ public String allFallback() { return "Fallback for All Requests"; } + @RequestMapping(value = "/foos/multiple", method = { RequestMethod.PUT, RequestMethod.POST }) + @ResponseBody + public String putAndPostFoos() { + return "Advanced - PUT and POST within single method"; + } + } From bccc8fc690c49a8791b2e0b5079c618edb31ad4d Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 17 May 2013 12:12:34 +0300 Subject: [PATCH 050/796] minor persistence work --- spring-hibernate4/.classpath | 7 +- .../org.eclipse.wst.common.component | 1 + spring-hibernate4/pom.xml | 317 +++++++++--------- .../persistence/service/FooService.java | 2 + .../FooServicePersistenceIntegrationTest.java | 13 + 5 files changed, 184 insertions(+), 156 deletions(-) create mode 100644 spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index 593395a46e93..10115292f412 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -16,6 +16,12 @@ + + + + + + @@ -24,7 +30,6 @@ - diff --git a/spring-hibernate4/.settings/org.eclipse.wst.common.component b/spring-hibernate4/.settings/org.eclipse.wst.common.component index 619260207900..59f6da9f9587 100644 --- a/spring-hibernate4/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate4/.settings/org.eclipse.wst.common.component @@ -4,6 +4,7 @@ + diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index c7171e0acdc5..61129e1a4739 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -1,157 +1,164 @@ - - 4.0.0 - org.baeldung - spring-hibernate4 - 0.1-SNAPSHOT - - spring-hibernate4 - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-core - 4.2.1.Final - - - org.javassist - javassist - 3.17.1-GA - - - mysql - mysql-connector-java - 5.1.25 - runtime - - - - - - com.google.guava - guava - 14.0.1 - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-hibernate4 - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.2.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.4 - - 1.8.0 - 1.8.9 - - + + 4.0.0 + org.baeldung + spring-hibernate4 + 0.1-SNAPSHOT + + spring-hibernate4 + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate4 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java index cda31a0e86ef..896e2795ffe8 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -3,8 +3,10 @@ import org.baeldung.spring.persistence.dao.IFooDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional public class FooService { @Autowired diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..5d23f5354cb2 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,13 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + // +} From 852c5b96de233efbad9341537c9b8ce9ff6c71d9 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 17 May 2013 12:22:20 +0300 Subject: [PATCH 051/796] service work --- .../.settings/org.eclipse.jdt.core.prefs | 83 +++++++++++++++++++ .../spring/persistence/dao/FooDao.java | 52 ++++++++++++ .../spring/persistence/dao/IFooDao.java | 18 +++- .../persistence/service/FooService.java | 7 +- .../FooServicePersistenceIntegrationTest.java | 20 ++++- 5 files changed, 177 insertions(+), 3 deletions(-) diff --git a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs index 62492222ad2e..a931b331929d 100644 --- a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,9 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve @@ -6,7 +11,85 @@ org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index a59bb30f48b1..b7878abd81d7 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -1,14 +1,66 @@ package org.baeldung.spring.persistence.dao; +import java.util.List; + +import org.baeldung.spring.persistence.model.Foo; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; +import com.google.common.base.Preconditions; + @Repository public class FooDao implements IFooDao { + @Autowired + private SessionFactory sessionFactory; + public FooDao() { super(); } // API + @Override + public Foo findOne(final Long id) { + Preconditions.checkArgument(id != null); + return (Foo) getCurrentSession().get(Foo.class, id); + } + + @Override + @SuppressWarnings("unchecked") + public List findAll() { + return getCurrentSession().createQuery("from " + Foo.class.getName()).list(); + } + + @Override + public void create(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().persist(entity); + } + + @Override + public void update(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().merge(entity); + } + + @Override + public void delete(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public void deleteById(final Long entityId) { + final Foo entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index 91d44f5f6bfb..5536c9e7d740 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -1,5 +1,21 @@ package org.baeldung.spring.persistence.dao; +import java.util.List; + +import org.baeldung.spring.persistence.model.Foo; + public interface IFooDao { - // + + Foo findOne(Long id); + + List findAll(); + + void create(Foo entity); + + void update(Foo entity); + + void delete(Foo entity); + + void deleteById(Long entityId); + } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java index 896e2795ffe8..1d3b5c4a0201 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -1,6 +1,7 @@ package org.baeldung.spring.persistence.service; import org.baeldung.spring.persistence.dao.IFooDao; +import org.baeldung.spring.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -10,7 +11,7 @@ public class FooService { @Autowired - private IFooDao fooDao; + private IFooDao dao; public FooService() { super(); @@ -18,4 +19,8 @@ public FooService() { // API + public void create(final Foo entity) { + dao.create(entity); + } + } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 5d23f5354cb2..eaa72fc6efa2 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,7 +1,10 @@ package org.baeldung.spring.persistence.service; import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.baeldung.spring.persistence.model.Foo; +import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -9,5 +12,20 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) public class FooServicePersistenceIntegrationTest { - // + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityisCreated_thenNoExceptions() { + service.create(new Foo()); + } + } From c5ba7852461067692ee6b68f7a4bfd7844e93e53 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 17 May 2013 12:37:04 +0300 Subject: [PATCH 052/796] persistence work --- spring-hibernate4/pom.xml | 8 +++ .../spring/persistence/model/Foo.java | 50 +++++++++++++++++++ .../FooServicePersistenceIntegrationTest.java | 4 +- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 61129e1a4739..e966579fad2f 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -56,6 +56,14 @@ + + + org.apache.commons + commons-lang3 + 3.1 + test + + org.springframework spring-test diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 8842c26d95b1..8b03df39e7a3 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -1,5 +1,6 @@ package org.baeldung.spring.persistence.model; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -12,10 +13,19 @@ public class Foo { @GeneratedValue(strategy = GenerationType.AUTO) private long id; + @Column(nullable = false) + private String name; + public Foo() { super(); } + public Foo(final String name) { + super(); + + this.name = name; + } + // API public long getId() { @@ -26,6 +36,46 @@ public void setId(final long id) { this.id = id; } + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + // + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index eaa72fc6efa2..cabb94c2f0cb 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,5 +1,7 @@ package org.baeldung.spring.persistence.service; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; import org.junit.Test; @@ -25,7 +27,7 @@ public final void whenContextIsBootstrapped_thenNoExceptions() { @Test public final void whenEntityisCreated_thenNoExceptions() { - service.create(new Foo()); + service.create(new Foo(randomAlphabetic(6))); } } From f82c1030464e3c1a8f54bfc6d06db7b9e72e7027 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 17 May 2013 18:54:16 +0300 Subject: [PATCH 053/796] persistence work --- .../service/FooServicePersistenceIntegrationTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index cabb94c2f0cb..fae40cdad075 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -26,8 +26,14 @@ public final void whenContextIsBootstrapped_thenNoExceptions() { } @Test - public final void whenEntityisCreated_thenNoExceptions() { + public final void whenEntityIsCreated_thenNoExceptions() { service.create(new Foo(randomAlphabetic(6))); } + // @Test(expected = DataIntegrityViolationException.class) + @Test + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + } From 993fc6bade9e6c19d5682d8767ad714a9a8b7a88 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 11:45:55 +0300 Subject: [PATCH 054/796] eclipse work --- spring-hibernate3/.project | 2 +- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-hibernate3/pom.xml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-hibernate3/.project b/spring-hibernate3/.project index 8aa9e7ad5822..fba218889745 100644 --- a/spring-hibernate3/.project +++ b/spring-hibernate3/.project @@ -1,6 +1,6 @@ - spring-hibernate3-dao + spring-hibernate3 diff --git a/spring-hibernate3/.settings/org.eclipse.wst.common.component b/spring-hibernate3/.settings/org.eclipse.wst.common.component index 557fa1bf21e8..14b1679703ce 100644 --- a/spring-hibernate3/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate3/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index d2adea1f25ce..2fc47dbcadf1 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-hibernate3-dao + spring-hibernate3 0.1-SNAPSHOT - spring-hibernate3-dao + spring-hibernate3 war @@ -86,7 +86,7 @@ - spring-hibernate3-dao + spring-hibernate3 src/main/resources From 09eaa5b8e146e676d84228e48076ea554c8ef431 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 11:49:19 +0300 Subject: [PATCH 055/796] minor cleanup --- spring-hibernate4/.classpath | 3 ++- spring-hibernate4/.project | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index 10115292f412..ca257cf1f962 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -22,7 +22,7 @@ - + @@ -30,6 +30,7 @@ + diff --git a/spring-hibernate4/.project b/spring-hibernate4/.project index 233d73c017ac..40591b21b2fc 100644 --- a/spring-hibernate4/.project +++ b/spring-hibernate4/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder From 2b7304c32da6d44ca99e8631a2481e0a3d9fa9df Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 13:07:16 +0300 Subject: [PATCH 056/796] persistence work --- spring-hibernate4/pom.xml | 347 +++++++++--------- .../spring/persistence/model/Foo.java | 2 + .../FooServicePersistenceIntegrationTest.java | 22 +- 3 files changed, 199 insertions(+), 172 deletions(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index e966579fad2f..254d9e111826 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -1,172 +1,179 @@ - - 4.0.0 - org.baeldung - spring-hibernate4 - 0.1-SNAPSHOT - - spring-hibernate4 - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-core - 4.2.1.Final - - - org.javassist - javassist - 3.17.1-GA - - - mysql - mysql-connector-java - 5.1.25 - runtime - - - - - - com.google.guava - guava - 14.0.1 - - - - - - org.apache.commons - commons-lang3 - 3.1 - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-hibernate4 - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.2.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.4 - - 1.8.0 - 1.8.9 - - + + 4.0.0 + org.baeldung + spring-hibernate4 + 0.1-SNAPSHOT + + spring-hibernate4 + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + org.hibernate + hibernate-validator + 5.0.1.Final + + + + + + com.google.guava + guava + 14.0.1 + + + + + + org.apache.commons + commons-lang3 + 3.1 + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate4 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 8b03df39e7a3..2bf8f7f00869 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -5,6 +5,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.validation.constraints.NotNull; @Entity public class Foo { @@ -14,6 +15,7 @@ public class Foo { private long id; @Column(nullable = false) + @NotNull private String name; public Foo() { diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index fae40cdad075..3020250f6d03 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -7,6 +7,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -30,10 +32,26 @@ public final void whenEntityIsCreated_thenNoExceptions() { service.create(new Foo(randomAlphabetic(6))); } - // @Test(expected = DataIntegrityViolationException.class) - @Test + @Test(expected = DataIntegrityViolationException.class) public final void whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + } From 676bc5d1601f3e657fa417b66c01f4f67da9ada1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 13:08:43 +0300 Subject: [PATCH 057/796] new spring jpa tutorial --- spring-jpa/.classpath | 37 ++++ spring-jpa/.gitignore | 13 ++ spring-jpa/.project | 49 +++++ spring-jpa/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++++ spring-jpa/.settings/org.eclipse.jdt.ui.prefs | 55 ++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 11 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-jpa/.springBeans | 14 ++ spring-jpa/README.md | 3 + spring-jpa/pom.xml | 179 ++++++++++++++++++ .../config/HibernateXmlConfig.java | 18 ++ .../persistence/config/PersistenceConfig.java | 79 ++++++++ .../spring/persistence/dao/FooDao.java | 66 +++++++ .../spring/persistence/dao/IFooDao.java | 21 ++ .../spring/persistence/model/Foo.java | 83 ++++++++ .../persistence/service/FooService.java | 26 +++ .../src/main/resources/hibernate4Config.xml | 35 ++++ spring-jpa/src/main/resources/logback.xml | 20 ++ .../resources/persistence-mysql.properties | 10 + .../src/main/resources/webSecurityConfig.xml | 36 ++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + spring-jpa/src/main/webapp/WEB-INF/web.xml | 17 ++ .../FooServicePersistenceIntegrationTest.java | 57 ++++++ spring-jpa/src/test/resources/.gitignore | 13 ++ 32 files changed, 992 insertions(+) create mode 100644 spring-jpa/.classpath create mode 100644 spring-jpa/.gitignore create mode 100644 spring-jpa/.project create mode 100644 spring-jpa/.settings/.jsdtscope create mode 100644 spring-jpa/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-jpa/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-jpa/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-jpa/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-jpa/.settings/org.eclipse.wst.common.component create mode 100644 spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-jpa/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-jpa/.springBeans create mode 100644 spring-jpa/README.md create mode 100644 spring-jpa/pom.xml create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java create mode 100644 spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java create mode 100644 spring-jpa/src/main/resources/hibernate4Config.xml create mode 100644 spring-jpa/src/main/resources/logback.xml create mode 100644 spring-jpa/src/main/resources/persistence-mysql.properties create mode 100644 spring-jpa/src/main/resources/webSecurityConfig.xml create mode 100644 spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-jpa/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java create mode 100644 spring-jpa/src/test/resources/.gitignore diff --git a/spring-jpa/.classpath b/spring-jpa/.classpath new file mode 100644 index 000000000000..ca257cf1f962 --- /dev/null +++ b/spring-jpa/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-jpa/.gitignore b/spring-jpa/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-jpa/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-jpa/.project b/spring-jpa/.project new file mode 100644 index 000000000000..3fe887cb4569 --- /dev/null +++ b/spring-jpa/.project @@ -0,0 +1,49 @@ + + + spring-jpa + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-jpa/.settings/.jsdtscope b/spring-jpa/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-jpa/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-jpa/.settings/org.eclipse.jdt.core.prefs b/spring-jpa/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..a931b331929d --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-jpa/.settings/org.eclipse.jdt.ui.prefs b/spring-jpa/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-jpa/.settings/org.eclipse.m2e.core.prefs b/spring-jpa/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs b/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-jpa/.settings/org.eclipse.wst.common.component b/spring-jpa/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..68573b98202a --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-jpa/.settings/org.eclipse.wst.validation.prefs b/spring-jpa/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-jpa/.springBeans b/spring-jpa/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-jpa/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-jpa/README.md b/spring-jpa/README.md new file mode 100644 index 000000000000..12eb079c88b1 --- /dev/null +++ b/spring-jpa/README.md @@ -0,0 +1,3 @@ +Hibernate 4 with Spring +========= + diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml new file mode 100644 index 000000000000..1485739f68ec --- /dev/null +++ b/spring-jpa/pom.xml @@ -0,0 +1,179 @@ + + 4.0.0 + org.baeldung + spring-jpa + 0.1-SNAPSHOT + + spring-jpa + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + org.hibernate + hibernate-validator + 5.0.1.Final + + + + + + com.google.guava + guava + 14.0.1 + + + + + + org.apache.commons + commons-lang3 + 3.1 + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-jpa + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java new file mode 100644 index 000000000000..51fbcd27c16d --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.spring.persistence.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ImportResource({ "classpath:hibernate4Config.xml" }) +public class HibernateXmlConfig { + + public HibernateXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java new file mode 100644 index 000000000000..3157c92e9924 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.spring.persistence.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java new file mode 100644 index 000000000000..b7878abd81d7 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -0,0 +1,66 @@ +package org.baeldung.spring.persistence.dao; + +import java.util.List; + +import org.baeldung.spring.persistence.model.Foo; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import com.google.common.base.Preconditions; + +@Repository +public class FooDao implements IFooDao { + + @Autowired + private SessionFactory sessionFactory; + + public FooDao() { + super(); + } + + // API + + @Override + public Foo findOne(final Long id) { + Preconditions.checkArgument(id != null); + return (Foo) getCurrentSession().get(Foo.class, id); + } + + @Override + @SuppressWarnings("unchecked") + public List findAll() { + return getCurrentSession().createQuery("from " + Foo.class.getName()).list(); + } + + @Override + public void create(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().persist(entity); + } + + @Override + public void update(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().merge(entity); + } + + @Override + public void delete(final Foo entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public void deleteById(final Long entityId) { + final Foo entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..5536c9e7d740 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -0,0 +1,21 @@ +package org.baeldung.spring.persistence.dao; + +import java.util.List; + +import org.baeldung.spring.persistence.model.Foo; + +public interface IFooDao { + + Foo findOne(Long id); + + List findAll(); + + void create(Foo entity); + + void update(Foo entity); + + void delete(Foo entity); + + void deleteById(Long entityId); + +} diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java new file mode 100644 index 000000000000..2bf8f7f00869 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package org.baeldung.spring.persistence.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + +@Entity +public class Foo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + @NotNull + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java new file mode 100644 index 000000000000..1d3b5c4a0201 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -0,0 +1,26 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.IFooDao; +import org.baeldung.spring.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class FooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + public void create(final Foo entity) { + dao.create(entity); + } + +} diff --git a/spring-jpa/src/main/resources/hibernate4Config.xml b/spring-jpa/src/main/resources/hibernate4Config.xml new file mode 100644 index 000000000000..f35de2a4c5db --- /dev/null +++ b/spring-jpa/src/main/resources/hibernate4Config.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-jpa/src/main/resources/logback.xml b/spring-jpa/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-jpa/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-jpa/src/main/resources/persistence-mysql.properties b/spring-jpa/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..a1ff997616ae --- /dev/null +++ b/spring-jpa/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-jpa/src/main/resources/webSecurityConfig.xml b/spring-jpa/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-jpa/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp b/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-jpa/src/main/webapp/WEB-INF/web.xml b/spring-jpa/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..e0de9aefd45a --- /dev/null +++ b/spring-jpa/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + Spring MVC Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.persistence.config + + + org.springframework.web.context.ContextLoaderListener + + \ No newline at end of file diff --git a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..3020250f6d03 --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,57 @@ +package org.baeldung.spring.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.baeldung.spring.persistence.model.Foo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + +} diff --git a/spring-jpa/src/test/resources/.gitignore b/spring-jpa/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-jpa/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From dbd5616f5a7f2dca7d835a9090d713c720c91ab0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 13:18:34 +0300 Subject: [PATCH 058/796] jpa work --- spring-jpa/pom.xml | 7 +++- .../persistence/config/PersistenceConfig.java | 37 ++++++++++++------- .../spring/persistence/dao/FooDao.java | 30 ++++++--------- .../spring/persistence/dao/IFooDao.java | 4 +- .../spring/persistence/model/Foo.java | 2 - .../FooServicePersistenceIntegrationTest.java | 2 + 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 1485739f68ec..d7c3bc3dac23 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -34,6 +34,11 @@ hibernate-core 4.2.1.Final + + org.hibernate + hibernate-entitymanager + 4.2.1.Final + org.javassist javassist @@ -47,7 +52,7 @@ - + org.hibernate hibernate-validator diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 3157c92e9924..3532afe22934 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -12,8 +12,11 @@ import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; @@ -32,13 +35,20 @@ public PersistenceConfig() { } @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); + public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); + factoryBean.setDataSource(restDataSource()); + factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - return sessionFactory; + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter() { + { + // JPA properties ... + } + }; + factoryBean.setJpaVendorAdapter(vendorAdapter); + factoryBean.setJpaProperties(additionalProperties()); + + return factoryBean; } @Bean @@ -53,11 +63,11 @@ public DataSource restDataSource() { } @Bean - public HibernateTransactionManager transactionManager() { - final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); + public PlatformTransactionManager transactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactoryBean().getObject()); - return txManager; + return transactionManager; } @Bean @@ -65,7 +75,7 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { return new PersistenceExceptionTranslationPostProcessor(); } - final Properties hibernateProperties() { + final Properties additionalProperties() { return new Properties() { { setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); @@ -76,4 +86,5 @@ final Properties hibernateProperties() { } }; } + } \ No newline at end of file diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index b7878abd81d7..8f9b5003daa4 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -2,10 +2,10 @@ import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + import org.baeldung.spring.persistence.model.Foo; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import com.google.common.base.Preconditions; @@ -13,8 +13,8 @@ @Repository public class FooDao implements IFooDao { - @Autowired - private SessionFactory sessionFactory; + @PersistenceContext + private EntityManager entityManager; public FooDao() { super(); @@ -23,44 +23,38 @@ public FooDao() { // API @Override - public Foo findOne(final Long id) { - Preconditions.checkArgument(id != null); - return (Foo) getCurrentSession().get(Foo.class, id); + public Foo findOne(final long id) { + return entityManager.find(Foo.class, id); } @Override @SuppressWarnings("unchecked") public List findAll() { - return getCurrentSession().createQuery("from " + Foo.class.getName()).list(); + return entityManager.createQuery("from " + Foo.class.getName()).getResultList(); } @Override public void create(final Foo entity) { Preconditions.checkNotNull(entity); - getCurrentSession().persist(entity); + entityManager.persist(entity); } @Override public void update(final Foo entity) { Preconditions.checkNotNull(entity); - getCurrentSession().merge(entity); + entityManager.merge(entity); } @Override public void delete(final Foo entity) { Preconditions.checkNotNull(entity); - getCurrentSession().delete(entity); + entityManager.remove(entity); } @Override - public void deleteById(final Long entityId) { + public void deleteById(final long entityId) { final Foo entity = findOne(entityId); - Preconditions.checkState(entity != null); delete(entity); } - protected final Session getCurrentSession() { - return sessionFactory.getCurrentSession(); - } - } diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index 5536c9e7d740..a5c22d1e419e 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -6,7 +6,7 @@ public interface IFooDao { - Foo findOne(Long id); + Foo findOne(long id); List findAll(); @@ -16,6 +16,6 @@ public interface IFooDao { void delete(Foo entity); - void deleteById(Long entityId); + void deleteById(long entityId); } diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 2bf8f7f00869..8b03df39e7a3 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -5,7 +5,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.validation.constraints.NotNull; @Entity public class Foo { @@ -15,7 +14,6 @@ public class Foo { private long id; @Column(nullable = false) - @NotNull private String name; public Foo() { diff --git a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 3020250f6d03..576f536adc80 100644 --- a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,6 +4,7 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -50,6 +51,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { } @Test + @Ignore public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } From 71a230ef91dac7ec3a954389ca8001d53814a3e0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 15:54:43 +0300 Subject: [PATCH 059/796] jpa work --- .../spring/persistence/config/PersistenceConfig.java | 6 +----- .../java/org/baeldung/spring/persistence/dao/FooDao.java | 4 ++-- .../java/org/baeldung/spring/persistence/dao/IFooDao.java | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index 3532afe22934..52ee113e17aa 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -40,11 +40,7 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { factoryBean.setDataSource(restDataSource()); factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter() { - { - // JPA properties ... - } - }; + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setJpaProperties(additionalProperties()); diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index 8f9b5003daa4..f970ade71f70 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -40,9 +40,9 @@ public void create(final Foo entity) { } @Override - public void update(final Foo entity) { + public Foo update(final Foo entity) { Preconditions.checkNotNull(entity); - entityManager.merge(entity); + return entityManager.merge(entity); } @Override diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index a5c22d1e419e..201fc3e35187 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -12,7 +12,7 @@ public interface IFooDao { void create(Foo entity); - void update(Foo entity); + Foo update(Foo entity); void delete(Foo entity); diff --git a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 576f536adc80..42dbb45f030c 100644 --- a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,7 +4,6 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -51,9 +50,8 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { } @Test - @Ignore public final void temp_whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); + service.create(new Foo()); } } From bcfc7d9aaf5e27924e77a90953c0e6327ffaf288 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 16:03:37 +0300 Subject: [PATCH 060/796] hibernate work --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../persistence/dao/AbstractHibernateDao.java | 59 +++++++++++++++++++ .../spring/persistence/dao/FooDao.java | 50 +--------------- .../spring/persistence/dao/IFooDao.java | 10 ++-- .../spring/persistence/model/Foo.java | 6 +- .../FooServicePersistenceIntegrationTest.java | 2 + 6 files changed, 73 insertions(+), 56 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java diff --git a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs index a931b331929d..c201ee1f7a18 100644 --- a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs @@ -42,7 +42,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java new file mode 100644 index 000000000000..4ff95f112688 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java @@ -0,0 +1,59 @@ +package org.baeldung.spring.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao { + private Class clazz; + + @Autowired + private SessionFactory sessionFactory; + + // API + + protected final void setClazz(final Class clazzToSet) { + clazz = clazzToSet; + } + + public final T findOne(final Long id) { + Preconditions.checkArgument(id != null); + return ((T) getCurrentSession().get(clazz, id)); + } + + public final List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + public final void create(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().persist(entity); + } + + public final T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + public final void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + public final void deleteById(final Long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index b7878abd81d7..1efa61ffb283 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -1,66 +1,22 @@ package org.baeldung.spring.persistence.dao; -import java.util.List; - import org.baeldung.spring.persistence.model.Foo; -import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; -import com.google.common.base.Preconditions; - @Repository -public class FooDao implements IFooDao { +public class FooDao extends AbstractHibernateDao implements IFooDao { @Autowired private SessionFactory sessionFactory; public FooDao() { super(); - } - - // API - - @Override - public Foo findOne(final Long id) { - Preconditions.checkArgument(id != null); - return (Foo) getCurrentSession().get(Foo.class, id); - } - - @Override - @SuppressWarnings("unchecked") - public List findAll() { - return getCurrentSession().createQuery("from " + Foo.class.getName()).list(); - } - @Override - public void create(final Foo entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().persist(entity); + setClazz(Foo.class); } - @Override - public void update(final Foo entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().merge(entity); - } - - @Override - public void delete(final Foo entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().delete(entity); - } - - @Override - public void deleteById(final Long entityId) { - final Foo entity = findOne(entityId); - Preconditions.checkState(entity != null); - delete(entity); - } - - protected final Session getCurrentSession() { - return sessionFactory.getCurrentSession(); - } + // API } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index 5536c9e7d740..6ad12b147cc1 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -6,16 +6,16 @@ public interface IFooDao { - Foo findOne(Long id); + Foo findOne(final Long id); List findAll(); - void create(Foo entity); + void create(final Foo entity); - void update(Foo entity); + Foo update(final Foo entity); - void delete(Foo entity); + void delete(final Foo entity); - void deleteById(Long entityId); + void deleteById(final Long entityId); } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 2bf8f7f00869..2043d087e024 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -1,21 +1,21 @@ package org.baeldung.spring.persistence.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.validation.constraints.NotNull; @Entity -public class Foo { +public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(nullable = false) - @NotNull private String name; public Foo() { diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 3020250f6d03..576f536adc80 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,6 +4,7 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -50,6 +51,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { } @Test + @Ignore public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } From ecaeb5e87165d650a390cefc177d860226353458 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 16:21:36 +0300 Subject: [PATCH 061/796] persistence work --- spring-hibernate3/.classpath | 1 + spring-hibernate3/.project | 11 --- .../.settings/org.eclipse.jdt.core.prefs | 83 +++++++++++++++++++ .../org.eclipse.wst.common.component | 1 + spring-hibernate3/pom.xml | 14 ++++ .../persistence/dao/AbstractHibernateDao.java | 64 ++++++++++++++ .../spring/persistence/dao/FooDao.java | 5 +- .../spring/persistence/dao/IFooDao.java | 4 +- .../spring/persistence/dao/IOperations.java | 20 +++++ .../spring/persistence/model/Foo.java | 54 +++++++++++- .../persistence/service/FooService.java | 7 +- .../FooServicePersistenceIntegrationTest.java | 59 +++++++++++++ .../persistence/dao/AbstractHibernateDao.java | 17 ++-- .../spring/persistence/dao/IFooDao.java | 18 +--- .../spring/persistence/dao/IOperations.java | 20 +++++ 15 files changed, 341 insertions(+), 37 deletions(-) create mode 100644 spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java create mode 100644 spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java create mode 100644 spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java diff --git a/spring-hibernate3/.classpath b/spring-hibernate3/.classpath index 593395a46e93..7e214d86c6e2 100644 --- a/spring-hibernate3/.classpath +++ b/spring-hibernate3/.classpath @@ -6,6 +6,7 @@
+ diff --git a/spring-hibernate3/.project b/spring-hibernate3/.project index fba218889745..5725f008def9 100644 --- a/spring-hibernate3/.project +++ b/spring-hibernate3/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs index 62492222ad2e..33f3a5c234c0 100644 --- a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,9 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve @@ -6,7 +11,85 @@ org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-hibernate3/.settings/org.eclipse.wst.common.component b/spring-hibernate3/.settings/org.eclipse.wst.common.component index 14b1679703ce..2078f0abbbc5 100644 --- a/spring-hibernate3/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate3/.settings/org.eclipse.wst.common.component @@ -4,6 +4,7 @@ + diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 2fc47dbcadf1..69d9da3294f5 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -56,6 +56,20 @@ + + org.apache.commons + commons-lang3 + 3.1 + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + junit junit-dep diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java new file mode 100644 index 000000000000..0ff6307147c0 --- /dev/null +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java @@ -0,0 +1,64 @@ +package org.baeldung.spring.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao implements IOperations { + private Class clazz; + + @Autowired + private SessionFactory sessionFactory; + + // API + + protected final void setClazz(final Class clazzToSet) { + clazz = clazzToSet; + } + + @Override + public final T findOne(final long id) { + return ((T) getCurrentSession().get(clazz, id)); + } + + @Override + public final List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + @Override + public final long create(final T entity) { + Preconditions.checkNotNull(entity); + return (Long) getCurrentSession().save(entity); + } + + @Override + public final T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + @Override + public final void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public final void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java index a59bb30f48b1..1c76ed1f0405 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java @@ -1,12 +1,15 @@ package org.baeldung.spring.persistence.dao; +import org.baeldung.spring.persistence.model.Foo; import org.springframework.stereotype.Repository; @Repository -public class FooDao implements IFooDao { +public class FooDao extends AbstractHibernateDao implements IFooDao { public FooDao() { super(); + + setClazz(Foo.class); } // API diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index 91d44f5f6bfb..eea1f17b5a0d 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -1,5 +1,7 @@ package org.baeldung.spring.persistence.dao; -public interface IFooDao { +import org.baeldung.spring.persistence.model.Foo; + +public interface IFooDao extends IOperations { // } diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java new file mode 100644 index 000000000000..d2cb0a9cefcb --- /dev/null +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java @@ -0,0 +1,20 @@ +package org.baeldung.spring.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + long create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java index 8842c26d95b1..2043d087e024 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java @@ -1,21 +1,33 @@ package org.baeldung.spring.persistence.model; +import java.io.Serializable; + +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity -public class Foo { +public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; + @Column(nullable = false) + private String name; + public Foo() { super(); } + public Foo(final String name) { + super(); + + this.name = name; + } + // API public long getId() { @@ -26,6 +38,46 @@ public void setId(final long id) { this.id = id; } + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + // + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + } diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java index cda31a0e86ef..4983d9991506 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -1,6 +1,7 @@ package org.baeldung.spring.persistence.service; import org.baeldung.spring.persistence.dao.IFooDao; +import org.baeldung.spring.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -8,7 +9,7 @@ public class FooService { @Autowired - private IFooDao fooDao; + private IFooDao dao; public FooService() { super(); @@ -16,4 +17,8 @@ public FooService() { // API + public void create(final Foo entity) { + dao.create(entity); + } + } diff --git a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..576f536adc80 --- /dev/null +++ b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,59 @@ +package org.baeldung.spring.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.baeldung.spring.persistence.model.Foo; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test + @Ignore + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java index 4ff95f112688..0ff6307147c0 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java @@ -10,7 +10,7 @@ import com.google.common.base.Preconditions; @SuppressWarnings("unchecked") -public abstract class AbstractHibernateDao { +public abstract class AbstractHibernateDao implements IOperations { private Class clazz; @Autowired @@ -22,31 +22,36 @@ protected final void setClazz(final Class clazzToSet) { clazz = clazzToSet; } - public final T findOne(final Long id) { - Preconditions.checkArgument(id != null); + @Override + public final T findOne(final long id) { return ((T) getCurrentSession().get(clazz, id)); } + @Override public final List findAll() { return getCurrentSession().createQuery("from " + clazz.getName()).list(); } - public final void create(final T entity) { + @Override + public final long create(final T entity) { Preconditions.checkNotNull(entity); - getCurrentSession().persist(entity); + return (Long) getCurrentSession().save(entity); } + @Override public final T update(final T entity) { Preconditions.checkNotNull(entity); return (T) getCurrentSession().merge(entity); } + @Override public final void delete(final T entity) { Preconditions.checkNotNull(entity); getCurrentSession().delete(entity); } - public final void deleteById(final Long entityId) { + @Override + public final void deleteById(final long entityId) { final T entity = findOne(entityId); Preconditions.checkState(entity != null); delete(entity); diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index 6ad12b147cc1..eea1f17b5a0d 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -1,21 +1,7 @@ package org.baeldung.spring.persistence.dao; -import java.util.List; - import org.baeldung.spring.persistence.model.Foo; -public interface IFooDao { - - Foo findOne(final Long id); - - List findAll(); - - void create(final Foo entity); - - Foo update(final Foo entity); - - void delete(final Foo entity); - - void deleteById(final Long entityId); - +public interface IFooDao extends IOperations { + // } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java new file mode 100644 index 000000000000..d2cb0a9cefcb --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java @@ -0,0 +1,20 @@ +package org.baeldung.spring.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + long create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} From 780300b8b3a4c23e26c46ba678a270d0b08d9069 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 16:48:11 +0300 Subject: [PATCH 062/796] persistence work --- .../baeldung/spring/persistence/config/PersistenceConfig.java | 3 ++- .../spring/persistence/config/PersistenceXmlConfig.java | 3 +-- .../baeldung/spring/persistence/dao/AbstractHibernateDao.java | 4 ++-- .../java/org/baeldung/spring/persistence/dao/IOperations.java | 2 +- .../org/baeldung/spring/persistence/service/FooService.java | 2 ++ 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java index b59ea8e3414e..769f3132f522 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -17,7 +18,7 @@ import com.google.common.base.Preconditions; -// @Configuration +@Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java index d8791b6bcc7b..e38b57fbcaf8 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java @@ -1,11 +1,10 @@ package org.baeldung.spring.persistence.config; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.transaction.annotation.EnableTransactionManagement; -@Configuration +// @Configuration @EnableTransactionManagement @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) @ImportResource({ "classpath:persistenceConfig.xml" }) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java index 0ff6307147c0..9a579245d39d 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java @@ -33,9 +33,9 @@ public final List findAll() { } @Override - public final long create(final T entity) { + public final void create(final T entity) { Preconditions.checkNotNull(entity); - return (Long) getCurrentSession().save(entity); + getCurrentSession().persist(entity); } @Override diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java index d2cb0a9cefcb..51591c57b433 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java @@ -9,7 +9,7 @@ public interface IOperations { List findAll(); - long create(final T entity); + void create(final T entity); T update(final T entity); diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java index 4983d9991506..1d3b5c4a0201 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java @@ -4,8 +4,10 @@ import org.baeldung.spring.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional public class FooService { @Autowired From 1a8b39bde6b75308c20b41be4d99ba0e394ac9e3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 16:55:10 +0300 Subject: [PATCH 063/796] one to one initial work --- .../spring/persistence/dao/IChildDao.java | 8 +++++ .../spring/persistence/dao/IFooDao.java | 1 + .../spring/persistence/dao/IOwnerDao.java | 8 +++++ .../{ => common}/AbstractHibernateDao.java | 2 +- .../dao/{ => common}/IOperations.java | 2 +- .../spring/persistence/dao/impl/ChildDao.java | 24 +++++++++++++++ .../persistence/dao/{ => impl}/FooDao.java | 4 ++- .../spring/persistence/dao/impl/OwnerDao.java | 24 +++++++++++++++ .../spring/persistence/model/Child.java | 30 +++++++++++++++++++ .../spring/persistence/model/Owner.java | 30 +++++++++++++++++++ 10 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/{ => common}/AbstractHibernateDao.java (96%) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/{ => common}/IOperations.java (85%) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/{ => impl}/FooDao.java (71%) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java new file mode 100644 index 000000000000..0a2180bed3cd --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.dao; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Child; + +public interface IChildDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java index eea1f17b5a0d..646b3af228b6 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java @@ -1,5 +1,6 @@ package org.baeldung.spring.persistence.dao; +import org.baeldung.spring.persistence.dao.common.IOperations; import org.baeldung.spring.persistence.model.Foo; public interface IFooDao extends IOperations { diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java new file mode 100644 index 000000000000..beda16493593 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.dao; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Owner; + +public interface IOwnerDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java similarity index 96% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java index 0ff6307147c0..25d14cd69714 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.spring.persistence.dao.common; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java similarity index 85% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java index d2cb0a9cefcb..716bd40e9b97 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.spring.persistence.dao.common; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java new file mode 100644 index 000000000000..380787823c92 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java @@ -0,0 +1,24 @@ +package org.baeldung.spring.persistence.dao.impl; + +import org.baeldung.spring.persistence.dao.IChildDao; +import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.spring.persistence.model.Child; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class ChildDao extends AbstractHibernateDao implements IChildDao { + + @Autowired + private SessionFactory sessionFactory; + + public ChildDao() { + super(); + + setClazz(Child.class); + } + + // API + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java similarity index 71% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java index 1efa61ffb283..c083b41799b5 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java @@ -1,5 +1,7 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.spring.persistence.dao.impl; +import org.baeldung.spring.persistence.dao.IFooDao; +import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; import org.baeldung.spring.persistence.model.Foo; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java new file mode 100644 index 000000000000..a9156d06cf15 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java @@ -0,0 +1,24 @@ +package org.baeldung.spring.persistence.dao.impl; + +import org.baeldung.spring.persistence.dao.IOwnerDao; +import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.spring.persistence.model.Owner; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class OwnerDao extends AbstractHibernateDao implements IOwnerDao { + + @Autowired + private SessionFactory sessionFactory; + + public OwnerDao() { + super(); + + setClazz(Owner.class); + } + + // API + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java new file mode 100644 index 000000000000..123ab2ac17ac --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java @@ -0,0 +1,30 @@ +package org.baeldung.spring.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Child implements Serializable { + + @Id + @GeneratedValue + private long id; + + public Child() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java new file mode 100644 index 000000000000..d2f8d36f4482 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java @@ -0,0 +1,30 @@ +package org.baeldung.spring.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Owner implements Serializable { + + @Id + @GeneratedValue + private long id; + + public Owner() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + +} From 011d6a1f78162dcdbf04161574c79f8e5e06fd8a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 16:58:37 +0300 Subject: [PATCH 064/796] persistence work (unstable) --- .../dao/common/AbstractHibernateDao.java | 4 +- .../persistence/dao/common/IOperations.java | 2 +- .../service/common/AbstractService.java | 42 +++++++++++++++++++ .../service/{ => impl}/FooService.java | 11 +++-- .../FooServicePersistenceIntegrationTest.java | 1 + 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/{ => impl}/FooService.java (56%) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java index 25d14cd69714..0d9a691ab8e4 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java @@ -33,9 +33,9 @@ public final List findAll() { } @Override - public final long create(final T entity) { + public final void create(final T entity) { Preconditions.checkNotNull(entity); - return (Long) getCurrentSession().save(entity); + getCurrentSession().save(entity); } @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java index 716bd40e9b97..12ac048d745c 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java @@ -9,7 +9,7 @@ public interface IOperations { List findAll(); - long create(final T entity); + void create(final T entity); T update(final T entity); diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java new file mode 100644 index 000000000000..009bb03c45d3 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java @@ -0,0 +1,42 @@ +package org.baeldung.spring.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.spring.persistence.dao.common.IOperations; + +public abstract class AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return getDao().findOne(id); + } + + @Override + public List findAll() { + return getDao().findAll(); + } + + @Override + public void create(final T entity) { + getDao().create(entity); + } + + @Override + public T update(final T entity) { + return getDao().update(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(entityId); + } + + protected abstract IOperations getDao(); + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java similarity index 56% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java index 1d3b5c4a0201..7438258e30ee 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java @@ -1,14 +1,16 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.spring.persistence.service.impl; import org.baeldung.spring.persistence.dao.IFooDao; +import org.baeldung.spring.persistence.dao.common.IOperations; import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.spring.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional -public class FooService { +public class FooService extends AbstractService { @Autowired private IFooDao dao; @@ -19,8 +21,9 @@ public FooService() { // API - public void create(final Foo entity) { - dao.create(entity); + @Override + protected IOperations getDao() { + return dao; } } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 576f536adc80..bc629f4ae320 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,6 +4,7 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.spring.persistence.service.impl.FooService; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; From 7cbbf265f9989a8254103ae6684a21805bd0e1fa Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:01:26 +0300 Subject: [PATCH 065/796] persistence work --- .../persistence/dao/common/AbstractHibernateDao.java | 2 +- .../baeldung/spring/persistence/service/IFooService.java | 8 ++++++++ .../persistence/service/common/AbstractService.java | 2 ++ .../spring/persistence/service/impl/FooService.java | 3 ++- .../service/FooServicePersistenceIntegrationTest.java | 3 +-- 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java index 0d9a691ab8e4..81f6acf9dc6b 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java @@ -35,7 +35,7 @@ public final List findAll() { @Override public final void create(final T entity) { Preconditions.checkNotNull(entity); - getCurrentSession().save(entity); + getCurrentSession().persist(entity); } @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java new file mode 100644 index 000000000000..59d532aa5459 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Foo; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java index 009bb03c45d3..6d0f2f49d623 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java @@ -4,7 +4,9 @@ import java.util.List; import org.baeldung.spring.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; +@Transactional public abstract class AbstractService implements IOperations { @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java index 7438258e30ee..6a97596e7d62 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java @@ -3,6 +3,7 @@ import org.baeldung.spring.persistence.dao.IFooDao; import org.baeldung.spring.persistence.dao.common.IOperations; import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.spring.persistence.service.IFooService; import org.baeldung.spring.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -10,7 +11,7 @@ @Service @Transactional -public class FooService extends AbstractService { +public class FooService extends AbstractService implements IFooService { @Autowired private IFooDao dao; diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index bc629f4ae320..d35440bf1543 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,7 +4,6 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Foo; -import org.baeldung.spring.persistence.service.impl.FooService; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,7 +19,7 @@ public class FooServicePersistenceIntegrationTest { @Autowired - private FooService service; + private IFooService service; // tests From 2035877d58b78a2757d6f2990e713616284a50c3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:03:17 +0300 Subject: [PATCH 066/796] persistence work --- .../spring/persistence/dao/common/AbstractHibernateDao.java | 2 +- .../baeldung/spring/persistence/service/impl/FooService.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java index 81f6acf9dc6b..cf293231ab3f 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java @@ -19,7 +19,7 @@ public abstract class AbstractHibernateDao implements IO // API protected final void setClazz(final Class clazzToSet) { - clazz = clazzToSet; + clazz = Preconditions.checkNotNull(clazzToSet); } @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java index 6a97596e7d62..19223a82ca4a 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java @@ -7,10 +7,8 @@ import org.baeldung.spring.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service -@Transactional public class FooService extends AbstractService implements IFooService { @Autowired From 2bde87bef2a973d1c9b3fabe6c59db5f7ebc1fcd Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:14:49 +0300 Subject: [PATCH 067/796] new owner - child support --- .../persistence/service/IChildService.java | 8 ++++++ .../persistence/service/IOwnerService.java | 8 ++++++ .../service/impl/ChildService.java | 28 +++++++++++++++++++ .../service/impl/OwnerService.java | 28 +++++++++++++++++++ ...wnerServicePersistenceIntegrationTest.java | 28 +++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java new file mode 100644 index 000000000000..785d581c799f --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Child; + +public interface IChildService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java new file mode 100644 index 000000000000..66e647b25354 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java @@ -0,0 +1,8 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Owner; + +public interface IOwnerService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java new file mode 100644 index 000000000000..d28682fdfd7c --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service.impl; + +import org.baeldung.spring.persistence.dao.IChildDao; +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Child; +import org.baeldung.spring.persistence.service.IChildService; +import org.baeldung.spring.persistence.service.common.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ChildService extends AbstractService implements IChildService { + + @Autowired + private IChildDao dao; + + public ChildService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java new file mode 100644 index 000000000000..e3f2f7a04f05 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service.impl; + +import org.baeldung.spring.persistence.dao.IOwnerDao; +import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.spring.persistence.model.Owner; +import org.baeldung.spring.persistence.service.IOwnerService; +import org.baeldung.spring.persistence.service.common.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class OwnerService extends AbstractService implements IOwnerService { + + @Autowired + private IOwnerDao dao; + + public OwnerService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..4b668777a855 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.persistence.service; + +import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class OwnerServicePersistenceIntegrationTest { + + @Autowired + private IOwnerService service; + + @Autowired + private IChildService childService; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + +} From f50f4eb6a6ad2b2267d36990b81e435fe8715517 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:15:36 +0300 Subject: [PATCH 068/796] name change --- .../dao/{IOwnerDao.java => IParentDao.java} | 4 ++-- .../dao/impl/{OwnerDao.java => ParentDao.java} | 10 +++++----- .../persistence/model/{Owner.java => Parent.java} | 4 ++-- .../{IOwnerService.java => IParentService.java} | 4 ++-- .../impl/{OwnerService.java => ParentService.java} | 14 +++++++------- ...> ParentServicePersistenceIntegrationTest.java} | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/{IOwnerDao.java => IParentDao.java} (51%) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/{OwnerDao.java => ParentDao.java} (60%) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/{Owner.java => Parent.java} (85%) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/{IOwnerService.java => IParentService.java} (51%) rename spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/{OwnerService.java => ParentService.java} (52%) rename spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/{OwnerServicePersistenceIntegrationTest.java => ParentServicePersistenceIntegrationTest.java} (89%) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java similarity index 51% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java index beda16493593..1b35ba9f018e 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IOwnerDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java @@ -1,8 +1,8 @@ package org.baeldung.spring.persistence.dao; import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Owner; +import org.baeldung.spring.persistence.model.Parent; -public interface IOwnerDao extends IOperations { +public interface IParentDao extends IOperations { // } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java similarity index 60% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java index a9156d06cf15..6604c7a77430 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/OwnerDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java @@ -1,22 +1,22 @@ package org.baeldung.spring.persistence.dao.impl; -import org.baeldung.spring.persistence.dao.IOwnerDao; +import org.baeldung.spring.persistence.dao.IParentDao; import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; -import org.baeldung.spring.persistence.model.Owner; +import org.baeldung.spring.persistence.model.Parent; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @Repository -public class OwnerDao extends AbstractHibernateDao implements IOwnerDao { +public class ParentDao extends AbstractHibernateDao implements IParentDao { @Autowired private SessionFactory sessionFactory; - public OwnerDao() { + public ParentDao() { super(); - setClazz(Owner.class); + setClazz(Parent.class); } // API diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java similarity index 85% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index d2f8d36f4482..2fb6367feea1 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Owner.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -7,13 +7,13 @@ import javax.persistence.Id; @Entity -public class Owner implements Serializable { +public class Parent implements Serializable { @Id @GeneratedValue private long id; - public Owner() { + public Parent() { super(); } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java similarity index 51% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java index 66e647b25354..6d37d75354f9 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IOwnerService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java @@ -1,8 +1,8 @@ package org.baeldung.spring.persistence.service; import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Owner; +import org.baeldung.spring.persistence.model.Parent; -public interface IOwnerService extends IOperations { +public interface IParentService extends IOperations { // } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java similarity index 52% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java index e3f2f7a04f05..84d42772993c 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/OwnerService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java @@ -1,27 +1,27 @@ package org.baeldung.spring.persistence.service.impl; -import org.baeldung.spring.persistence.dao.IOwnerDao; +import org.baeldung.spring.persistence.dao.IParentDao; import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Owner; -import org.baeldung.spring.persistence.service.IOwnerService; +import org.baeldung.spring.persistence.model.Parent; +import org.baeldung.spring.persistence.service.IParentService; import org.baeldung.spring.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class OwnerService extends AbstractService implements IOwnerService { +public class ParentService extends AbstractService implements IParentService { @Autowired - private IOwnerDao dao; + private IParentDao dao; - public OwnerService() { + public ParentService() { super(); } // API @Override - protected IOperations getDao() { + protected IOperations getDao() { return dao; } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java similarity index 89% rename from spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java rename to spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 4b668777a855..11d13eba60ea 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/OwnerServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -10,10 +10,10 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class OwnerServicePersistenceIntegrationTest { +public class ParentServicePersistenceIntegrationTest { @Autowired - private IOwnerService service; + private IParentService service; @Autowired private IChildService childService; From c1dce2cd5963c36d1182021193b2ba50fb9815ac Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:28:25 +0300 Subject: [PATCH 069/796] temporary persistence work --- .../spring/persistence/model/Child.java | 15 ++++++++++++++ .../spring/persistence/model/Parent.java | 20 +++++++++++++++++++ ...rentServicePersistenceIntegrationTest.java | 12 +++++++++++ 3 files changed, 47 insertions(+) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java index 123ab2ac17ac..010063d252e9 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java @@ -3,8 +3,11 @@ import java.io.Serializable; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.PrimaryKeyJoinColumn; @Entity public class Child implements Serializable { @@ -13,6 +16,10 @@ public class Child implements Serializable { @GeneratedValue private long id; + @OneToOne(fetch = FetchType.LAZY) + @PrimaryKeyJoinColumn + private Parent parent; + public Child() { super(); } @@ -27,4 +34,12 @@ public void setId(final long id) { this.id = id; } + public Parent getParent() { + return parent; + } + + public void setParent(final Parent parent) { + this.parent = parent; + } + } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index 2fb6367feea1..39d43d1adfb8 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -2,9 +2,12 @@ import java.io.Serializable; +import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.OneToOne; @Entity public class Parent implements Serializable { @@ -13,10 +16,19 @@ public class Parent implements Serializable { @GeneratedValue private long id; + @OneToOne(fetch = FetchType.LAZY, mappedBy = "parent", cascade = CascadeType.ALL) + private Child child; + public Parent() { super(); } + public Parent(final Child child) { + super(); + + this.child = child; + } + // API public long getId() { @@ -27,4 +39,12 @@ public void setId(final long id) { this.id = id; } + public Child getChild() { + return child; + } + + public void setChild(final Child child) { + this.child = child; + } + } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 11d13eba60ea..df40f6a6a95f 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -1,6 +1,8 @@ package org.baeldung.spring.persistence.service; import org.baeldung.spring.persistence.config.PersistenceConfig; +import org.baeldung.spring.persistence.model.Child; +import org.baeldung.spring.persistence.model.Parent; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -25,4 +27,14 @@ public final void whenContextIsBootstrapped_thenNoExceptions() { // } + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + final Child childEntity = new Child(); + childService.create(childEntity); + + service.create(new Parent(childEntity)); + + System.out.println(); + } + } From fbb5402bf25349ada1a4b5a2c959c04abba541c3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 17:50:40 +0300 Subject: [PATCH 070/796] one to one done --- .../main/resources/persistence-mysql.properties | 2 +- .../baeldung/spring/persistence/model/Child.java | 10 ++++++++++ .../baeldung/spring/persistence/model/Parent.java | 14 ++++++++++++-- .../main/resources/persistence-mysql.properties | 2 +- .../ParentServicePersistenceIntegrationTest.java | 9 +++++++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/spring-hibernate3/src/main/resources/persistence-mysql.properties b/spring-hibernate3/src/main/resources/persistence-mysql.properties index a1ff997616ae..d5769fc9780b 100644 --- a/spring-hibernate3/src/main/resources/persistence-mysql.properties +++ b/spring-hibernate3/src/main/resources/persistence-mysql.properties @@ -1,6 +1,6 @@ # jdbc.X jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate3_01?createDatabaseIfNotExist=true jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java index 010063d252e9..e2382dfe11e9 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java @@ -34,6 +34,7 @@ public void setId(final long id) { this.id = id; } + @OneToOne(mappedBy = "child") public Parent getParent() { return parent; } @@ -42,4 +43,13 @@ public void setParent(final Parent parent) { this.parent = parent; } + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Child [id=").append(id).append(", parent=").append(parent).append("]"); + return builder.toString(); + } + } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index 39d43d1adfb8..c936e27dea65 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -4,9 +4,9 @@ import javax.persistence.CascadeType; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.OneToOne; @Entity @@ -16,7 +16,6 @@ public class Parent implements Serializable { @GeneratedValue private long id; - @OneToOne(fetch = FetchType.LAZY, mappedBy = "parent", cascade = CascadeType.ALL) private Child child; public Parent() { @@ -39,6 +38,8 @@ public void setId(final long id) { this.id = id; } + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "child_fk") public Child getChild() { return child; } @@ -47,4 +48,13 @@ public void setChild(final Child child) { this.child = child; } + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Parent [id=").append(id).append(", child=").append(child).append("]"); + return builder.toString(); + } + } diff --git a/spring-hibernate4/src/main/resources/persistence-mysql.properties b/spring-hibernate4/src/main/resources/persistence-mysql.properties index a1ff997616ae..8263b0d9accd 100644 --- a/spring-hibernate4/src/main/resources/persistence-mysql.properties +++ b/spring-hibernate4/src/main/resources/persistence-mysql.properties @@ -1,6 +1,6 @@ # jdbc.X jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index df40f6a6a95f..7f7060f0b9cd 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -32,9 +32,14 @@ public final void whenEntityIsCreated_thenNoExceptions() { final Child childEntity = new Child(); childService.create(childEntity); - service.create(new Parent(childEntity)); + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); - System.out.println(); + System.out.println("Child = " + childService.findOne(childEntity.getId())); + System.out.println("Child - parent = " + childService.findOne(childEntity.getId()).getParent()); + + System.out.println("Parent = " + service.findOne(parentEntity.getId())); + System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); } } From cb1c8cb3e270db5bd4e4b8c09ffbb0118b6a468c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 18:03:52 +0300 Subject: [PATCH 071/796] bidrectional foregin key one to one --- .../baeldung/spring/persistence/model/Child.java | 6 +----- .../baeldung/spring/persistence/model/Parent.java | 4 ++-- .../ParentServicePersistenceIntegrationTest.java | 13 ++++++++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java index e2382dfe11e9..8589a2f49787 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java @@ -3,11 +3,9 @@ import java.io.Serializable; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToOne; -import javax.persistence.PrimaryKeyJoinColumn; @Entity public class Child implements Serializable { @@ -16,8 +14,7 @@ public class Child implements Serializable { @GeneratedValue private long id; - @OneToOne(fetch = FetchType.LAZY) - @PrimaryKeyJoinColumn + @OneToOne(mappedBy = "child") private Parent parent; public Child() { @@ -34,7 +31,6 @@ public void setId(final long id) { this.id = id; } - @OneToOne(mappedBy = "child") public Parent getParent() { return parent; } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index c936e27dea65..4fd7af6b0972 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -16,6 +16,8 @@ public class Parent implements Serializable { @GeneratedValue private long id; + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "child_fk") private Child child; public Parent() { @@ -38,8 +40,6 @@ public void setId(final long id) { this.id = id; } - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "child_fk") public Child getChild() { return child; } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 7f7060f0b9cd..126066a941b5 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -28,7 +28,7 @@ public final void whenContextIsBootstrapped_thenNoExceptions() { } @Test - public final void whenEntityIsCreated_thenNoExceptions() { + public final void whenOneToOneEntitiesAreCreated_thenNoExceptions() { final Child childEntity = new Child(); childService.create(childEntity); @@ -42,4 +42,15 @@ public final void whenEntityIsCreated_thenNoExceptions() { System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); } + @Test + public final void whenChildIsDeleted_thenDataException() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + childService.delete(childEntity); + } + } From 26e6d6eb86a25436932587237d147b384bbc3a6f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 18:11:09 +0300 Subject: [PATCH 072/796] good one to one mapping, failing tests for constraint violation --- .../spring/persistence/dao/common/AbstractHibernateDao.java | 3 ++- .../java/org/baeldung/spring/persistence/model/Child.java | 2 +- .../java/org/baeldung/spring/persistence/model/Parent.java | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 1 + .../service/ParentServicePersistenceIntegrationTest.java | 4 ++++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java index cf293231ab3f..3476b8cadc9e 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java @@ -35,7 +35,8 @@ public final List findAll() { @Override public final void create(final T entity) { Preconditions.checkNotNull(entity); - getCurrentSession().persist(entity); + // getCurrentSession().persist(entity); + getCurrentSession().saveOrUpdate(entity); } @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java index 8589a2f49787..978502242c15 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java @@ -44,7 +44,7 @@ public void setParent(final Parent parent) { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("Child [id=").append(id).append(", parent=").append(parent).append("]"); + builder.append("Child [id=").append(id).append("]"); return builder.toString(); } diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index 4fd7af6b0972..875b56df3438 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -53,7 +53,7 @@ public void setChild(final Child child) { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("Parent [id=").append(id).append(", child=").append(child).append("]"); + builder.append("Parent [id=").append(id).append("]"); return builder.toString(); } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index d35440bf1543..69d094f5d893 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -44,6 +44,7 @@ public final void whenEntityWithLongNameIsCreated_thenDataException() { } @Test(expected = InvalidDataAccessApiUsageException.class) + @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") public final void whenSameEntityIsCreatedTwice_thenDataException() { final Foo entity = new Foo(randomAlphabetic(8)); service.create(entity); diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 126066a941b5..27338a6c4ddc 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -3,6 +3,7 @@ import org.baeldung.spring.persistence.config.PersistenceConfig; import org.baeldung.spring.persistence.model.Child; import org.baeldung.spring.persistence.model.Parent; +import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +21,9 @@ public class ParentServicePersistenceIntegrationTest { @Autowired private IChildService childService; + @Autowired + private SessionFactory sessionFactory; + // tests @Test From 34c89649fe1c16d4e5657da3cf43eef51d66769b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 May 2013 20:14:59 +0300 Subject: [PATCH 073/796] persistence work --- .../baeldung/spring/persistence/model/Parent.java | 2 +- .../ParentServicePersistenceIntegrationTest.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java index 875b56df3438..5a8702896001 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java @@ -16,7 +16,7 @@ public class Parent implements Serializable { @GeneratedValue private long id; - @OneToOne(cascade = CascadeType.ALL) + @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH }) @JoinColumn(name = "child_fk") private Child child; diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 27338a6c4ddc..753d94ac79ab 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -46,14 +47,26 @@ public final void whenOneToOneEntitiesAreCreated_thenNoExceptions() { System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); } + @Test(expected = DataIntegrityViolationException.class) + public final void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + childService.delete(childEntity); + } + @Test - public final void whenChildIsDeleted_thenDataException() { + public final void whenChildIsDeletedAfterTheParent_thenNoExceptions() { final Child childEntity = new Child(); childService.create(childEntity); final Parent parentEntity = new Parent(childEntity); service.create(parentEntity); + service.delete(parentEntity); childService.delete(childEntity); } From 38361e887f172c03fd7030a4cff25421cbf8e95d Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 22 May 2013 14:50:48 +0300 Subject: [PATCH 074/796] deployment descriptor in java --- spring-mvc-java/pom.xml | 4 +- .../web/config/MainWebAppInitializer.java | 41 +++++++++++++++++++ .../webapp/WEB-INF/{web.xml => web_old.xml} | 0 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java rename spring-mvc-java/src/main/webapp/WEB-INF/{web.xml => web_old.xml} (100%) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index bb983b43e6f0..45551f72426b 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -120,7 +120,7 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE 1.7.5 @@ -132,7 +132,7 @@ 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java new file mode 100644 index 000000000000..81a94f1a8c10 --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java @@ -0,0 +1,41 @@ +package org.baeldung.spring.web.config; + +import java.util.Set; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + /** + * Register and configure all Servlet container components necessary to power the web application. + */ + @Override + public void onStartup(final ServletContext sc) throws ServletException { + System.out.println("GreenhouseWebAppInitializer.onStartup()"); + + // Create the 'root' Spring application context + final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.scan("org.baeldung.spring.web.config"); + // root.getEnvironment().setDefaultProfiles("embedded"); + + // Manages the lifecycle of the root application context + sc.addListener(new ContextLoaderListener(root)); + + // Handles requests into the application + final ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext())); + appServlet.setLoadOnStartup(1); + final Set mappingConflicts = appServlet.addMapping("/"); + if (!mappingConflicts.isEmpty()) { + throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); + } + } + +} diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/web.xml b/spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/web.xml rename to spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml From 47bfc87401638ce8ffa8b69eb8462af03974dd7f Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Wed, 22 May 2013 20:12:22 +0300 Subject: [PATCH 075/796] minor upgrades --- spring-security-basic-auth/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index fa41a090e6ed..4b114f1435dd 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -169,7 +169,7 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE 3.1.4.RELEASE @@ -182,7 +182,7 @@ 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 From dd8debd720a80965e3b59ff286bef4b28e26e920 Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Wed, 22 May 2013 20:52:33 +0300 Subject: [PATCH 076/796] security work --- ...ientWebConfig.java => FrontendConfig.java} | 5 +-- .../baeldung/spring/web/config/WebConfig.java | 17 ++++++++ .../spring/web/controller/TestController.java | 28 +++++++++++++ .../src/main/resources/webSecurityConfig.xml | 41 +++++++++++-------- 4 files changed, 71 insertions(+), 20 deletions(-) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/{ClientWebConfig.java => FrontendConfig.java} (88%) create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java similarity index 88% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java index 4aadc3a48c92..ffcc855716da 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java @@ -11,9 +11,9 @@ @EnableWebMvc @Configuration -public class ClientWebConfig extends WebMvcConfigurerAdapter { +public class FrontendConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { + public FrontendConfig() { super(); } @@ -23,7 +23,6 @@ public ClientWebConfig() { public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); } diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java new file mode 100644 index 000000000000..9a79aa3b6b29 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.spring.web.controller") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java new file mode 100644 index 000000000000..c7b04c14d2a4 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index d2a28094461e..a7d8d679ea66 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -1,23 +1,30 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ff3b2dfc53ebf527d4ac3b76785fcede20f174d4 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 22 May 2013 22:03:20 +0300 Subject: [PATCH 077/796] security work --- .../src/main/resources/webSecurityConfig.xml | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index a7d8d679ea66..5ddca9778643 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -1,30 +1,28 @@ - + - - + + - + - + - + - + - - - - - - - - - + + + + + + + \ No newline at end of file From e84500c4c48c801094929e4c00ae1f2b1c1e519e Mon Sep 17 00:00:00 2001 From: Eugen Date: Thu, 23 May 2013 11:13:36 +0300 Subject: [PATCH 078/796] minor work --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../java/org/baeldung/spring/web/Foo.java | 11 +++++++ .../spring/web/controller/FooController.java | 29 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java diff --git a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..df8135651462 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs @@ -42,7 +42,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java new file mode 100644 index 000000000000..a5e46bc8e545 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.spring.web; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java new file mode 100644 index 000000000000..eb0575f279a8 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -0,0 +1,29 @@ +package org.baeldung.spring.web.controller; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.spring.web.Foo; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.util.UriComponentsBuilder; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + +} From 794e3c0a95e6337a392a7d0d5770700fdd714c98 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 23 May 2013 21:28:33 +0300 Subject: [PATCH 079/796] logout work --- spring-security-login/pom.xml | 4 ++-- .../src/main/resources/webSecurityConfig.xml | 4 +++- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index d8cecabcdb63..b22672d8ebd9 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -169,7 +169,7 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE 3.1.4.RELEASE @@ -182,7 +182,7 @@ 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 6394c926995b..7fcee298b54b 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + + + diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp index 7cc14b5dcddf..5d96e37e32d5 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,7 +1,9 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

This is the body of the sample view

+ "> Logout \ No newline at end of file From e85fd01d616d45b44c4c4a4576ed8ba039d2eb95 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 23 May 2013 23:25:53 +0300 Subject: [PATCH 080/796] security work --- .../security/CustomLogoutSuccessHandler.java | 29 ++++++++++++++ .../spring/web/config/ClientWebConfig.java | 38 ++++++++++--------- .../src/main/resources/webSecurityConfig.xml | 20 +++++++--- .../main/webapp/WEB-INF/view/anonymous.jsp | 10 +++++ .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/web.xml | 6 +-- 6 files changed, 78 insertions(+), 27 deletions(-) create mode 100644 spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java create mode 100644 spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp diff --git a/spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java b/spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java new file mode 100644 index 000000000000..4d19744033d0 --- /dev/null +++ b/spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java @@ -0,0 +1,29 @@ +package org.baeldung.spring.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; +import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; + +public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler { + + public CustomLogoutSuccessHandler() { + super(); + } + + // API + + @Override + public void onLogoutSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { + final String refererUrl = request.getHeader("Referer"); + System.out.println(refererUrl); + + super.onLogoutSuccess(request, response, authentication); + } + +} diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 4aadc3a48c92..316759b24b3a 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -13,28 +13,30 @@ @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/login.html"); - registry.addViewController("/homepage.html"); - } + registry.addViewController("/anonymous.html"); - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + } - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - return bean; - } + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } } \ No newline at end of file diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 7fcee298b54b..e2b63fe45820 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -5,9 +5,14 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - - + + + + + + + + - - + + + + diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp new file mode 100644 index 000000000000..d4e9c0289b29 --- /dev/null +++ b/spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Anonymous page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp index 5d96e37e32d5..5504d2f134ee 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp @@ -4,6 +4,6 @@

This is the body of the sample view

- "> Logout + ">Logout \ No newline at end of file diff --git a/spring-security-login/src/main/webapp/WEB-INF/web.xml b/spring-security-login/src/main/webapp/WEB-INF/web.xml index 23e0e8c1d7b0..6274cdd9fe95 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-login/src/main/webapp/WEB-INF/web.xml @@ -45,8 +45,8 @@ /* - - index.html - + + + \ No newline at end of file From 144ce58d766dc0ad765fdd482b2393e3b296317f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 24 May 2013 21:36:46 +0300 Subject: [PATCH 081/796] exception work --- .../spring/web/config/ClientWebConfig.java | 34 +++++++++---------- .../baeldung/spring/web/config/WebConfig.java | 19 +++++++++++ .../src/main/java/org/baeldung/web/BeanA.java | 16 +++++++++ .../src/main/java/org/baeldung/web/BeanB.java | 9 +++++ 4 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java create mode 100644 spring-mvc-java/src/main/java/org/baeldung/web/BeanA.java create mode 100644 spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2758a707e6bc..945c1794fba9 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -13,27 +13,27 @@ @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + registry.addViewController("/sample.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java new file mode 100644 index 000000000000..d60bcfe12760 --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/org/baeldung/web/BeanA.java b/spring-mvc-java/src/main/java/org/baeldung/web/BeanA.java new file mode 100644 index 000000000000..b6b6f49c16d1 --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/web/BeanA.java @@ -0,0 +1,16 @@ +package org.baeldung.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private BeanB b; + + public BeanA() { + super(); + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java b/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java new file mode 100644 index 000000000000..8d0f29b29ee4 --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java @@ -0,0 +1,9 @@ +package org.baeldung.web; + +public class BeanB { + + public BeanB() { + super(); + } + +} From 17228e375d3ffb5227373a3e09a5e027d3daacea Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 24 May 2013 22:45:12 +0300 Subject: [PATCH 082/796] new project, bean wiring tests in the old mvc project --- spring-all/.classpath | 37 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-all/.gitignore | 13 + spring-all/.project | 60 ++++ spring-all/.settings/.jsdtscope | 12 + .../.settings/org.eclipse.jdt.core.prefs | 91 ++++++ spring-all/.settings/org.eclipse.jdt.ui.prefs | 55 ++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 + .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-all/.springBeans | 14 + spring-all/README.md | 3 + spring-all/pom.xml | 141 +++++++++ .../spring/web/config/ClientWebConfig.java | 39 +++ .../web/config/MainWebAppInitializer.java | 41 +++ .../baeldung/spring/web/config/WebConfig.java | 19 ++ .../src/main/java/org/baeldung/web/BeanA.java | 16 + .../src/main/java/org/baeldung/web/BeanB.java | 12 + spring-all/src/main/resources/logback.xml | 20 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web_old.xml | 42 +++ spring-all/src/test/resources/.gitignore | 13 + spring-mvc-java/pom.xml | 279 +++++++++--------- .../src/main/java/org/baeldung/web/BeanB.java | 3 + 30 files changed, 830 insertions(+), 140 deletions(-) create mode 100644 spring-all/.classpath create mode 100644 spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-all/.gitignore create mode 100644 spring-all/.project create mode 100644 spring-all/.settings/.jsdtscope create mode 100644 spring-all/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-all/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-all/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-all/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-all/.settings/org.eclipse.wst.common.component create mode 100644 spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-all/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-all/.springBeans create mode 100644 spring-all/README.md create mode 100644 spring-all/pom.xml create mode 100644 spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/web/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/web/BeanB.java create mode 100644 spring-all/src/main/resources/logback.xml create mode 100644 spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-all/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-all/src/main/webapp/WEB-INF/web_old.xml create mode 100644 spring-all/src/test/resources/.gitignore diff --git a/spring-all/.classpath b/spring-all/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-all/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-all/.gitignore b/spring-all/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-all/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-all/.project b/spring-all/.project new file mode 100644 index 000000000000..4ae82dabf052 --- /dev/null +++ b/spring-all/.project @@ -0,0 +1,60 @@ + + + spring-all + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-all/.settings/.jsdtscope b/spring-all/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-all/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-all/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-all/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-all/.settings/org.eclipse.jdt.ui.prefs b/spring-all/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-all/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-all/.settings/org.eclipse.m2e.core.prefs b/spring-all/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-all/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-all/.settings/org.eclipse.m2e.wtp.prefs b/spring-all/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-all/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-all/.settings/org.eclipse.wst.common.component b/spring-all/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..847c6ff6987a --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-all/.settings/org.eclipse.wst.validation.prefs b/spring-all/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-all/.springBeans b/spring-all/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-all/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-all/README.md b/spring-all/README.md new file mode 100644 index 000000000000..1abc096086ed --- /dev/null +++ b/spring-all/README.md @@ -0,0 +1,3 @@ +[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) +========= + diff --git a/spring-all/pom.xml b/spring-all/pom.xml new file mode 100644 index 000000000000..9561c1316ebc --- /dev/null +++ b/spring-all/pom.xml @@ -0,0 +1,141 @@ + + 4.0.0 + org.baeldung + spring-all + 0.1-SNAPSHOT + + spring-all + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-all + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..945c1794fba9 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java new file mode 100644 index 000000000000..81a94f1a8c10 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java @@ -0,0 +1,41 @@ +package org.baeldung.spring.web.config; + +import java.util.Set; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + /** + * Register and configure all Servlet container components necessary to power the web application. + */ + @Override + public void onStartup(final ServletContext sc) throws ServletException { + System.out.println("GreenhouseWebAppInitializer.onStartup()"); + + // Create the 'root' Spring application context + final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.scan("org.baeldung.spring.web.config"); + // root.getEnvironment().setDefaultProfiles("embedded"); + + // Manages the lifecycle of the root application context + sc.addListener(new ContextLoaderListener(root)); + + // Handles requests into the application + final ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext())); + appServlet.setLoadOnStartup(1); + final Set mappingConflicts = appServlet.addMapping("/"); + if (!mappingConflicts.isEmpty()) { + throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); + } + } + +} diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java new file mode 100644 index 000000000000..d60bcfe12760 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java new file mode 100644 index 000000000000..b6b6f49c16d1 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -0,0 +1,16 @@ +package org.baeldung.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private BeanB b; + + public BeanA() { + super(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB.java b/spring-all/src/main/java/org/baeldung/web/BeanB.java new file mode 100644 index 000000000000..49e5af4ccbe9 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/BeanB.java @@ -0,0 +1,12 @@ +package org.baeldung.web; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB { + + public BeanB() { + super(); + } + +} diff --git a/spring-all/src/main/resources/logback.xml b/spring-all/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-all/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/sample.jsp b/spring-all/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/web_old.xml b/spring-all/src/main/webapp/WEB-INF/web_old.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/web_old.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-all/src/test/resources/.gitignore b/spring-all/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-all/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 45551f72426b..913aa5058c30 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -1,142 +1,141 @@ - - 4.0.0 - org.baeldung - spring-mvc-java - 0.1-SNAPSHOT - - spring-mvc-java - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-mvc - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.0 - 1.8.9 - - + + 4.0.0 + org.baeldung + spring-mvc-java + 0.1-SNAPSHOT + + spring-mvc-java + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java b/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java index 8d0f29b29ee4..49e5af4ccbe9 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java +++ b/spring-mvc-java/src/main/java/org/baeldung/web/BeanB.java @@ -1,5 +1,8 @@ package org.baeldung.web; +import org.springframework.stereotype.Component; + +@Component public class BeanB { public BeanB() { From 8b070d278b8a539c87e0225af02dd7690a5c81d9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 24 May 2013 22:49:48 +0300 Subject: [PATCH 083/796] exception work --- spring-all/pom.xml | 45 +++++++++++ .../{web => }/config/ClientWebConfig.java | 2 +- .../config/MainWebAppInitializer.java | 2 +- .../spring/config/PersistenceConfig.java | 79 +++++++++++++++++++ .../spring/{web => }/config/WebConfig.java | 2 +- .../src/main/java/org/baeldung/web/BeanA.java | 2 +- .../src/main/java/org/baeldung/web/BeanB.java | 4 +- .../main/java/org/baeldung/web/IBeanB.java | 5 ++ 8 files changed, 136 insertions(+), 5 deletions(-) rename spring-all/src/main/java/org/baeldung/spring/{web => }/config/ClientWebConfig.java (96%) rename spring-all/src/main/java/org/baeldung/spring/{web => }/config/MainWebAppInitializer.java (97%) create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename spring-all/src/main/java/org/baeldung/spring/{web => }/config/WebConfig.java (92%) create mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanB.java diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 9561c1316ebc..bcbd87440c54 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -21,6 +21,43 @@ spring-webmvc ${org.springframework.version}
+ + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + 4.2.1.Final + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + 5.1.25 + runtime + + + + + + org.hibernate + hibernate-validator + 5.0.1.Final + @@ -38,6 +75,14 @@ runtime + + + + com.google.guava + guava + 14.0.1 + + diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java similarity index 96% rename from spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java index 945c1794fba9..f027eb73fc6a 100644 --- a/spring-all/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java similarity index 97% rename from spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java rename to spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java index 81a94f1a8c10..32096c64c762 100644 --- a/spring-all/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import java.util.Set; diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java new file mode 100644 index 000000000000..078d7e6f88bc --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.spring.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java similarity index 92% rename from spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java rename to spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java index d60bcfe12760..640302a495c4 100644 --- a/spring-all/src/main/java/org/baeldung/spring/web/config/WebConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java index b6b6f49c16d1..7a8a0d24d8ce 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -7,7 +7,7 @@ public class BeanA { @Autowired - private BeanB b; + private IBeanB b; public BeanA() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB.java b/spring-all/src/main/java/org/baeldung/web/BeanB.java index 49e5af4ccbe9..4078fe700089 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanB.java @@ -1,9 +1,11 @@ package org.baeldung.web; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; @Component -public class BeanB { +@Transactional +public class BeanB implements IBeanB { public BeanB() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanB.java b/spring-all/src/main/java/org/baeldung/web/IBeanB.java new file mode 100644 index 000000000000..63357980adc8 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.web; + +public interface IBeanB { + // +} From 7245aa572acad65ae121f60330a01bcfb0d6e9fb Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 24 May 2013 23:14:34 +0300 Subject: [PATCH 084/796] bean work --- spring-all/pom.xml | 2 +- .../spring/config/MainWebAppInitializer.java | 2 +- spring-all/src/main/java/org/baeldung/web/BeanA.java | 12 ++++++++++-- .../src/main/java/org/baeldung/web/BeanB1.java | 12 ++++++++++++ .../src/main/java/org/baeldung/web/BeanB2.java | 12 ++++++++++++ .../java/org/baeldung/web/{BeanB.java => BeanC.java} | 4 ++-- .../src/main/java/org/baeldung/web/IBeanC.java | 5 +++++ .../src/main/resources/persistence-mysql.properties | 10 ++++++++++ spring-hibernate4/pom.xml | 6 +++--- 9 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/web/BeanB1.java create mode 100644 spring-all/src/main/java/org/baeldung/web/BeanB2.java rename spring-all/src/main/java/org/baeldung/web/{BeanB.java => BeanC.java} (76%) create mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanC.java create mode 100644 spring-all/src/main/resources/persistence-mysql.properties diff --git a/spring-all/pom.xml b/spring-all/pom.xml index bcbd87440c54..546375faddca 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -37,7 +37,7 @@ org.hibernate hibernate-core - 4.2.1.Final + 4.2.2.Final org.javassist diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java index 32096c64c762..6eb2dadcf275 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java @@ -23,7 +23,7 @@ public void onStartup(final ServletContext sc) throws ServletException { // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.scan("org.baeldung.spring.web.config"); + root.scan("org.baeldung.spring.config"); // root.getEnvironment().setDefaultProfiles("embedded"); // Manages the lifecycle of the root application context diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java index 7a8a0d24d8ce..4848a3ad4676 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -1,16 +1,24 @@ package org.baeldung.web; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class BeanA { +public class BeanA implements InitializingBean { @Autowired - private IBeanB b; + private IBeanC dependency; public BeanA() { super(); } + // + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println(); + } + } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB1.java b/spring-all/src/main/java/org/baeldung/web/BeanB1.java new file mode 100644 index 000000000000..b72bce163170 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/BeanB1.java @@ -0,0 +1,12 @@ +package org.baeldung.web; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB1 implements IBeanB { + + public BeanB1() { + super(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB2.java b/spring-all/src/main/java/org/baeldung/web/BeanB2.java new file mode 100644 index 000000000000..232521fc0b5f --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/BeanB2.java @@ -0,0 +1,12 @@ +package org.baeldung.web; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB2 implements IBeanB { + + public BeanB2() { + super(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB.java b/spring-all/src/main/java/org/baeldung/web/BeanC.java similarity index 76% rename from spring-all/src/main/java/org/baeldung/web/BeanB.java rename to spring-all/src/main/java/org/baeldung/web/BeanC.java index 4078fe700089..1b571c1e77d6 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanC.java @@ -5,9 +5,9 @@ @Component @Transactional -public class BeanB implements IBeanB { +public class BeanC implements IBeanC { - public BeanB() { + public BeanC() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanC.java b/spring-all/src/main/java/org/baeldung/web/IBeanC.java new file mode 100644 index 000000000000..78adca4e72eb --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/IBeanC.java @@ -0,0 +1,5 @@ +package org.baeldung.web; + +public interface IBeanC { + // +} diff --git a/spring-all/src/main/resources/persistence-mysql.properties b/spring-all/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..8263b0d9accd --- /dev/null +++ b/spring-all/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 254d9e111826..7b8668cda10b 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -32,7 +32,7 @@ org.hibernate hibernate-core - 4.2.1.Final + 4.2.2.Final org.javassist @@ -157,7 +157,7 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE 1.7.5 @@ -169,7 +169,7 @@ 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 From 8555b95268f16e7d3156f775c953ecfb61cc6674 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 24 May 2013 23:32:25 +0300 Subject: [PATCH 085/796] bean work --- .../org/baeldung/spring/config/CoreConfig.java | 15 +++++++++++++++ .../org/baeldung/spring/config/WebConfig.java | 2 +- .../src/main/java/org/baeldung/web/BeanA.java | 6 +++--- .../src/main/java/org/baeldung/web/BeanC.java | 2 -- .../src/main/java/org/baeldung/web/BeanD.java | 9 +++++++++ .../src/main/java/org/baeldung/web/IBeanD.java | 5 +++++ spring-all/src/main/resources/beansInXml.xml | 9 +++++++++ 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/web/BeanD.java create mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanD.java create mode 100644 spring-all/src/main/resources/beansInXml.xml diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java new file mode 100644 index 000000000000..e202a779dbbe --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java @@ -0,0 +1,15 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ImportResource("classpath:beansInXml.xml") +public class CoreConfig extends WebMvcConfigurerAdapter { + + public CoreConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java index 640302a495c4..728a890e8f8e 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -14,6 +14,6 @@ public WebConfig() { super(); } - // API + } \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java index 4848a3ad4676..f773185bd130 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -1,14 +1,13 @@ package org.baeldung.web; import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class BeanA implements InitializingBean { - @Autowired - private IBeanC dependency; + // @Autowired + // private IBeanC dependency; public BeanA() { super(); @@ -19,6 +18,7 @@ public BeanA() { @Override public void afterPropertiesSet() throws Exception { System.out.println(); + // throw new NullPointerException(); } } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanC.java b/spring-all/src/main/java/org/baeldung/web/BeanC.java index 1b571c1e77d6..c57d30179ca1 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanC.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanC.java @@ -1,10 +1,8 @@ package org.baeldung.web; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; @Component -@Transactional public class BeanC implements IBeanC { public BeanC() { diff --git a/spring-all/src/main/java/org/baeldung/web/BeanD.java b/spring-all/src/main/java/org/baeldung/web/BeanD.java new file mode 100644 index 000000000000..f1b97b8977c3 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/BeanD.java @@ -0,0 +1,9 @@ +package org.baeldung.web; + +public abstract class BeanD implements IBeanD { + + public BeanD() { + super(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanD.java b/spring-all/src/main/java/org/baeldung/web/IBeanD.java new file mode 100644 index 000000000000..2b50038c71e0 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/IBeanD.java @@ -0,0 +1,5 @@ +package org.baeldung.web; + +public interface IBeanD { + // +} diff --git a/spring-all/src/main/resources/beansInXml.xml b/spring-all/src/main/resources/beansInXml.xml new file mode 100644 index 000000000000..26b55fc18321 --- /dev/null +++ b/spring-all/src/main/resources/beansInXml.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file From 94f9a60da1d8126b5c18639bce98fdcb85c7dfc6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 May 2013 00:03:27 +0300 Subject: [PATCH 086/796] bean work --- spring-all/src/main/java/org/baeldung/web/BeanA.java | 12 ++---------- .../java/org/baeldung/web/{BeanC.java => BeanB.java} | 4 ++-- .../org/baeldung/web/{BeanB1.java => BeanC1.java} | 4 ++-- .../org/baeldung/web/{BeanB2.java => BeanC2.java} | 4 ++-- spring-all/src/main/java/org/baeldung/web/BeanD.java | 5 ++++- spring-all/src/main/resources/beansInXml.xml | 4 +++- 6 files changed, 15 insertions(+), 18 deletions(-) rename spring-all/src/main/java/org/baeldung/web/{BeanC.java => BeanB.java} (65%) rename spring-all/src/main/java/org/baeldung/web/{BeanB1.java => BeanC1.java} (64%) rename spring-all/src/main/java/org/baeldung/web/{BeanB2.java => BeanC2.java} (64%) diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java index f773185bd130..19f1fd20230a 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -1,13 +1,11 @@ package org.baeldung.web; -import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; @Component -public class BeanA implements InitializingBean { +public class BeanA { - // @Autowired - // private IBeanC dependency; + private IBeanC dependency; public BeanA() { super(); @@ -15,10 +13,4 @@ public BeanA() { // - @Override - public void afterPropertiesSet() throws Exception { - System.out.println(); - // throw new NullPointerException(); - } - } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanC.java b/spring-all/src/main/java/org/baeldung/web/BeanB.java similarity index 65% rename from spring-all/src/main/java/org/baeldung/web/BeanC.java rename to spring-all/src/main/java/org/baeldung/web/BeanB.java index c57d30179ca1..4dd6a2fc7e36 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanC.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanB.java @@ -3,9 +3,9 @@ import org.springframework.stereotype.Component; @Component -public class BeanC implements IBeanC { +public class BeanB implements IBeanB { - public BeanC() { + public BeanB() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB1.java b/spring-all/src/main/java/org/baeldung/web/BeanC1.java similarity index 64% rename from spring-all/src/main/java/org/baeldung/web/BeanB1.java rename to spring-all/src/main/java/org/baeldung/web/BeanC1.java index b72bce163170..cb3c845a0258 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB1.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanC1.java @@ -3,9 +3,9 @@ import org.springframework.stereotype.Component; @Component -public class BeanB1 implements IBeanB { +public class BeanC1 implements IBeanC { - public BeanB1() { + public BeanC1() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB2.java b/spring-all/src/main/java/org/baeldung/web/BeanC2.java similarity index 64% rename from spring-all/src/main/java/org/baeldung/web/BeanB2.java rename to spring-all/src/main/java/org/baeldung/web/BeanC2.java index 232521fc0b5f..f914384518a4 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB2.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanC2.java @@ -3,9 +3,9 @@ import org.springframework.stereotype.Component; @Component -public class BeanB2 implements IBeanB { +public class BeanC2 implements IBeanB { - public BeanB2() { + public BeanC2() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanD.java b/spring-all/src/main/java/org/baeldung/web/BeanD.java index f1b97b8977c3..04488238e533 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanD.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanD.java @@ -1,6 +1,9 @@ package org.baeldung.web; -public abstract class BeanD implements IBeanD { +import org.springframework.stereotype.Component; + +@Component +public class BeanD implements IBeanD { public BeanD() { super(); diff --git a/spring-all/src/main/resources/beansInXml.xml b/spring-all/src/main/resources/beansInXml.xml index 26b55fc18321..81ad0a9ecda9 100644 --- a/spring-all/src/main/resources/beansInXml.xml +++ b/spring-all/src/main/resources/beansInXml.xml @@ -4,6 +4,8 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> - + + + \ No newline at end of file From 343a7432298a07be428ba3fb42434ed43606cbce Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 May 2013 01:10:44 +0300 Subject: [PATCH 087/796] bean work --- .../org/baeldung/spring/config/PersistenceConfig.java | 3 +-- .../main/java/org/baeldung/spring/config/WebConfig.java | 7 +++++-- spring-all/src/main/java/org/baeldung/web/BeanA.java | 6 ++---- spring-all/src/main/java/org/baeldung/web/BeanB.java | 8 +++++++- spring-all/src/main/java/org/baeldung/web/BeanC2.java | 2 +- spring-all/src/main/java/org/baeldung/web/IBeanA.java | 5 +++++ spring-all/src/main/resources/beansInXml.xml | 4 +--- 7 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanA.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 078d7e6f88bc..4bc4739ccdb7 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -18,7 +17,7 @@ import com.google.common.base.Preconditions; -@Configuration +// @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) diff --git a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java index 728a890e8f8e..c69ef21b0c24 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -1,5 +1,7 @@ package org.baeldung.spring.config; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -10,10 +12,11 @@ @ComponentScan("org.baeldung.web") public class WebConfig extends WebMvcConfigurerAdapter { + @Autowired + BeanFactory beanFactory; + public WebConfig() { super(); } - - } \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java index 19f1fd20230a..96cc715ec78c 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanA.java @@ -1,16 +1,14 @@ package org.baeldung.web; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; @Component +@Transactional public class BeanA { - private IBeanC dependency; - public BeanA() { super(); } - // - } diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB.java b/spring-all/src/main/java/org/baeldung/web/BeanB.java index 4dd6a2fc7e36..53a3ef0b2f64 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanB.java @@ -1,9 +1,15 @@ package org.baeldung.web; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; @Component -public class BeanB implements IBeanB { +@Transactional +public class BeanB { + + @Autowired + private BeanA beanA; public BeanB() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/BeanC2.java b/spring-all/src/main/java/org/baeldung/web/BeanC2.java index f914384518a4..ed38a809cf5f 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanC2.java +++ b/spring-all/src/main/java/org/baeldung/web/BeanC2.java @@ -3,7 +3,7 @@ import org.springframework.stereotype.Component; @Component -public class BeanC2 implements IBeanB { +public class BeanC2 implements IBeanC { public BeanC2() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanA.java b/spring-all/src/main/java/org/baeldung/web/IBeanA.java new file mode 100644 index 000000000000..91d770ce73d3 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/IBeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.web; + +public interface IBeanA { + // +} diff --git a/spring-all/src/main/resources/beansInXml.xml b/spring-all/src/main/resources/beansInXml.xml index 81ad0a9ecda9..9cd3282179bd 100644 --- a/spring-all/src/main/resources/beansInXml.xml +++ b/spring-all/src/main/resources/beansInXml.xml @@ -4,8 +4,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> - - - + \ No newline at end of file From f5990cb42b0b507e9c20c081012c94b3348acadb Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 May 2013 01:14:38 +0300 Subject: [PATCH 088/796] bean work --- .../src/main/java/org/baeldung/web/BeanA.java | 14 -------- .../web/{IBeanA.java => IServiceA.java} | 2 +- .../main/java/org/baeldung/web/ServiceA.java | 24 ++++++++++++++ .../web/{BeanB.java => ServiceB.java} | 16 +++++++--- .../src/main/java/org/baeldung/web/Setup.java | 32 +++++++++++++++++++ 5 files changed, 68 insertions(+), 20 deletions(-) delete mode 100644 spring-all/src/main/java/org/baeldung/web/BeanA.java rename spring-all/src/main/java/org/baeldung/web/{IBeanA.java => IServiceA.java} (55%) create mode 100644 spring-all/src/main/java/org/baeldung/web/ServiceA.java rename spring-all/src/main/java/org/baeldung/web/{BeanB.java => ServiceB.java} (50%) create mode 100644 spring-all/src/main/java/org/baeldung/web/Setup.java diff --git a/spring-all/src/main/java/org/baeldung/web/BeanA.java b/spring-all/src/main/java/org/baeldung/web/BeanA.java deleted file mode 100644 index 96cc715ec78c..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/BeanA.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.web; - -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -@Transactional -public class BeanA { - - public BeanA() { - super(); - } - -} diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanA.java b/spring-all/src/main/java/org/baeldung/web/IServiceA.java similarity index 55% rename from spring-all/src/main/java/org/baeldung/web/IBeanA.java rename to spring-all/src/main/java/org/baeldung/web/IServiceA.java index 91d770ce73d3..0461d5293ff8 100644 --- a/spring-all/src/main/java/org/baeldung/web/IBeanA.java +++ b/spring-all/src/main/java/org/baeldung/web/IServiceA.java @@ -1,5 +1,5 @@ package org.baeldung.web; -public interface IBeanA { +public interface IServiceA { // } diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceA.java b/spring-all/src/main/java/org/baeldung/web/ServiceA.java new file mode 100644 index 000000000000..47afde94c889 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/ServiceA.java @@ -0,0 +1,24 @@ +package org.baeldung.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class ServiceA implements IServiceA { + + @Autowired + private ServiceB serviceB; + + public ServiceA() { + super(); + } + + // + + public void testA() { + System.out.println(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanB.java b/spring-all/src/main/java/org/baeldung/web/ServiceB.java similarity index 50% rename from spring-all/src/main/java/org/baeldung/web/BeanB.java rename to spring-all/src/main/java/org/baeldung/web/ServiceB.java index 53a3ef0b2f64..65b4215cc407 100644 --- a/spring-all/src/main/java/org/baeldung/web/BeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/ServiceB.java @@ -1,18 +1,24 @@ package org.baeldung.web; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -@Component +@Service @Transactional -public class BeanB { +public class ServiceB { @Autowired - private BeanA beanA; + private IServiceA serviceA; - public BeanB() { + public ServiceB() { super(); } + // + + public void testB() { + System.out.println(); + } + } diff --git a/spring-all/src/main/java/org/baeldung/web/Setup.java b/spring-all/src/main/java/org/baeldung/web/Setup.java new file mode 100644 index 000000000000..653609e006da --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/web/Setup.java @@ -0,0 +1,32 @@ +package org.baeldung.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; + +@Component +public class Setup implements ApplicationListener { + + private boolean setupDone; + + @Autowired + IServiceA serviceA; + + @Autowired + ServiceB serviceB; + + public Setup() { + super(); + } + + // + + @Override + public final void onApplicationEvent(final ContextRefreshedEvent event) { + if (!setupDone) { + // + } + } + +} From 59bd37ec1040f08cd3ecb866137964a0feb47b1f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 May 2013 15:59:25 +0300 Subject: [PATCH 089/796] bean work --- .../org/baeldung/spring/config/PersistenceConfig.java | 3 ++- .../org/baeldung/web/{IBeanB.java => IServiceB.java} | 2 +- .../src/main/java/org/baeldung/web/ServiceA.java | 6 ++---- .../src/main/java/org/baeldung/web/ServiceB.java | 6 +----- spring-all/src/main/java/org/baeldung/web/Setup.java | 10 +++++----- 5 files changed, 11 insertions(+), 16 deletions(-) rename spring-all/src/main/java/org/baeldung/web/{IBeanB.java => IServiceB.java} (55%) diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 4bc4739ccdb7..078d7e6f88bc 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -17,7 +18,7 @@ import com.google.common.base.Preconditions; -// @Configuration +@Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanB.java b/spring-all/src/main/java/org/baeldung/web/IServiceB.java similarity index 55% rename from spring-all/src/main/java/org/baeldung/web/IBeanB.java rename to spring-all/src/main/java/org/baeldung/web/IServiceB.java index 63357980adc8..faf048cde5f0 100644 --- a/spring-all/src/main/java/org/baeldung/web/IBeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/IServiceB.java @@ -1,5 +1,5 @@ package org.baeldung.web; -public interface IBeanB { +public interface IServiceB { // } diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceA.java b/spring-all/src/main/java/org/baeldung/web/ServiceA.java index 47afde94c889..deee4c6e5580 100644 --- a/spring-all/src/main/java/org/baeldung/web/ServiceA.java +++ b/spring-all/src/main/java/org/baeldung/web/ServiceA.java @@ -6,12 +6,10 @@ @Service @Transactional -public class ServiceA implements IServiceA { +public class ServiceA { @Autowired - private ServiceB serviceB; - - public ServiceA() { + public ServiceA(final IServiceB serviceB) { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceB.java b/spring-all/src/main/java/org/baeldung/web/ServiceB.java index 65b4215cc407..48ff0f264829 100644 --- a/spring-all/src/main/java/org/baeldung/web/ServiceB.java +++ b/spring-all/src/main/java/org/baeldung/web/ServiceB.java @@ -1,15 +1,11 @@ package org.baeldung.web; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional -public class ServiceB { - - @Autowired - private IServiceA serviceA; +public class ServiceB implements IServiceB { public ServiceB() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/Setup.java b/spring-all/src/main/java/org/baeldung/web/Setup.java index 653609e006da..f04135d807f6 100644 --- a/spring-all/src/main/java/org/baeldung/web/Setup.java +++ b/spring-all/src/main/java/org/baeldung/web/Setup.java @@ -3,18 +3,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.stereotype.Component; -@Component +// @Component public class Setup implements ApplicationListener { private boolean setupDone; @Autowired - IServiceA serviceA; + ServiceA serviceA; @Autowired - ServiceB serviceB; + IServiceB serviceB; public Setup() { super(); @@ -25,7 +24,8 @@ public Setup() { @Override public final void onApplicationEvent(final ContextRefreshedEvent event) { if (!setupDone) { - // + System.out.println(); + setupDone = true; } } From a57fec094aa39dc386532804b1c0e12a9ade0cd1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 26 May 2013 18:42:50 +0300 Subject: [PATCH 090/796] spring rest work --- spring-security-rest/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-rest/.gitignore | 13 ++ spring-security-rest/.project | 59 ++++++ spring-security-rest/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 +++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-rest/.springBeans | 14 ++ spring-security-rest/README.md | 3 + spring-security-rest/pom.xml | 192 ++++++++++++++++++ .../security/CustomLogoutSuccessHandler.java | 29 +++ .../spring/web/config/ClientWebConfig.java | 42 ++++ .../spring/web/config/SecSecurityConfig.java | 14 ++ .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 41 ++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../main/webapp/WEB-INF/view/anonymous.jsp | 10 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 9 + .../src/main/webapp/WEB-INF/view/login.jsp | 26 +++ .../src/main/webapp/WEB-INF/web.xml | 52 +++++ .../src/test/resources/.gitignore | 13 ++ 29 files changed, 775 insertions(+) create mode 100644 spring-security-rest/.classpath create mode 100644 spring-security-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-rest/.gitignore create mode 100644 spring-security-rest/.project create mode 100644 spring-security-rest/.settings/.jsdtscope create mode 100644 spring-security-rest/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-rest/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-rest/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-rest/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-rest/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-rest/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-rest/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-rest/.springBeans create mode 100644 spring-security-rest/README.md create mode 100644 spring-security-rest/pom.xml create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java create mode 100644 spring-security-rest/src/main/resources/logback.xml create mode 100644 spring-security-rest/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp create mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-rest/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-rest/src/test/resources/.gitignore diff --git a/spring-security-rest/.classpath b/spring-security-rest/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-rest/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest/.gitignore b/spring-security-rest/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest/.project b/spring-security-rest/.project new file mode 100644 index 000000000000..67be91451e64 --- /dev/null +++ b/spring-security-rest/.project @@ -0,0 +1,59 @@ + + + spring-security-rest + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-security-rest/.settings/.jsdtscope b/spring-security-rest/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-rest/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-rest/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-rest/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-rest/.settings/org.eclipse.wst.common.component b/spring-security-rest/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..6782a0c5c740 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-rest/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-rest/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-rest/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-rest/.springBeans b/spring-security-rest/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-rest/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md new file mode 100644 index 000000000000..7cc97242ec04 --- /dev/null +++ b/spring-security-rest/README.md @@ -0,0 +1,3 @@ +Spring Security Login +========= + diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml new file mode 100644 index 000000000000..9b5cfbdace28 --- /dev/null +++ b/spring-security-rest/pom.xml @@ -0,0 +1,192 @@ + + 4.0.0 + org.baeldung + spring-security-rest + 0.1-SNAPSHOT + + spring-security-rest + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + + \ No newline at end of file diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java b/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java new file mode 100644 index 000000000000..4d19744033d0 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java @@ -0,0 +1,29 @@ +package org.baeldung.spring.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; +import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; + +public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler { + + public CustomLogoutSuccessHandler() { + super(); + } + + // API + + @Override + public void onLogoutSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { + final String refererUrl = request.getHeader("Referer"); + System.out.println(refererUrl); + + super.onLogoutSuccess(request, response, authentication); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..316759b24b3a --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,42 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/anonymous.html"); + + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java new file mode 100644 index 000000000000..65a571c71589 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-rest/src/main/resources/logback.xml b/spring-security-rest/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-rest/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..e2b63fe45820 --- /dev/null +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp new file mode 100644 index 000000000000..d4e9c0289b29 --- /dev/null +++ b/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Anonymous page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..5504d2f134ee --- /dev/null +++ b/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,9 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

This is the body of the sample view

+ ">Logout + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..013ceccb4e4d --- /dev/null +++ b/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,26 @@ + + + + +

Login

+ +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+ + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..6274cdd9fe95 --- /dev/null +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-rest/src/test/resources/.gitignore b/spring-security-rest/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 9ca6724a17a7e829af232cdf414769cbfe131d84 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 26 May 2013 18:44:06 +0300 Subject: [PATCH 091/796] minor cleanup --- .../spring/web/config/SecSecurityConfig.java | 6 +- .../src/main/webapp/WEB-INF/web.xml | 78 +++++++++---------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java index 65a571c71589..a21a05c17d2d 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java @@ -7,8 +7,8 @@ @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecSecurityConfig { - public SecSecurityConfig() { - super(); - } + public SecSecurityConfig() { + super(); + } } diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index 6274cdd9fe95..aa8d47fe8680 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -1,52 +1,50 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.web.config - + + + contextConfigLocation + org.baeldung.spring.web.config + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file From 74bafb99a9e7325cad578171e96713f3e17977ee Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 26 May 2013 18:51:36 +0300 Subject: [PATCH 092/796] security work --- .../{web => }/config/ClientWebConfig.java | 2 +- .../{web => }/config/SecSecurityConfig.java | 4 +- .../security/CustomLogoutSuccessHandler.java | 29 --------- ...uestAwareAuthenticationSuccessHandler.java | 48 ++++++++++++++ .../RestAuthenticationEntryPoint.java | 19 ++++++ .../src/main/resources/webSecurityConfig.xml | 62 ++++++++----------- .../src/main/webapp/WEB-INF/web.xml | 2 +- 7 files changed, 99 insertions(+), 67 deletions(-) rename spring-security-rest/src/main/java/org/baeldung/spring/{web => }/config/ClientWebConfig.java (96%) rename spring-security-rest/src/main/java/org/baeldung/spring/{web => }/config/SecSecurityConfig.java (66%) delete mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java similarity index 96% rename from spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java index 316759b24b3a..d0c33bd135ca 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java similarity index 66% rename from spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java rename to spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java index a21a05c17d2d..d38c304d9a7c 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java @@ -1,10 +1,12 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.spring.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java b/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java deleted file mode 100644 index 4d19744033d0..000000000000 --- a/spring-security-rest/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.spring.security; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; - -public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler { - - public CustomLogoutSuccessHandler() { - super(); - } - - // API - - @Override - public void onLogoutSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { - final String refererUrl = request.getHeader("Referer"); - System.out.println(refererUrl); - - super.onLogoutSuccess(request, response, authentication); - } - -} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..82272292de37 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -0,0 +1,48 @@ +package org.baeldung.spring.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; + +public class MySavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + private RequestCache requestCache = new HttpSessionRequestCache(); + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws ServletException, IOException { + final SavedRequest savedRequest = requestCache.getRequest(request, response); + + if (savedRequest == null) { + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + final String targetUrlParameter = getTargetUrlParameter(); + if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { + requestCache.removeRequest(request, response); + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + + clearAuthenticationAttributes(request); + + // Use the DefaultSavedRequest URL + // final String targetUrl = savedRequest.getRedirectUrl(); + // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); + // getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + public void setRequestCache(final RequestCache requestCache) { + this.requestCache = requestCache; + } +} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java b/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java new file mode 100644 index 000000000000..53f2a736e0a5 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } +} \ No newline at end of file diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index e2b63fe45820..b40b5390ba74 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -1,41 +1,33 @@ - + - - - - - - - - + + - - - - - - - + - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index aa8d47fe8680..3238896d4aa7 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -15,7 +15,7 @@ contextConfigLocation - org.baeldung.spring.web.config + org.baeldung.spring.config From 3572f7ecd53bb0b82d7fdb19bf13d04803ea6d5f Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 27 May 2013 00:25:50 +0300 Subject: [PATCH 093/796] security work --- spring-security-rest/.springBeans | 2 +- .../spring/config/ClientWebConfig.java | 25 ------------------ .../RestAuthenticationEntryPoint.java | 4 +++ .../src/main/resources/webSecurityConfig.xml | 4 +-- .../{mvc-servlet.xml => api-servlet.xml} | 0 .../main/webapp/WEB-INF/view/anonymous.jsp | 10 ------- .../src/main/webapp/WEB-INF/view/homepage.jsp | 9 ------- .../src/main/webapp/WEB-INF/view/login.jsp | 26 ------------------- .../src/main/webapp/WEB-INF/web.xml | 6 ++--- 9 files changed, 10 insertions(+), 76 deletions(-) rename spring-security-rest/src/main/webapp/WEB-INF/{mvc-servlet.xml => api-servlet.xml} (100%) delete mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp delete mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-rest/.springBeans b/spring-security-rest/.springBeans index 7623a7e88836..d11fb034bdc0 100644 --- a/spring-security-rest/.springBeans +++ b/spring-security-rest/.springBeans @@ -7,7 +7,7 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml + src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java index d0c33bd135ca..1a87fd8a09d7 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java @@ -1,13 +1,8 @@ package org.baeldung.spring.config; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; @EnableWebMvc @Configuration @@ -19,24 +14,4 @@ public ClientWebConfig() { // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/anonymous.html"); - - registry.addViewController("/login.html"); - registry.addViewController("/homepage.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } } \ No newline at end of file diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java b/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java index 53f2a736e0a5..9e6f4da1e084 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java @@ -9,6 +9,9 @@ import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; +/** + * The Entry Point will not redirect to any sort of Login - it will return the 401 + */ @Component public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { @@ -16,4 +19,5 @@ public final class RestAuthenticationEntryPoint implements AuthenticationEntryPo public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } + } \ No newline at end of file diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index b40b5390ba74..a0aeae9e6ae6 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -7,8 +7,8 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - + + diff --git a/spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-security-rest/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp deleted file mode 100644 index d4e9c0289b29..000000000000 --- a/spring-security-rest/src/main/webapp/WEB-INF/view/anonymous.jsp +++ /dev/null @@ -1,10 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - -

Anonymous page

- - ">To Login - - \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index 5504d2f134ee..000000000000 --- a/spring-security-rest/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,9 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - -

This is the body of the sample view

- ">Logout - - \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 013ceccb4e4d..000000000000 --- a/spring-security-rest/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,26 +0,0 @@ - - - - -

Login

- -
- - - - - - - - - - - - - -
User:
Password:
- -
- - - \ No newline at end of file diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index 3238896d4aa7..d7e554666d10 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -24,13 +24,13 @@ - mvc + api org.springframework.web.servlet.DispatcherServlet 1 - mvc - / + api + /api/* From f9604dec46f3d1938644b97c5956f3b2748a8377 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 27 May 2013 01:11:29 +0300 Subject: [PATCH 094/796] config work --- .../src/main/resources/webSecurityConfig.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index a0aeae9e6ae6..ebb73828c462 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -10,15 +10,11 @@ - + - - - - From 3f1a9ae5e1d25181c5c6efb2341d1d0484e43efd Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 12:25:46 +0300 Subject: [PATCH 095/796] minor doc work --- spring-all/README.md | 7 +++++-- spring-hibernate3/README.md | 14 +++++++++++++- spring-hibernate4/README.md | 14 +++++++++++++- spring-mvc/README.md | 5 ++++- spring-security-basic-auth/README.md | 4 +++- spring-security-login/README.md | 6 +++++- 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/spring-all/README.md b/spring-all/README.md index 1abc096086ed..d3e07f338d80 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -1,3 +1,6 @@ -[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) ========= - +This project is used to replicate Spring Exceptions only. +Relevant articles: +- [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) +- [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) +- [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) diff --git a/spring-hibernate3/README.md b/spring-hibernate3/README.md index 89dd04db8206..6dcc602ef07d 100644 --- a/spring-hibernate3/README.md +++ b/spring-hibernate3/README.md @@ -1,3 +1,15 @@ -Hibernate 3 with Spring ========= +Relevant Article: +- [Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) + + +Quick Start + +``` +git clone git://github.com/eugenp/REST.git +cd REST +mvn install +mvn cargo:run +``` +- note: starts on port 8082 diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index 12eb079c88b1..3c48826a2a4d 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -1,3 +1,15 @@ -Hibernate 4 with Spring ========= +Relevant Article: +- [Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring) + + +Quick Start + +``` +git clone git://github.com/eugenp/REST.git +cd REST +mvn install +mvn cargo:run +``` +- note: starts on port 8082 diff --git a/spring-mvc/README.md b/spring-mvc/README.md index 1abc096086ed..857e0007da57 100644 --- a/spring-mvc/README.md +++ b/spring-mvc/README.md @@ -1,3 +1,6 @@ -[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) ========= +Relevant Articles: +- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) + + diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md index 7cc97242ec04..d013b51e1807 100644 --- a/spring-security-basic-auth/README.md +++ b/spring-security-basic-auth/README.md @@ -1,3 +1,5 @@ -Spring Security Login ========= +Relevant Article: +- [Spring Security – security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) + diff --git a/spring-security-login/README.md b/spring-security-login/README.md index 7cc97242ec04..3fc9941d1edf 100644 --- a/spring-security-login/README.md +++ b/spring-security-login/README.md @@ -1,3 +1,7 @@ -Spring Security Login ========= +Relevant Articles: +- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) +- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) + + From 1515377c48050f1c3325e93047d8da148c755ca8 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 12:29:35 +0300 Subject: [PATCH 096/796] minor doc work --- spring-jpa/README.md | 4 +++- spring-mvc-xml/README.md | 4 +++- spring-security-rest/README.md | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index 12eb079c88b1..7f5cdda2e232 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -1,3 +1,5 @@ -Hibernate 4 with Spring +JPA with Spring ========= +Relevant Articles: +- \ No newline at end of file diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 1abc096086ed..b67f11e4e7aa 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,3 +1,5 @@ -[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) +Spring MVC Tutorial ========= +Relevant Articles: +- \ No newline at end of file diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index 7cc97242ec04..a7dd66cfbadc 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -1,3 +1,5 @@ -Spring Security Login +Spring Security for REST ========= +Relevant Articles: +- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file From 66f6623c28829f5c50b8e7fe2763d763bf1b0dc0 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:07:51 +0300 Subject: [PATCH 097/796] rest security work --- ...edRequestAwareAuthenticationSuccessHandler.java | 2 +- .../security/RestAuthenticationEntryPoint.java | 2 +- .../baeldung/spring/config/SecSecurityConfig.java | 2 +- .../java/org/baeldung/spring/config/WebConfig.java | 14 ++++++++++++++ .../org/baeldung/web/controller/FooController.java | 8 ++++++++ .../src/main/java/org/baeldung/web/dto/Foo.java | 5 +++++ .../src/main/resources/webSecurityConfig.xml | 2 +- 7 files changed, 31 insertions(+), 4 deletions(-) rename spring-security-rest/src/main/java/org/baeldung/{spring => }/security/MySavedRequestAwareAuthenticationSuccessHandler.java (98%) rename spring-security-rest/src/main/java/org/baeldung/{spring => }/security/RestAuthenticationEntryPoint.java (95%) create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java similarity index 98% rename from spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java rename to spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java index 82272292de37..698052fa2b00 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/security/MySavedRequestAwareAuthenticationSuccessHandler.java +++ b/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.security; +package org.baeldung.security; import java.io.IOException; diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java b/spring-security-rest/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java similarity index 95% rename from spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java rename to spring-security-rest/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java index 9e6f4da1e084..77aa32ff979e 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/security/RestAuthenticationEntryPoint.java +++ b/spring-security-rest/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.security; +package org.baeldung.security; import java.io.IOException; diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java index d38c304d9a7c..8d5dfb04092e 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java @@ -6,7 +6,7 @@ @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.spring.security") +@ComponentScan("org.baeldung.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java new file mode 100644 index 000000000000..33efc93b2b44 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig { + + public WebConfig() { + super(); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..e4507df59c68 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,8 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; + +@Controller +public class FooController { + // +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..cb12846cd751 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,5 @@ +package org.baeldung.web.dto; + +public class Foo { + +} diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index ebb73828c462..d3f8f6cfaf03 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -15,7 +15,7 @@
- + From 279ccd2a5526eb6e904b07cd93b6c2a95d9fadbc Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:17:23 +0300 Subject: [PATCH 098/796] security and rest work --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- spring-security-rest/pom.xml | 8 ++++ .../persistence/service/FooService.java | 23 ++++++++++ .../spring/config/PersistenceConfig.java | 14 ++++++ .../web/controller/FooController.java | 44 ++++++++++++++++++- .../web/controller/ResourceCreated.java | 35 +++++++++++++++ .../controller/SingleResourceRetrieved.java | 29 ++++++++++++ 7 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java diff --git a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..df8135651462 100644 --- a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs @@ -42,7 +42,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 9b5cfbdace28..8c41c2fece39 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -88,6 +88,14 @@ runtime
+ + + + com.google.guava + guava + 14.0.1 + + diff --git a/spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..02db7a733a6b --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,23 @@ +package org.baeldung.persistence.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public FooService() { + super(); + } + + // API + + public Foo getById(final Long id) { + return null; + } + + public Long create(final Foo resource) { + return null; + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java new file mode 100644 index 000000000000..913c5d26ceb9 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.persistence") +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java index e4507df59c68..ce3b59e82528 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,8 +1,50 @@ package org.baeldung.web.controller; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.service.FooService; +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import com.google.common.base.Preconditions; @Controller public class FooController { - // + + @Autowired + private FooService service; + + @Autowired + private ApplicationEventPublisher eventPublisher; + + // API + + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + } diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java new file mode 100644 index 000000000000..9baa0e2df823 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfCreatedResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfCreatedResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfCreatedResource = idOfCreatedResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfCreatedResource() { + return idOfCreatedResource; + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java new file mode 100644 index 000000000000..3de791810549 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java @@ -0,0 +1,29 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + +} From 8b409e07a60175ca5cce62808baf56f0168c8943 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:30:54 +0300 Subject: [PATCH 099/796] discoverability work --- .../web/controller/ResourceCreated.java | 10 +++--- ...esourceCreatedDiscoverabilityListener.java | 35 +++++++++++++++++++ ...ourceRetrievedDiscoverabilityListener.java | 32 +++++++++++++++++ 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java index 9baa0e2df823..a67788810161 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -8,14 +8,14 @@ public class ResourceCreated extends ApplicationEvent { private final HttpServletResponse response; private final HttpServletRequest request; - private final long idOfCreatedResource; + private final long idOfNewResource; - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfCreatedResource) { + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { super(source); this.request = request; this.response = response; - this.idOfCreatedResource = idOfCreatedResource; + this.idOfNewResource = idOfNewResource; } // API @@ -28,8 +28,8 @@ public HttpServletRequest getRequest() { return request; } - public long getIdOfCreatedResource() { - return idOfCreatedResource; + public long getIdOfNewResource() { + return idOfNewResource; } } diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 000000000000..8d19ef82fc63 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletRequest request = resourceCreatedEvent.getRequest(); + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(request, response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + final String requestUrl = request.getRequestURL().toString(); + final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..b7384b0196b3 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,32 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletRequest request = resourceRetrievedEvent.getRequest(); + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(request, response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { + final StringBuffer requestURL = request.getRequestURL(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + // final String linkHeaderValue = RESTURLUtil.createLinkHeader(uriForResourceCreation, "collection"); + // response.addHeader(LINK_HEADER, linkHeaderValue); + } + +} \ No newline at end of file From 6ffd867e1194423d612101c6a092f2a6a604a06d Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:37:20 +0300 Subject: [PATCH 100/796] rest discoverability work --- .../web/controller/FooController.java | 13 ++++++++ .../org/baeldung/web/controller/LinkUtil.java | 30 +++++++++++++++++++ ...ourceRetrievedDiscoverabilityListener.java | 4 +-- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java index ce3b59e82528..8768796e293b 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,5 +1,7 @@ package org.baeldung.web.controller; +import java.net.URI; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriTemplate; import com.google.common.base.Preconditions; @@ -47,4 +50,14 @@ public void create(@RequestBody final Foo resource, final HttpServletRequest req eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); } + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } + } diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java new file mode 100644 index 000000000000..a41ebb5a5cdd --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java index b7384b0196b3..45cd7c4d131a 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -25,8 +25,8 @@ void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, fi final int positionOfLastSlash = requestURL.lastIndexOf("/"); final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); - // final String linkHeaderValue = RESTURLUtil.createLinkHeader(uriForResourceCreation, "collection"); - // response.addHeader(LINK_HEADER, linkHeaderValue); + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader("Link", linkHeaderValue); } } \ No newline at end of file From af424e266b573ce23bfa8fb382269f3a354ee133 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:45:19 +0300 Subject: [PATCH 101/796] security cleanup --- .../{web => }/config/FrontendConfig.java | 36 +++++++++---------- .../{web => }/config/SecSecurityConfig.java | 8 ++--- .../spring/{web => }/config/WebConfig.java | 10 +++--- .../spring/web/controller/TestController.java | 28 --------------- .../web/controller/FooController.java | 4 +-- .../web/controller/TestController.java | 28 +++++++++++++++ .../baeldung/{spring/web => web/dto}/Foo.java | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- 8 files changed, 59 insertions(+), 59 deletions(-) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{web => }/config/FrontendConfig.java (52%) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{web => }/config/SecSecurityConfig.java (71%) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{web => }/config/WebConfig.java (77%) delete mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java rename spring-security-basic-auth/src/main/java/org/baeldung/{spring => }/web/controller/FooController.java (90%) create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/web/controller/TestController.java rename spring-security-basic-auth/src/main/java/org/baeldung/{spring/web => web/dto}/Foo.java (78%) diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java similarity index 52% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java index ffcc855716da..693b1006b5ce 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/FrontendConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,27 +13,27 @@ @Configuration public class FrontendConfig extends WebMvcConfigurerAdapter { - public FrontendConfig() { - super(); - } + public FrontendConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/homepage.html"); - } + registry.addViewController("/homepage.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java similarity index 71% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java index 65a571c71589..a8b4962672b1 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @@ -7,8 +7,8 @@ @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecSecurityConfig { - public SecSecurityConfig() { - super(); - } + public SecSecurityConfig() { + super(); + } } diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java similarity index 77% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java index 9a79aa3b6b29..c6d3aa896b77 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/config/WebConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -8,10 +8,10 @@ @ComponentScan("org.baeldung.spring.web.controller") public class WebConfig extends WebMvcConfigurerAdapter { - public WebConfig() { - super(); - } + public WebConfig() { + super(); + } - // API + // API } \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java deleted file mode 100644 index c7b04c14d2a4..000000000000 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.spring.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class TestController { - - public TestController() { - super(); - } - - // API - - @RequestMapping("/permitAll") - @ResponseBody - public String permitAll() { - return "Permit All"; - } - - @RequestMapping("/securityNone") - @ResponseBody - public String securityNone() { - return "Security None"; - } - -} diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java similarity index 90% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java index eb0575f279a8..a80ab832b3f5 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,8 +1,8 @@ -package org.baeldung.spring.web.controller; +package org.baeldung.web.controller; import javax.servlet.http.HttpServletResponse; -import org.baeldung.spring.web.Foo; +import org.baeldung.web.dto.Foo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/TestController.java new file mode 100644 index 000000000000..f68cfb2eb7dc --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/dto/Foo.java similarity index 78% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/dto/Foo.java index a5e46bc8e545..352045989daa 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/web/Foo.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/web/dto/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web; +package org.baeldung.web.dto; import java.io.Serializable; diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index d3f8f6cfaf03..f53b15752c57 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -21,7 +21,7 @@ - + From b0692e8ef3eeda3121a442b8971804b51ad53a6f Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:47:41 +0300 Subject: [PATCH 102/796] overall cleanup --- spring-security-basic-auth/pom.xml | 8 +++ .../persistence/service/FooService.java | 0 .../web/controller/FooController.java | 45 +++++++++++++ .../org/baeldung/web/controller/LinkUtil.java | 0 .../web/controller/ResourceCreated.java | 0 ...esourceCreatedDiscoverabilityListener.java | 0 .../controller/SingleResourceRetrieved.java | 0 ...ourceRetrievedDiscoverabilityListener.java | 0 .../web/controller/FooController.java | 63 ------------------- .../main/java/org/baeldung/web/dto/Foo.java | 5 -- 10 files changed, 53 insertions(+), 68 deletions(-) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/persistence/service/FooService.java (100%) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/web/controller/LinkUtil.java (100%) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/web/controller/ResourceCreated.java (100%) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java (100%) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java (100%) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java (100%) delete mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java delete mode 100644 spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 4b114f1435dd..9a9c7f05278e 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -88,6 +88,14 @@ runtime + + + + com.google.guava + guava + 14.0.1 + + diff --git a/spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-basic-auth/src/main/java/org/baeldung/persistence/service/FooService.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/persistence/service/FooService.java rename to spring-security-basic-auth/src/main/java/org/baeldung/persistence/service/FooService.java diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java index a80ab832b3f5..daa797ee368e 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,19 +1,37 @@ package org.baeldung.web.controller; +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.baeldung.persistence.service.FooService; import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; @Controller @RequestMapping(value = "/foo") public class FooController { + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private FooService service; + public FooController() { super(); } @@ -26,4 +44,31 @@ public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder return new Foo(); } + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } } diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/LinkUtil.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreated.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-basic-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java rename to spring-security-basic-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java deleted file mode 100644 index 8768796e293b..000000000000 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.baeldung.persistence.service.FooService; -import org.baeldung.web.dto.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; - -@Controller -public class FooController { - - @Autowired - private FooService service; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - // API - - @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); - - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); - return resourceById; - } - - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { - Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource); - - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); - } - - @RequestMapping(value = "admin", method = RequestMethod.GET) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { - final String rootUri = request.getRequestURL().toString(); - - final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); - final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); - response.addHeader("Link", linkToFoo); - } - -} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java deleted file mode 100644 index cb12846cd751..000000000000 --- a/spring-security-rest/src/main/java/org/baeldung/web/dto/Foo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.web.dto; - -public class Foo { - -} From 2a64bb227a5bac21b25fec81be664d91e4c07ed2 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 27 May 2013 18:49:58 +0300 Subject: [PATCH 103/796] security work --- .../main/java/org/baeldung/spring/config/PersistenceConfig.java | 0 .../src/main/java/org/baeldung/spring/config/WebConfig.java | 2 +- spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {spring-security-rest => spring-security-basic-auth}/src/main/java/org/baeldung/spring/config/PersistenceConfig.java (100%) diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/PersistenceConfig.java similarity index 100% rename from spring-security-rest/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/config/PersistenceConfig.java diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java index c6d3aa896b77..20f3bf8f1839 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -5,7 +5,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration -@ComponentScan("org.baeldung.spring.web.controller") +@ComponentScan("org.baeldung.web") public class WebConfig extends WebMvcConfigurerAdapter { public WebConfig() { diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index 23e0e8c1d7b0..adb3e17d7d01 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -17,7 +17,7 @@ contextConfigLocation - org.baeldung.spring.web.config + org.baeldung.spring.config From acd6f0432ed080c39fc1b1f44d0b63b6a3316829 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 29 May 2013 18:29:25 +0300 Subject: [PATCH 104/796] minor cleanup --- .../MyBasicAuthenticationEntryPoint.java | 31 ++++++++++++++++ .../spring/config/SecSecurityConfig.java | 2 ++ .../src/main/resources/webSecurityConfig.xml | 35 +++++++++---------- 3 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 spring-security-basic-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-basic-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 000000000000..968237227f63 --- /dev/null +++ b/spring-security-basic-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,31 @@ +package org.baeldung.security.basic; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java index a8b4962672b1..8d5dfb04092e 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java @@ -1,10 +1,12 @@ package org.baeldung.spring.config; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index 5ddca9778643..7734ea5f56af 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -1,28 +1,27 @@ - - + - - + + + + - + - + - - - - - - - - - - - + + + + + + + \ No newline at end of file From 6b0dd70f2bd6b2b6fd17e4d7607fab471866f23c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 22:56:25 +0300 Subject: [PATCH 105/796] maven cleanup --- spring-all/pom.xml | 24 +- spring-hibernate3/pom.xml | 28 +- spring-hibernate4/pom.xml | 24 +- spring-jpa/pom.xml | 37 ++- spring-mvc-java/pom.xml | 16 + .../.settings/org.eclipse.jdt.core.prefs | 6 - spring-mvc/pom.xml | 295 +++++++++--------- spring-security-basic-auth/pom.xml | 45 ++- 8 files changed, 290 insertions(+), 185 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 546375faddca..6f3ff2c35566 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -37,7 +37,7 @@ org.hibernate hibernate-core - 4.2.2.Final + ${hibernate.version} org.javassist @@ -47,7 +47,7 @@ mysql mysql-connector-java - 5.1.25 + ${mysql-connector-java.version} runtime @@ -56,7 +56,7 @@ org.hibernate hibernate-validator - 5.0.1.Final + ${hibernate-validator.version} @@ -80,7 +80,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -128,6 +128,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -141,6 +142,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -166,10 +168,21 @@ 3.2.3.RELEASE + + 4.2.2.Final + 5.1.25 + 1.7.5 1.0.11 + + 5.0.1.Final + + + 14.0.1 + 3.1 + 1.3 4.11 @@ -181,6 +194,9 @@ 1.8.0 1.8.9 + + 1.4.2 + 2.14.1 \ No newline at end of file diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 69d9da3294f5..e23ae24f11e3 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -32,7 +32,7 @@ org.hibernate hibernate-core - 3.6.10.Final + ${hibernate.version} org.javassist @@ -42,7 +42,7 @@ mysql mysql-connector-java - 5.1.25 + ${mysql-connector-java.version} runtime @@ -51,7 +51,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -59,7 +59,7 @@ org.apache.commons commons-lang3 - 3.1 + ${commons-lang3.version} test @@ -113,6 +113,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -126,6 +127,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -149,23 +151,37 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE + + + 3.6.10.Final + 5.1.25 1.7.5 1.0.11 + + 5.0.1.Final + + + 14.0.1 + 3.1 + 1.3 4.11 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 + + 1.4.2 + 2.14.1 \ No newline at end of file diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 7b8668cda10b..52ad28054899 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -32,7 +32,7 @@ org.hibernate hibernate-core - 4.2.2.Final + ${hibernate.version} org.javassist @@ -42,7 +42,7 @@ mysql mysql-connector-java - 5.1.25 + ${mysql-connector-java.version} runtime @@ -51,7 +51,7 @@ org.hibernate hibernate-validator - 5.0.1.Final + ${hibernate-validator.version} @@ -59,7 +59,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -121,6 +121,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -134,6 +135,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -159,10 +161,21 @@ 3.2.3.RELEASE + + 4.2.2.Final + 5.1.25 + 1.7.5 1.0.11 + + 5.0.1.Final + + + 14.0.1 + 3.1 + 1.3 4.11 @@ -174,6 +187,9 @@ 1.8.0 1.8.9 + + 1.4.2 + 2.14.1 \ No newline at end of file diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index d7c3bc3dac23..e2dfda178f32 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -1,11 +1,12 @@ 4.0.0 + org.baeldung spring-jpa 0.1-SNAPSHOT - - spring-jpa + war + spring-jpa @@ -32,12 +33,12 @@ org.hibernate hibernate-core - 4.2.1.Final + ${hibernate.version} org.hibernate hibernate-entitymanager - 4.2.1.Final + ${hibernate.version} org.javassist @@ -47,7 +48,7 @@ mysql mysql-connector-java - 5.1.25 + ${mysql-connector-java.version} runtime @@ -56,7 +57,7 @@ org.hibernate hibernate-validator - 5.0.1.Final + ${hibernate-validator.version} @@ -64,7 +65,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -72,7 +73,7 @@ org.apache.commons commons-lang3 - 3.1 + ${commons-lang3.version} test @@ -126,6 +127,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -139,6 +141,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -162,23 +165,37 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE + + + 4.2.2.Final + 5.1.25 1.7.5 1.0.11 + + 5.0.1.Final + + + 14.0.1 + 3.1 + 1.3 4.11 1.9.5 4.2.4 - 4.2.4 + 4.2.5 1.8.0 1.8.9 + + 1.4.2 + 2.14.1 \ No newline at end of file diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 913aa5058c30..81428ddb2e14 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -83,6 +83,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -96,6 +97,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -121,10 +123,21 @@ 3.2.3.RELEASE + + 4.2.2.Final + 5.1.25 + 1.7.5 1.0.11 + + 5.0.1.Final + + + 14.0.1 + 3.1 + 1.3 4.11 @@ -136,6 +149,9 @@ 1.8.0 1.8.9 + + 1.4.2 + 2.14.1 \ No newline at end of file diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-mvc/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..747acb809194 100644 --- a/spring-mvc/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc/.settings/org.eclipse.jdt.core.prefs @@ -4,11 +4,7 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -17,7 +13,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled @@ -88,4 +83,3 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index 3700a428ddb4..8e8969f0fda6 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -1,142 +1,157 @@ - - 4.0.0 - org.baeldung - spring-mvc - 0.1-SNAPSHOT - - spring-mvc - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-mvc - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.2.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.4 - - 1.8.0 - 1.8.9 - - + + 4.0.0 + org.baeldung + spring-mvc + 0.1-SNAPSHOT + + spring-mvc + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + \ No newline at end of file diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 9a9c7f05278e..0b820e53d1ad 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -141,6 +141,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -154,6 +155,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -176,25 +178,38 @@
- - 3.2.3.RELEASE - 3.1.4.RELEASE + + 3.2.3.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final - - 1.7.5 - 1.0.11 + + 14.0.1 + 3.1 - - 1.3 - 4.11 - 1.9.5 + + 1.3 + 4.11 + 1.9.5 - 4.2.4 - 4.2.5 + 4.2.4 + 4.2.5 - 1.8.0 - 1.8.9 + 1.8.0 + 1.8.9 - + + 1.4.2 + 2.14.1 + \ No newline at end of file From f2496eec8b52455b0407a87c5afdde1490a71235 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 22:57:27 +0300 Subject: [PATCH 106/796] maven cleanup --- spring-security-basic-auth/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 0b820e53d1ad..e6c8b1706634 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -180,6 +180,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final From 34f2bc6a833121d027e38be6e944d997c0a21aa2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:01:42 +0300 Subject: [PATCH 107/796] maven cleanup --- spring-all/pom.xml | 1 + spring-hibernate3/pom.xml | 1 + spring-hibernate4/pom.xml | 1 + spring-jpa/pom.xml | 1 + spring-mvc-java/pom.xml | 1 + spring-mvc/pom.xml | 1 + spring-security-login/pom.xml | 46 ++-- spring-security-rest/pom.xml | 411 ++++++++++++++++++---------------- 8 files changed, 250 insertions(+), 213 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 6f3ff2c35566..e801ff8c5464 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -167,6 +167,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index e23ae24f11e3..1859506e71af 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -152,6 +152,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 3.6.10.Final diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 52ad28054899..fd0fe6f121de 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -160,6 +160,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index e2dfda178f32..ebcc7f79a0b9 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -166,6 +166,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 81428ddb2e14..eb3831b4aae7 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -122,6 +122,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index 8e8969f0fda6..b46d4b484e78 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -122,6 +122,7 @@ 3.2.3.RELEASE + 3.1.4.RELEASE 4.2.2.Final diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index b22672d8ebd9..c797ae3bcbe3 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -133,6 +133,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -146,6 +147,7 @@ org.codehaus.cargo cargo-maven2-plugin + ${cargo-maven2-plugin.version} true @@ -168,25 +170,39 @@ - - 3.2.3.RELEASE - 3.1.4.RELEASE + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final - - 1.7.5 - 1.0.11 + + 14.0.1 + 3.1 - - 1.3 - 4.11 - 1.9.5 + + 1.3 + 4.11 + 1.9.5 - 4.2.4 - 4.2.5 + 4.2.4 + 4.2.5 - 1.8.0 - 1.8.9 + 1.8.0 + 1.8.9 - + + 1.4.2 + 2.14.1 + \ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 8c41c2fece39..909d32af74a7 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -1,200 +1,215 @@ - - 4.0.0 - org.baeldung - spring-security-rest - 0.1-SNAPSHOT - - spring-security-rest - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - 14.0.1 - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 1.7.5 - 1.0.11 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.0 - 1.8.9 - - + + 4.0.0 + org.baeldung + spring-security-rest + 0.1-SNAPSHOT + + spring-security-rest + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + \ No newline at end of file From 830a6c614ad79b806b93c40805ea8b12e2710ef6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:02:02 +0300 Subject: [PATCH 108/796] formatting cleanup --- .../org/baeldung/spring/web/config/SecSecurityConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java index 65a571c71589..a21a05c17d2d 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java @@ -7,8 +7,8 @@ @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecSecurityConfig { - public SecSecurityConfig() { - super(); - } + public SecSecurityConfig() { + super(); + } } From e8a1bfa2bd7766dbc9a571f85d30b03e39e1ee4c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:04:08 +0300 Subject: [PATCH 109/796] project cleanup --- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-mvc/.settings/org.eclipse.jdt.core.prefs | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/spring-mvc-java/.settings/org.eclipse.wst.common.component b/spring-mvc-java/.settings/org.eclipse.wst.common.component index 9784ac36ee68..73770253eef9 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-java/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-mvc/.settings/org.eclipse.jdt.core.prefs index 747acb809194..723e5b12451a 100644 --- a/spring-mvc/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc/.settings/org.eclipse.jdt.core.prefs @@ -4,7 +4,15 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -13,6 +21,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled @@ -83,3 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 From 210be2e5737f2992e60cac27e9dc9dc625df5722 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:13:16 +0300 Subject: [PATCH 110/796] jpa work --- .../{spring => }/persistence/dao/FooDao.java | 4 +-- .../{spring => }/persistence/dao/IFooDao.java | 4 +-- .../{spring => }/persistence/model/Foo.java | 2 +- .../persistence/service/FooService.java | 6 ++-- .../config => }/HibernateXmlConfig.java | 4 +-- .../config => }/PersistenceConfig.java | 6 ++-- .../src/main/resources/hibernate4Config.xml | 2 +- spring-jpa/src/main/webapp/WEB-INF/web.xml | 30 +++++++++++-------- .../FooServicePersistenceIntegrationTest.java | 7 +++-- 9 files changed, 35 insertions(+), 30 deletions(-) rename spring-jpa/src/main/java/org/baeldung/{spring => }/persistence/dao/FooDao.java (92%) rename spring-jpa/src/main/java/org/baeldung/{spring => }/persistence/dao/IFooDao.java (71%) rename spring-jpa/src/main/java/org/baeldung/{spring => }/persistence/model/Foo.java (97%) rename spring-jpa/src/main/java/org/baeldung/{spring => }/persistence/service/FooService.java (73%) rename spring-jpa/src/main/java/org/baeldung/spring/{persistence/config => }/HibernateXmlConfig.java (75%) rename spring-jpa/src/main/java/org/baeldung/spring/{persistence/config => }/PersistenceConfig.java (94%) rename spring-jpa/src/test/java/org/baeldung/{spring => }/persistence/service/FooServicePersistenceIntegrationTest.java (90%) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java similarity index 92% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java index f970ade71f70..4f37afc9ff3f 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java @@ -1,11 +1,11 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.persistence.dao; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; import org.springframework.stereotype.Repository; import com.google.common.base.Preconditions; diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java similarity index 71% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java rename to spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java index 201fc3e35187..f5799522e2fa 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -1,8 +1,8 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.persistence.dao; import java.util.List; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; public interface IFooDao { diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java similarity index 97% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java index 8b03df39e7a3..1e3bcc013108 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.model; +package org.baeldung.persistence.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java similarity index 73% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java index 1d3b5c4a0201..b07698c43854 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java @@ -1,7 +1,7 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; -import org.baeldung.spring.persistence.dao.IFooDao; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java similarity index 75% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java rename to spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java index 51fbcd27c16d..4c54d150a15a 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -7,7 +7,7 @@ @Configuration @EnableTransactionManagement -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) @ImportResource({ "classpath:hibernate4Config.xml" }) public class HibernateXmlConfig { diff --git a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java similarity index 94% rename from spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java index 52ee113e17aa..300579ff419d 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import java.util.Properties; @@ -24,7 +24,7 @@ @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence" }) public class PersistenceConfig { @Autowired @@ -38,7 +38,7 @@ public PersistenceConfig() { public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(restDataSource()); - factoryBean.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + factoryBean.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setJpaVendorAdapter(vendorAdapter); diff --git a/spring-jpa/src/main/resources/hibernate4Config.xml b/spring-jpa/src/main/resources/hibernate4Config.xml index f35de2a4c5db..f85811f8ede5 100644 --- a/spring-jpa/src/main/resources/hibernate4Config.xml +++ b/spring-jpa/src/main/resources/hibernate4Config.xml @@ -10,7 +10,7 @@ - + ${hibernate.hbm2ddl.auto} diff --git a/spring-jpa/src/main/webapp/WEB-INF/web.xml b/spring-jpa/src/main/webapp/WEB-INF/web.xml index e0de9aefd45a..90f2abc2f6c9 100644 --- a/spring-jpa/src/main/webapp/WEB-INF/web.xml +++ b/spring-jpa/src/main/webapp/WEB-INF/web.xml @@ -1,17 +1,21 @@ - - Spring MVC Application - - contextClass - + + + Spring JPA Application + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.persistence.config - - - org.springframework.web.context.ContextLoaderListener - + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + \ No newline at end of file diff --git a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 90% rename from spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java rename to spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 42dbb45f030c..06e61930411e 100644 --- a/spring-jpa/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,9 +1,10 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.spring.persistence.config.PersistenceConfig; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.FooService; +import org.baeldung.spring.PersistenceConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; From 829521b212b2a84adb156b2dc802c71c0d151e9d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:15:06 +0300 Subject: [PATCH 111/796] jpa work --- ...rsistenceConfig.java => PersistenceJPAConfig.java} | 4 ++-- ...ateXmlConfig.java => PersistenceJPAConfigXml.java} | 11 +++++------ .../resources/{hibernate4Config.xml => jpaConfig.xml} | 0 .../service/FooServicePersistenceIntegrationTest.java | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) rename spring-jpa/src/main/java/org/baeldung/spring/{PersistenceConfig.java => PersistenceJPAConfig.java} (97%) rename spring-jpa/src/main/java/org/baeldung/spring/{HibernateXmlConfig.java => PersistenceJPAConfigXml.java} (50%) rename spring-jpa/src/main/resources/{hibernate4Config.xml => jpaConfig.xml} (100%) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java similarity index 97% rename from spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java rename to spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java index 300579ff419d..29494084b1aa 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -25,12 +25,12 @@ @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) -public class PersistenceConfig { +public class PersistenceJPAConfig { @Autowired private Environment env; - public PersistenceConfig() { + public PersistenceJPAConfig() { super(); } diff --git a/spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java similarity index 50% rename from spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java rename to spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java index 4c54d150a15a..e85510a0c424 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/HibernateXmlConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java @@ -1,17 +1,16 @@ package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.transaction.annotation.EnableTransactionManagement; -@Configuration +// @Configuration @EnableTransactionManagement -@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) -@ImportResource({ "classpath:hibernate4Config.xml" }) -public class HibernateXmlConfig { +@ComponentScan({ "org.baeldung.persistence" }) +@ImportResource({ "classpath:jpaConfig.xml" }) +public class PersistenceJPAConfigXml { - public HibernateXmlConfig() { + public PersistenceJPAConfigXml() { super(); } diff --git a/spring-jpa/src/main/resources/hibernate4Config.xml b/spring-jpa/src/main/resources/jpaConfig.xml similarity index 100% rename from spring-jpa/src/main/resources/hibernate4Config.xml rename to spring-jpa/src/main/resources/jpaConfig.xml diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 06e61930411e..e6c9d8ff1828 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,7 +4,7 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.FooService; -import org.baeldung.spring.PersistenceConfig; +import org.baeldung.spring.PersistenceJPAConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -15,7 +15,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) public class FooServicePersistenceIntegrationTest { @Autowired From 5d1e5062ecf55165efdce596dba51cf6a920109d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:18:53 +0300 Subject: [PATCH 112/796] doc work --- spring-jpa/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index 7f5cdda2e232..9f63413d937d 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -1,5 +1,5 @@ -JPA with Spring ========= Relevant Articles: -- \ No newline at end of file +- [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) + From 9d86ea24a09a361f8658f57b9b265a86c066abde Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:39:09 +0300 Subject: [PATCH 113/796] general cleanup --- spring-jpa/.settings/org.eclipse.jdt.core.prefs | 2 +- spring-jpa/pom.xml | 7 +------ spring-jpa/src/main/resources/persistence-mysql.properties | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/spring-jpa/.settings/org.eclipse.jdt.core.prefs b/spring-jpa/.settings/org.eclipse.jdt.core.prefs index a931b331929d..c201ee1f7a18 100644 --- a/spring-jpa/.settings/org.eclipse.jdt.core.prefs +++ b/spring-jpa/.settings/org.eclipse.jdt.core.prefs @@ -42,7 +42,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index ebcc7f79a0b9..e3b864c3e7bb 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -29,12 +29,7 @@ - - - org.hibernate - hibernate-core - ${hibernate.version} - + org.hibernate hibernate-entitymanager diff --git a/spring-jpa/src/main/resources/persistence-mysql.properties b/spring-jpa/src/main/resources/persistence-mysql.properties index a1ff997616ae..c4de4ceb80a5 100644 --- a/spring-jpa/src/main/resources/persistence-mysql.properties +++ b/spring-jpa/src/main/resources/persistence-mysql.properties @@ -1,6 +1,6 @@ # jdbc.X jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate_dao_01?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/spring_jpa_01?createDatabaseIfNotExist=true jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql From 5fc81e081e9b2c90d1a9ebc27db1956afdf356ee Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 May 2013 23:57:15 +0300 Subject: [PATCH 114/796] xml configuration working as well --- .../baeldung/spring/PersistenceJPAConfig.java | 21 +++++++------- .../spring/PersistenceJPAConfigXml.java | 3 +- spring-jpa/src/main/resources/jpaConfig.xml | 28 ++++++++++++------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java index 29494084b1aa..dac41e182b23 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -7,13 +7,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -21,7 +19,7 @@ import com.google.common.base.Preconditions; -@Configuration +// @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) @@ -36,19 +34,20 @@ public PersistenceJPAConfig() { @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { - final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); - factoryBean.setDataSource(restDataSource()); - factoryBean.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - factoryBean.setJpaVendorAdapter(vendorAdapter); - factoryBean.setJpaProperties(additionalProperties()); + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + // vendorAdapter.set + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); - return factoryBean; + return em; } @Bean - public DataSource restDataSource() { + public DataSource dataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java index e85510a0c424..98f4f47249f6 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java @@ -1,10 +1,11 @@ package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.transaction.annotation.EnableTransactionManagement; -// @Configuration +@Configuration @EnableTransactionManagement @ComponentScan({ "org.baeldung.persistence" }) @ImportResource({ "classpath:jpaConfig.xml" }) diff --git a/spring-jpa/src/main/resources/jpaConfig.xml b/spring-jpa/src/main/resources/jpaConfig.xml index f85811f8ede5..31df8d69dacd 100644 --- a/spring-jpa/src/main/resources/jpaConfig.xml +++ b/spring-jpa/src/main/resources/jpaConfig.xml @@ -1,17 +1,24 @@ - - - + + - + + + + + ${hibernate.hbm2ddl.auto} ${hibernate.dialect} @@ -26,10 +33,11 @@ - - + + - + + \ No newline at end of file From a7464803266148b7359e30ae99814c8b946d3d8e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 00:40:51 +0300 Subject: [PATCH 115/796] dao work --- .../persistence/dao/AbstractJpaDAO.java | 46 +++++++++++++++++ .../org/baeldung/persistence/dao/FooDao.java | 49 ++----------------- .../org/baeldung/persistence/model/Foo.java | 4 +- 3 files changed, 52 insertions(+), 47 deletions(-) create mode 100644 spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java b/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java new file mode 100644 index 000000000000..13007d9fccef --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java @@ -0,0 +1,46 @@ +package org.baeldung.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +public abstract class AbstractJpaDAO { + + private Class clazz; + + @PersistenceContext + private EntityManager entityManager; + + public final void setClazz(final Class clazzToSet) { + this.clazz = clazzToSet; + } + + public T findOne(final long id) { + return entityManager.find(clazz, id); + } + + @SuppressWarnings("unchecked") + public List findAll() { + return entityManager.createQuery("from " + clazz.getName()).getResultList(); + } + + public void create(final T entity) { + entityManager.persist(entity); + } + + public T update(final T entity) { + return entityManager.merge(entity); + } + + public void delete(final T entity) { + entityManager.remove(entity); + } + + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + delete(entity); + } + +} \ No newline at end of file diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java index 4f37afc9ff3f..77978c5cf282 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java @@ -1,60 +1,17 @@ package org.baeldung.persistence.dao; -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - import org.baeldung.persistence.model.Foo; import org.springframework.stereotype.Repository; -import com.google.common.base.Preconditions; - @Repository -public class FooDao implements IFooDao { - - @PersistenceContext - private EntityManager entityManager; +public class FooDao extends AbstractJpaDAO implements IFooDao { public FooDao() { super(); - } - - // API - - @Override - public Foo findOne(final long id) { - return entityManager.find(Foo.class, id); - } - @Override - @SuppressWarnings("unchecked") - public List findAll() { - return entityManager.createQuery("from " + Foo.class.getName()).getResultList(); + setClazz(Foo.class); } - @Override - public void create(final Foo entity) { - Preconditions.checkNotNull(entity); - entityManager.persist(entity); - } - - @Override - public Foo update(final Foo entity) { - Preconditions.checkNotNull(entity); - return entityManager.merge(entity); - } - - @Override - public void delete(final Foo entity) { - Preconditions.checkNotNull(entity); - entityManager.remove(entity); - } - - @Override - public void deleteById(final long entityId) { - final Foo entity = findOne(entityId); - delete(entity); - } + // API } diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java index 1e3bcc013108..8e1dee33e845 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,5 +1,7 @@ package org.baeldung.persistence.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -7,7 +9,7 @@ import javax.persistence.Id; @Entity -public class Foo { +public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) From de6dbe897fba36d6d343521b3d8fb60794bbcbab Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 00:54:49 +0300 Subject: [PATCH 116/796] cleanup work --- .../core/ComponentUsingProperties.java | 12 ++++++++++ .../baeldung/{web => persistence}/Setup.java | 12 +++------- .../baeldung/spring/config/CoreConfig.java | 4 +++- .../{ClientWebConfig.java => MvcConfig.java} | 4 ++-- .../org/baeldung/spring/config/WebConfig.java | 22 ------------------- .../main/java/org/baeldung/web/BeanC1.java | 12 ---------- .../main/java/org/baeldung/web/BeanC2.java | 12 ---------- .../src/main/java/org/baeldung/web/BeanD.java | 12 ---------- .../main/java/org/baeldung/web/IBeanC.java | 5 ----- .../main/java/org/baeldung/web/IBeanD.java | 5 ----- .../main/java/org/baeldung/web/IServiceA.java | 5 ----- .../main/java/org/baeldung/web/IServiceB.java | 5 ----- .../main/java/org/baeldung/web/ServiceA.java | 22 ------------------- .../main/java/org/baeldung/web/ServiceB.java | 20 ----------------- ...beansInXml.xml => configForProperties.xml} | 0 15 files changed, 20 insertions(+), 132 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java rename spring-all/src/main/java/org/baeldung/{web => persistence}/Setup.java (72%) rename spring-all/src/main/java/org/baeldung/spring/config/{ClientWebConfig.java => MvcConfig.java} (92%) delete mode 100644 spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/BeanC1.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/BeanC2.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/BeanD.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanC.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/IBeanD.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/IServiceA.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/IServiceB.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/ServiceA.java delete mode 100644 spring-all/src/main/java/org/baeldung/web/ServiceB.java rename spring-all/src/main/resources/{beansInXml.xml => configForProperties.xml} (100%) diff --git a/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java b/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java new file mode 100644 index 000000000000..b3b44da3bdaa --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java @@ -0,0 +1,12 @@ +package org.baeldung.core; + +import org.springframework.stereotype.Component; + +@Component +public class ComponentUsingProperties { + + public ComponentUsingProperties() { + super(); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/web/Setup.java b/spring-all/src/main/java/org/baeldung/persistence/Setup.java similarity index 72% rename from spring-all/src/main/java/org/baeldung/web/Setup.java rename to spring-all/src/main/java/org/baeldung/persistence/Setup.java index f04135d807f6..5cba4e70fba3 100644 --- a/spring-all/src/main/java/org/baeldung/web/Setup.java +++ b/spring-all/src/main/java/org/baeldung/persistence/Setup.java @@ -1,20 +1,14 @@ -package org.baeldung.web; +package org.baeldung.persistence; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; -// @Component +@Component public class Setup implements ApplicationListener { private boolean setupDone; - @Autowired - ServiceA serviceA; - - @Autowired - IServiceB serviceB; - public Setup() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java index e202a779dbbe..ba17ca79386b 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java @@ -1,11 +1,13 @@ package org.baeldung.spring.config; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration -@ImportResource("classpath:beansInXml.xml") +@ImportResource("classpath:configForProperties.xml") +@ComponentScan("org.baeldung.core") public class CoreConfig extends WebMvcConfigurerAdapter { public CoreConfig() { diff --git a/spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java similarity index 92% rename from spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java rename to spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java index f027eb73fc6a..f87e400fce82 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/ClientWebConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java @@ -11,9 +11,9 @@ @EnableWebMvc @Configuration -public class ClientWebConfig extends WebMvcConfigurerAdapter { +public class MvcConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { + public MvcConfig() { super(); } diff --git a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java deleted file mode 100644 index c69ef21b0c24..000000000000 --- a/spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.baeldung.spring.config; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@EnableWebMvc -@ComponentScan("org.baeldung.web") -public class WebConfig extends WebMvcConfigurerAdapter { - - @Autowired - BeanFactory beanFactory; - - public WebConfig() { - super(); - } - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/web/BeanC1.java b/spring-all/src/main/java/org/baeldung/web/BeanC1.java deleted file mode 100644 index cb3c845a0258..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/BeanC1.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.web; - -import org.springframework.stereotype.Component; - -@Component -public class BeanC1 implements IBeanC { - - public BeanC1() { - super(); - } - -} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanC2.java b/spring-all/src/main/java/org/baeldung/web/BeanC2.java deleted file mode 100644 index ed38a809cf5f..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/BeanC2.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.web; - -import org.springframework.stereotype.Component; - -@Component -public class BeanC2 implements IBeanC { - - public BeanC2() { - super(); - } - -} diff --git a/spring-all/src/main/java/org/baeldung/web/BeanD.java b/spring-all/src/main/java/org/baeldung/web/BeanD.java deleted file mode 100644 index 04488238e533..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/BeanD.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.web; - -import org.springframework.stereotype.Component; - -@Component -public class BeanD implements IBeanD { - - public BeanD() { - super(); - } - -} diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanC.java b/spring-all/src/main/java/org/baeldung/web/IBeanC.java deleted file mode 100644 index 78adca4e72eb..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/IBeanC.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.web; - -public interface IBeanC { - // -} diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanD.java b/spring-all/src/main/java/org/baeldung/web/IBeanD.java deleted file mode 100644 index 2b50038c71e0..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/IBeanD.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.web; - -public interface IBeanD { - // -} diff --git a/spring-all/src/main/java/org/baeldung/web/IServiceA.java b/spring-all/src/main/java/org/baeldung/web/IServiceA.java deleted file mode 100644 index 0461d5293ff8..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/IServiceA.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.web; - -public interface IServiceA { - // -} diff --git a/spring-all/src/main/java/org/baeldung/web/IServiceB.java b/spring-all/src/main/java/org/baeldung/web/IServiceB.java deleted file mode 100644 index faf048cde5f0..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/IServiceB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.web; - -public interface IServiceB { - // -} diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceA.java b/spring-all/src/main/java/org/baeldung/web/ServiceA.java deleted file mode 100644 index deee4c6e5580..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/ServiceA.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.baeldung.web; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class ServiceA { - - @Autowired - public ServiceA(final IServiceB serviceB) { - super(); - } - - // - - public void testA() { - System.out.println(); - } - -} diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceB.java b/spring-all/src/main/java/org/baeldung/web/ServiceB.java deleted file mode 100644 index 48ff0f264829..000000000000 --- a/spring-all/src/main/java/org/baeldung/web/ServiceB.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.baeldung.web; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class ServiceB implements IServiceB { - - public ServiceB() { - super(); - } - - // - - public void testB() { - System.out.println(); - } - -} diff --git a/spring-all/src/main/resources/beansInXml.xml b/spring-all/src/main/resources/configForProperties.xml similarity index 100% rename from spring-all/src/main/resources/beansInXml.xml rename to spring-all/src/main/resources/configForProperties.xml From dee468a15411b39aca57deca3cd7e794a28f89e3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 01:07:57 +0300 Subject: [PATCH 117/796] initial work on properties --- ...e.wst.jsdt.core.javascriptValidator.launch | 7 ------- .../.settings/org.eclipse.jdt.core.prefs | 4 ++++ spring-all/pom.xml | 9 ++++++++- .../core/ComponentUsingProperties.java | 20 ++++++++++++++++++- .../spring/config/PersistenceConfig.java | 5 ++--- .../main/resources/configForProperties.xml | 2 +- spring-all/src/main/resources/foo.properties | 1 + .../resources/persistence-mysql.properties | 10 ---------- .../core/PropertiesViaXmlIntegrationTest.java | 19 ++++++++++++++++++ 9 files changed, 54 insertions(+), 23 deletions(-) delete mode 100644 spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-all/src/main/resources/foo.properties delete mode 100644 spring-all/src/main/resources/persistence-mysql.properties create mode 100644 spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java diff --git a/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch deleted file mode 100644 index 627021fb9640..000000000000 --- a/spring-all/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-all/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..723e5b12451a 100644 --- a/spring-all/.settings/org.eclipse.jdt.core.prefs +++ b/spring-all/.settings/org.eclipse.jdt.core.prefs @@ -6,7 +6,11 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore diff --git a/spring-all/pom.xml b/spring-all/pom.xml index e801ff8c5464..7e93da8b647c 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -84,7 +84,14 @@ - + + + org.springframework + spring-test + ${org.springframework.version} + test + + junit junit-dep diff --git a/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java b/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java index b3b44da3bdaa..7df4d8ead0af 100644 --- a/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java +++ b/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java @@ -1,12 +1,30 @@ package org.baeldung.core; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class ComponentUsingProperties { +public class ComponentUsingProperties implements InitializingBean { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; public ComponentUsingProperties() { super(); } + // + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println("via @Value: " + injectedProperty); + System.out.println("via Environment: " + env.getProperty("key.something")); + } + } diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 078d7e6f88bc..6a057fc0c741 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -18,10 +17,10 @@ import com.google.common.base.Preconditions; -@Configuration +// @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence" }) public class PersistenceConfig { @Autowired diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index 9cd3282179bd..c3218dffa416 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -4,6 +4,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> - + \ No newline at end of file diff --git a/spring-all/src/main/resources/foo.properties b/spring-all/src/main/resources/foo.properties new file mode 100644 index 000000000000..7c47cd788002 --- /dev/null +++ b/spring-all/src/main/resources/foo.properties @@ -0,0 +1 @@ +key.something=val \ No newline at end of file diff --git a/spring-all/src/main/resources/persistence-mysql.properties b/spring-all/src/main/resources/persistence-mysql.properties deleted file mode 100644 index 8263b0d9accd..000000000000 --- a/spring-all/src/main/resources/persistence-mysql.properties +++ /dev/null @@ -1,10 +0,0 @@ -# jdbc.X -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java new file mode 100644 index 000000000000..5bfede4217b6 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.core; + +import org.baeldung.spring.config.CoreConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { CoreConfig.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesViaXmlIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 52995a5194a0923030ea4db0049beb5b3c0e0528 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 01:10:08 +0300 Subject: [PATCH 118/796] property work --- .../baeldung/spring/config/CoreConfig.java | 2 -- .../properties/PropertiesWithJavaConfig.java | 17 +++++++++++++++++ .../properties/PropertiesWithXmlConfig.java | 17 +++++++++++++++++ .../PropertiesWithJavaIntegrationTest.java | 19 +++++++++++++++++++ ... => PropertiesWithXmlIntegrationTest.java} | 6 +++--- 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java create mode 100644 spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java rename spring-all/src/test/java/org/baeldung/core/{PropertiesViaXmlIntegrationTest.java => PropertiesWithXmlIntegrationTest.java} (66%) diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java index ba17ca79386b..ff1742351b23 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java @@ -2,11 +2,9 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration -@ImportResource("classpath:configForProperties.xml") @ComponentScan("org.baeldung.core") public class CoreConfig extends WebMvcConfigurerAdapter { diff --git a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java new file mode 100644 index 000000000000..fc67b7430ae5 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.properties; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.core") +@PropertySource("classpath:foo.properties") +public class PropertiesWithJavaConfig extends WebMvcConfigurerAdapter { + + public PropertiesWithJavaConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java b/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java new file mode 100644 index 000000000000..f5f5de77cb1d --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.properties; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ImportResource("classpath:configForProperties.xml") +@ComponentScan("org.baeldung.core") +public class PropertiesWithXmlConfig extends WebMvcConfigurerAdapter { + + public PropertiesWithXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java new file mode 100644 index 000000000000..e3cfb493ede3 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.core; + +import org.baeldung.spring.properties.PropertiesWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithJavaIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java similarity index 66% rename from spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java rename to spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java index 5bfede4217b6..44cacf58e36c 100644 --- a/spring-all/src/test/java/org/baeldung/core/PropertiesViaXmlIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java @@ -1,6 +1,6 @@ package org.baeldung.core; -import org.baeldung.spring.config.CoreConfig; +import org.baeldung.spring.properties.PropertiesWithXmlConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; @@ -8,8 +8,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { CoreConfig.class }, loader = AnnotationConfigContextLoader.class) -public class PropertiesViaXmlIntegrationTest { +@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithXmlIntegrationTest { @Test public final void givenContextIsInitialized_thenNoException() { From a7eeabc8de3684f04d10d94a42255432446bb3e9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 11:47:10 +0300 Subject: [PATCH 119/796] properties logic moved entirelly under a package --- .../core/ComponentUsingProperties.java | 6 ++--- .../spring/PropertiesWithJavaConfig.java | 25 +++++++++++++++++++ .../spring}/PropertiesWithXmlConfig.java | 5 ++-- .../properties/PropertiesWithJavaConfig.java | 17 ------------- .../main/resources/configForProperties.xml | 6 ++++- spring-all/src/main/resources/logback.xml | 2 ++ .../PropertiesWithJavaIntegrationTest.java | 16 +++++++++--- .../PropertiesWithXmlIntegrationTest.java | 16 +++++++++--- 8 files changed, 63 insertions(+), 30 deletions(-) rename spring-all/src/main/java/org/baeldung/{ => properties}/core/ComponentUsingProperties.java (73%) create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java rename spring-all/src/main/java/org/baeldung/{spring/properties => properties/spring}/PropertiesWithXmlConfig.java (64%) delete mode 100644 spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java rename spring-all/src/test/java/org/baeldung/{ => properties}/core/PropertiesWithJavaIntegrationTest.java (50%) rename spring-all/src/test/java/org/baeldung/{ => properties}/core/PropertiesWithXmlIntegrationTest.java (50%) diff --git a/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java similarity index 73% rename from spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java rename to spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java index 7df4d8ead0af..7e082702fe7e 100644 --- a/spring-all/src/main/java/org/baeldung/core/ComponentUsingProperties.java +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java @@ -1,4 +1,4 @@ -package org.baeldung.core; +package org.baeldung.properties.core; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -23,8 +23,8 @@ public ComponentUsingProperties() { @Override public void afterPropertiesSet() throws Exception { - System.out.println("via @Value: " + injectedProperty); - System.out.println("via Environment: " + env.getProperty("key.something")); + System.out.println("in afterPropertiesSet via @Value: " + injectedProperty); + System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something")); } } diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java new file mode 100644 index 000000000000..0269053fbeb1 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java @@ -0,0 +1,25 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan("org.baeldung.core") +@PropertySource("classpath:foo.properties") +public class PropertiesWithJavaConfig { + + public PropertiesWithJavaConfig() { + super(); + } + + // beans + + @Bean + public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java similarity index 64% rename from spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java rename to spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java index f5f5de77cb1d..9ad7febcb0c1 100644 --- a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithXmlConfig.java +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java @@ -1,14 +1,13 @@ -package org.baeldung.spring.properties; +package org.baeldung.properties.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration @ImportResource("classpath:configForProperties.xml") @ComponentScan("org.baeldung.core") -public class PropertiesWithXmlConfig extends WebMvcConfigurerAdapter { +public class PropertiesWithXmlConfig { public PropertiesWithXmlConfig() { super(); diff --git a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java deleted file mode 100644 index fc67b7430ae5..000000000000 --- a/spring-all/src/main/java/org/baeldung/spring/properties/PropertiesWithJavaConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring.properties; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@ComponentScan("org.baeldung.core") -@PropertySource("classpath:foo.properties") -public class PropertiesWithJavaConfig extends WebMvcConfigurerAdapter { - - public PropertiesWithJavaConfig() { - super(); - } - -} \ No newline at end of file diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index c3218dffa416..6ec3d15fe50c 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -1,9 +1,13 @@ - + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/logback.xml b/spring-all/src/main/resources/logback.xml index 1146dade632e..45c9697f776f 100644 --- a/spring-all/src/main/resources/logback.xml +++ b/spring-all/src/main/resources/logback.xml @@ -12,6 +12,8 @@ + + diff --git a/spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java similarity index 50% rename from spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java rename to spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java index e3cfb493ede3..72d4ccb4af67 100644 --- a/spring-all/src/test/java/org/baeldung/core/PropertiesWithJavaIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java @@ -1,8 +1,11 @@ -package org.baeldung.core; +package org.baeldung.properties.core; -import org.baeldung.spring.properties.PropertiesWithJavaConfig; +import org.baeldung.properties.spring.PropertiesWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +14,16 @@ @ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class PropertiesWithJavaIntegrationTest { + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + @Test public final void givenContextIsInitialized_thenNoException() { - // + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); } } diff --git a/spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java similarity index 50% rename from spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java rename to spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java index 44cacf58e36c..ff5eaab910b1 100644 --- a/spring-all/src/test/java/org/baeldung/core/PropertiesWithXmlIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java @@ -1,8 +1,11 @@ -package org.baeldung.core; +package org.baeldung.properties.core; -import org.baeldung.spring.properties.PropertiesWithXmlConfig; +import org.baeldung.properties.spring.PropertiesWithXmlConfig; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +14,16 @@ @ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) public class PropertiesWithXmlIntegrationTest { + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + @Test public final void givenContextIsInitialized_thenNoException() { - // + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); } } From f5af87c8581753b87c4a0d3d9d31876fe02ea02e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 13:04:45 +0300 Subject: [PATCH 120/796] properties work --- .../core/ComponentInXmlUsingProperties.java | 30 +++++++++++++++++++ .../spring/PropertiesWithJavaConfig.java | 4 +-- .../main/resources/configForProperties.xml | 11 +++++-- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java new file mode 100644 index 000000000000..f695326cd6bd --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; + +public class ComponentInXmlUsingProperties implements InitializingBean { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + public ComponentInXmlUsingProperties(final String propertyValue) { + super(); + + System.out.println("Constructor Injection - Property Value resolted to: " + propertyValue); + } + + // + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println("in afterPropertiesSet via @Value: " + injectedProperty); + System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java index 0269053fbeb1..9b5d7ed047b5 100644 --- a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java @@ -7,7 +7,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration -@ComponentScan("org.baeldung.core") +@ComponentScan("org.baeldung.properties.core") @PropertySource("classpath:foo.properties") public class PropertiesWithJavaConfig { @@ -18,7 +18,7 @@ public PropertiesWithJavaConfig() { // beans @Bean - public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index 6ec3d15fe50c..fc6cf21069e6 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -6,8 +6,13 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> - - - + + + + + + + + \ No newline at end of file From 9722a641271389fd9f79c2f30b6780d7f4e09c6e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 13:59:11 +0300 Subject: [PATCH 121/796] properties work --- .../spring/PropertiesWithJavaConfigOther.java | 16 ++++++++++ .../spring/PropertiesWithXmlConfigOne.java | 16 ++++++++++ .../spring/PropertiesWithXmlConfigTwo.java | 14 +++++++++ spring-all/src/main/resources/bar.properties | 1 + .../main/resources/configForProperties.xml | 5 +--- .../main/resources/configForPropertiesOne.xml | 15 ++++++++++ .../main/resources/configForPropertiesTwo.xml | 11 +++++++ .../PropertiesWithJavaIntegrationTest.java | 3 +- ...ertiesWithMultipleXmlsIntegrationTest.java | 30 +++++++++++++++++++ 9 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java create mode 100644 spring-all/src/main/resources/bar.properties create mode 100644 spring-all/src/main/resources/configForPropertiesOne.xml create mode 100644 spring-all/src/main/resources/configForPropertiesTwo.xml create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java new file mode 100644 index 000000000000..594ba0a09d52 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java @@ -0,0 +1,16 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource("classpath:bar.properties") +public class PropertiesWithJavaConfigOther { + + public PropertiesWithJavaConfigOther() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java new file mode 100644 index 000000000000..9061cc10d48d --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java @@ -0,0 +1,16 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource("classpath:configForPropertiesOne.xml") +@ComponentScan("org.baeldung.core") +public class PropertiesWithXmlConfigOne { + + public PropertiesWithXmlConfigOne() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java new file mode 100644 index 000000000000..e4365cbc8b78 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java @@ -0,0 +1,14 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource("classpath:configForPropertiesTwo.xml") +public class PropertiesWithXmlConfigTwo { + + public PropertiesWithXmlConfigTwo() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/resources/bar.properties b/spring-all/src/main/resources/bar.properties new file mode 100644 index 000000000000..1a41a49c4c3c --- /dev/null +++ b/spring-all/src/main/resources/bar.properties @@ -0,0 +1 @@ +key.something2=val2 \ No newline at end of file diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index fc6cf21069e6..20a40a319559 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -6,12 +6,9 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> - - - - + diff --git a/spring-all/src/main/resources/configForPropertiesOne.xml b/spring-all/src/main/resources/configForPropertiesOne.xml new file mode 100644 index 000000000000..ad9716fada18 --- /dev/null +++ b/spring-all/src/main/resources/configForPropertiesOne.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/configForPropertiesTwo.xml b/spring-all/src/main/resources/configForPropertiesTwo.xml new file mode 100644 index 000000000000..b9d5e86c95d9 --- /dev/null +++ b/spring-all/src/main/resources/configForPropertiesTwo.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java index 72d4ccb4af67..d6c99502d7db 100644 --- a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java @@ -1,6 +1,7 @@ package org.baeldung.properties.core; import org.baeldung.properties.spring.PropertiesWithJavaConfig; +import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -11,7 +12,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class) public class PropertiesWithJavaIntegrationTest { @Autowired diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java new file mode 100644 index 000000000000..9fc793fc1bf4 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; +import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithMultipleXmlsIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + } + +} From d323485b54d314ae5397bc4b8984520d2d3b2019 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 14:00:17 +0300 Subject: [PATCH 122/796] doc work --- spring-all/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-all/README.md b/spring-all/README.md index d3e07f338d80..2a0650209bf4 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -4,3 +4,4 @@ Relevant articles: - [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) - [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) - [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) +- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) \ No newline at end of file From 6d68242ff7cf8f63d0f7715a25a8a9ce4713f584 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 14:01:34 +0300 Subject: [PATCH 123/796] doc work --- spring-all/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-all/README.md b/spring-all/README.md index 2a0650209bf4..78b34858c574 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -4,4 +4,4 @@ Relevant articles: - [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) - [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) - [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) -- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) \ No newline at end of file +- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file From 044e6a3312027286260d68584bec5e8f8f4bf6d1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 14:53:31 +0300 Subject: [PATCH 124/796] general cleanup and improvements --- spring-hibernate3/.springBeans | 1 - .../persistence/dao/AbstractHibernateDao.java | 2 +- .../{spring => }/persistence/dao/FooDao.java | 4 +-- .../org/baeldung/persistence/dao/IFooDao.java | 7 +++++ .../persistence/dao/IOperations.java | 2 +- .../{spring => }/persistence/model/Foo.java | 2 +- .../persistence/service/FooService.java | 6 ++--- .../config => }/PersistenceConfig.java | 2 +- .../config => }/PersistenceXmlConfig.java | 2 +- .../spring/persistence/dao/IFooDao.java | 7 ----- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 ----- .../src/main/webapp/WEB-INF/web.xml | 27 ++++++++++--------- .../FooServicePersistenceIntegrationTest.java | 5 ++-- spring-hibernate4/.springBeans | 1 - .../baeldung/persistence/dao/IChildDao.java | 8 ++++++ .../org/baeldung/persistence/dao/IFooDao.java | 8 ++++++ .../baeldung/persistence/dao/IParentDao.java | 8 ++++++ .../dao/common/AbstractHibernateDao.java | 2 +- .../persistence/dao/common/IOperations.java | 2 +- .../persistence/dao/impl/ChildDao.java | 8 +++--- .../persistence/dao/impl/FooDao.java | 8 +++--- .../persistence/dao/impl/ParentDao.java | 8 +++--- .../{spring => }/persistence/model/Child.java | 2 +- .../{spring => }/persistence/model/Foo.java | 2 +- .../persistence/model/Parent.java | 2 +- .../persistence/service/IChildService.java | 8 ++++++ .../persistence/service/IFooService.java | 8 ++++++ .../persistence/service/IParentService.java | 8 ++++++ .../service/common/AbstractService.java | 4 +-- .../service/impl/ChildService.java | 12 ++++----- .../persistence/service/impl/FooService.java | 12 ++++----- .../service/impl/ParentService.java | 12 ++++----- .../config => }/HibernateXmlConfig.java | 2 +- .../config => }/PersistenceConfig.java | 2 +- .../spring/persistence/dao/IChildDao.java | 8 ------ .../spring/persistence/dao/IFooDao.java | 8 ------ .../spring/persistence/dao/IParentDao.java | 8 ------ .../persistence/service/IChildService.java | 8 ------ .../persistence/service/IFooService.java | 8 ------ .../persistence/service/IParentService.java | 8 ------ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 ----- .../src/main/webapp/WEB-INF/view/sample.jsp | 7 ----- .../src/main/webapp/WEB-INF/web.xml | 27 ++++++++++--------- .../FooServicePersistenceIntegrationTest.java | 5 ++-- ...rentServicePersistenceIntegrationTest.java | 8 +++--- 45 files changed, 143 insertions(+), 158 deletions(-) rename spring-hibernate3/src/main/java/org/baeldung/{spring => }/persistence/dao/AbstractHibernateDao.java (97%) rename spring-hibernate3/src/main/java/org/baeldung/{spring => }/persistence/dao/FooDao.java (70%) create mode 100644 spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IFooDao.java rename spring-hibernate3/src/main/java/org/baeldung/{spring => }/persistence/dao/IOperations.java (87%) rename spring-hibernate3/src/main/java/org/baeldung/{spring => }/persistence/model/Foo.java (97%) rename spring-hibernate3/src/main/java/org/baeldung/{spring => }/persistence/service/FooService.java (73%) rename spring-hibernate3/src/main/java/org/baeldung/spring/{persistence/config => }/PersistenceConfig.java (98%) rename spring-hibernate3/src/main/java/org/baeldung/spring/{persistence/config => }/PersistenceXmlConfig.java (91%) delete mode 100644 spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java delete mode 100644 spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IChildDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IParentDao.java rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/dao/common/AbstractHibernateDao.java (96%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/dao/common/IOperations.java (85%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/dao/impl/ChildDao.java (63%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/dao/impl/FooDao.java (63%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/dao/impl/ParentDao.java (63%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/model/Child.java (94%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/model/Foo.java (97%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/model/Parent.java (96%) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IChildService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IParentService.java rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/service/common/AbstractService.java (87%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/service/impl/ChildService.java (52%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/service/impl/FooService.java (52%) rename spring-hibernate4/src/main/java/org/baeldung/{spring => }/persistence/service/impl/ParentService.java (53%) rename spring-hibernate4/src/main/java/org/baeldung/spring/{persistence/config => }/HibernateXmlConfig.java (92%) rename spring-hibernate4/src/main/java/org/baeldung/spring/{persistence/config => }/PersistenceConfig.java (98%) delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java delete mode 100644 spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-hibernate3/.springBeans b/spring-hibernate3/.springBeans index 7623a7e88836..b854542b588b 100644 --- a/spring-hibernate3/.springBeans +++ b/spring-hibernate3/.springBeans @@ -7,7 +7,6 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java similarity index 97% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java rename to spring-hibernate3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java index 9a579245d39d..0f8b13289172 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/AbstractHibernateDao.java +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.persistence.dao; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java similarity index 70% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java rename to spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java index 1c76ed1f0405..23de04169eb4 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/FooDao.java +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java @@ -1,6 +1,6 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.persistence.dao; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; import org.springframework.stereotype.Repository; @Repository diff --git a/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..6a3bd95d71b8 --- /dev/null +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,7 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IOperations.java similarity index 87% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java rename to spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IOperations.java index 51591c57b433..8c5a5e1aed77 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IOperations.java +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao; +package org.baeldung.persistence.dao; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/model/Foo.java similarity index 97% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-hibernate3/src/main/java/org/baeldung/persistence/model/Foo.java index 2043d087e024..8e1dee33e845 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.model; +package org.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/service/FooService.java similarity index 73% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java rename to spring-hibernate3/src/main/java/org/baeldung/persistence/service/FooService.java index 1d3b5c4a0201..b07698c43854 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/service/FooService.java +++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/service/FooService.java @@ -1,7 +1,7 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; -import org.baeldung.spring.persistence.dao.IFooDao; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java similarity index 98% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java index 769f3132f522..b205c27cdc63 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import java.util.Properties; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java similarity index 91% rename from spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java rename to spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java index e38b57fbcaf8..c535d1b1bd1b 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/config/PersistenceXmlConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ImportResource; diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java deleted file mode 100644 index eea1f17b5a0d..000000000000 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -import org.baeldung.spring.persistence.model.Foo; - -public interface IFooDao extends IOperations { - // -} diff --git a/spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index 5463820874c8..000000000000 --- a/spring-hibernate3/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-hibernate3/src/main/webapp/WEB-INF/web.xml b/spring-hibernate3/src/main/webapp/WEB-INF/web.xml index e0de9aefd45a..5db6f59746c4 100644 --- a/spring-hibernate3/src/main/webapp/WEB-INF/web.xml +++ b/spring-hibernate3/src/main/webapp/WEB-INF/web.xml @@ -1,17 +1,18 @@ - - Spring MVC Application - - contextClass - + + Spring Hibernate 3 Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.persistence.config - - - org.springframework.web.context.ContextLoaderListener - + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + \ No newline at end of file diff --git a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 576f536adc80..974498535652 100644 --- a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -2,8 +2,9 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.spring.persistence.config.PersistenceConfig; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.FooService; +import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-hibernate4/.springBeans b/spring-hibernate4/.springBeans index 7623a7e88836..b854542b588b 100644 --- a/spring-hibernate4/.springBeans +++ b/spring-hibernate4/.springBeans @@ -7,7 +7,6 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IChildDao.java new file mode 100644 index 000000000000..3bc0dc1fc497 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IChildDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Child; + +public interface IChildDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..fc3928d8a648 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IParentDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IParentDao.java new file mode 100644 index 000000000000..09158a414399 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IParentDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Parent; + +public interface IParentDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java similarity index 96% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java index 3476b8cadc9e..048253d17a75 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao.common; +package org.baeldung.persistence.dao.common; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IOperations.java similarity index 85% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IOperations.java index 12ac048d745c..1c84b06c8569 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/common/IOperations.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.dao.common; +package org.baeldung.persistence.dao.common; import java.io.Serializable; import java.util.List; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java similarity index 63% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java index 380787823c92..d9c8fdceecdf 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ChildDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java @@ -1,8 +1,8 @@ -package org.baeldung.spring.persistence.dao.impl; +package org.baeldung.persistence.dao.impl; -import org.baeldung.spring.persistence.dao.IChildDao; -import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; -import org.baeldung.spring.persistence.model.Child; +import org.baeldung.persistence.dao.IChildDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Child; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java similarity index 63% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java index c083b41799b5..4441215a94d0 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java @@ -1,8 +1,8 @@ -package org.baeldung.spring.persistence.dao.impl; +package org.baeldung.persistence.dao.impl; -import org.baeldung.spring.persistence.dao.IFooDao; -import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Foo; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java similarity index 63% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java index 6604c7a77430..003ec627411a 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/impl/ParentDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java @@ -1,8 +1,8 @@ -package org.baeldung.spring.persistence.dao.impl; +package org.baeldung.persistence.dao.impl; -import org.baeldung.spring.persistence.dao.IParentDao; -import org.baeldung.spring.persistence.dao.common.AbstractHibernateDao; -import org.baeldung.spring.persistence.model.Parent; +import org.baeldung.persistence.dao.IParentDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Parent; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Child.java similarity index 94% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/model/Child.java index 978502242c15..4eec4cf1d3a4 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Child.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Child.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.model; +package org.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java similarity index 97% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 2043d087e024..8e1dee33e845 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.model; +package org.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Parent.java similarity index 96% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/model/Parent.java index 5a8702896001..19e405615dfe 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/model/Parent.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Parent.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.model; +package org.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IChildService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IChildService.java new file mode 100644 index 000000000000..c6c5e2cfb177 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Child; + +public interface IChildService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooService.java new file mode 100644 index 000000000000..877432045056 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IParentService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IParentService.java new file mode 100644 index 000000000000..1782c281d2fe --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IParentService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Parent; + +public interface IParentService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java similarity index 87% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 6d0f2f49d623..3b32bc3ebb59 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/common/AbstractService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -1,9 +1,9 @@ -package org.baeldung.spring.persistence.service.common; +package org.baeldung.persistence.service.common; import java.io.Serializable; import java.util.List; -import org.baeldung.spring.persistence.dao.common.IOperations; +import org.baeldung.persistence.dao.common.IOperations; import org.springframework.transaction.annotation.Transactional; @Transactional diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java similarity index 52% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java index d28682fdfd7c..2ea64285b305 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ChildService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java @@ -1,10 +1,10 @@ -package org.baeldung.spring.persistence.service.impl; +package org.baeldung.persistence.service.impl; -import org.baeldung.spring.persistence.dao.IChildDao; -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Child; -import org.baeldung.spring.persistence.service.IChildService; -import org.baeldung.spring.persistence.service.common.AbstractService; +import org.baeldung.persistence.dao.IChildDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Child; +import org.baeldung.persistence.service.IChildService; +import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java similarity index 52% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java index 19223a82ca4a..4b76eba3e50f 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -1,10 +1,10 @@ -package org.baeldung.spring.persistence.service.impl; +package org.baeldung.persistence.service.impl; -import org.baeldung.spring.persistence.dao.IFooDao; -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Foo; -import org.baeldung.spring.persistence.service.IFooService; -import org.baeldung.spring.persistence.service.common.AbstractService; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java similarity index 53% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java rename to spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java index 84d42772993c..73239f1d0045 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/impl/ParentService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java @@ -1,10 +1,10 @@ -package org.baeldung.spring.persistence.service.impl; +package org.baeldung.persistence.service.impl; -import org.baeldung.spring.persistence.dao.IParentDao; -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Parent; -import org.baeldung.spring.persistence.service.IParentService; -import org.baeldung.spring.persistence.service.common.AbstractService; +import org.baeldung.persistence.dao.IParentDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Parent; +import org.baeldung.persistence.service.IParentService; +import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java similarity index 92% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java index 51fbcd27c16d..10ead2fd6c1b 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/HibernateXmlConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java similarity index 98% rename from spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index 3157c92e9924..765a37962f62 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/config/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.config; +package org.baeldung.spring; import java.util.Properties; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java deleted file mode 100644 index 0a2180bed3cd..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IChildDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Child; - -public interface IChildDao extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java deleted file mode 100644 index 646b3af228b6..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IFooDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Foo; - -public interface IFooDao extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java deleted file mode 100644 index 1b35ba9f018e..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/dao/IParentDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.dao; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Parent; - -public interface IParentDao extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java deleted file mode 100644 index 785d581c799f..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IChildService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.service; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Child; - -public interface IChildService extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java deleted file mode 100644 index 59d532aa5459..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IFooService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.service; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Foo; - -public interface IFooService extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java b/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java deleted file mode 100644 index 6d37d75354f9..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/persistence/service/IParentService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.spring.persistence.service; - -import org.baeldung.spring.persistence.dao.common.IOperations; -import org.baeldung.spring.persistence.model.Parent; - -public interface IParentService extends IOperations { - // -} diff --git a/spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index 5463820874c8..000000000000 --- a/spring-hibernate4/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp b/spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/spring-hibernate4/src/main/webapp/WEB-INF/view/sample.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-hibernate4/src/main/webapp/WEB-INF/web.xml b/spring-hibernate4/src/main/webapp/WEB-INF/web.xml index e0de9aefd45a..64b5f6826d96 100644 --- a/spring-hibernate4/src/main/webapp/WEB-INF/web.xml +++ b/spring-hibernate4/src/main/webapp/WEB-INF/web.xml @@ -1,17 +1,18 @@ - - Spring MVC Application - - contextClass - + + Spring Hibernate 4 Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.persistence.config - - - org.springframework.web.context.ContextLoaderListener - + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + \ No newline at end of file diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 69d094f5d893..99dd630803d5 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -2,8 +2,9 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.spring.persistence.config.PersistenceConfig; -import org.baeldung.spring.persistence.model.Foo; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java index 753d94ac79ab..1c219ac2fad5 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -1,8 +1,10 @@ package org.baeldung.spring.persistence.service; -import org.baeldung.spring.persistence.config.PersistenceConfig; -import org.baeldung.spring.persistence.model.Child; -import org.baeldung.spring.persistence.model.Parent; +import org.baeldung.persistence.model.Child; +import org.baeldung.persistence.model.Parent; +import org.baeldung.persistence.service.IChildService; +import org.baeldung.persistence.service.IParentService; +import org.baeldung.spring.PersistenceConfig; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; From 2cf72a18ee58f2e79a26e775bae39cf482b1b366 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 15:09:13 +0300 Subject: [PATCH 125/796] generic dao work --- .../dao/common/AbstractHibernateDao.java | 2 +- .../persistence/dao/common/GenericHibernateDao.java | 13 +++++++++++++ .../persistence/dao/common/IGenericDao.java | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java index 048253d17a75..65e57afcb3e5 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -24,7 +24,7 @@ protected final void setClazz(final Class clazzToSet) { @Override public final T findOne(final long id) { - return ((T) getCurrentSession().get(clazz, id)); + return (T) getCurrentSession().get(clazz, id); } @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java new file mode 100644 index 000000000000..47ed13087808 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java @@ -0,0 +1,13 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Repository; + +@Repository +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { + // +} \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java new file mode 100644 index 000000000000..b7876deea491 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java @@ -0,0 +1,7 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; + +public interface IGenericDao extends IOperations { + // +} From a63560bb9fb2db5398df1475cf84779bd129e49e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 1 Jun 2013 19:40:30 +0300 Subject: [PATCH 126/796] security work --- spring-security-basic-auth/README.md | 4 ++-- .../src/main/resources/webSecurityConfig.xml | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md index d013b51e1807..61f509f9e5a3 100644 --- a/spring-security-basic-auth/README.md +++ b/spring-security-basic-auth/README.md @@ -1,5 +1,5 @@ ========= Relevant Article: -- [Spring Security – security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) - +- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index 7734ea5f56af..2b55ca1c7366 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -8,11 +8,9 @@ - - - + From 7175867d2d18bba2d75490dca07ea330f622151c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 12:17:44 +0300 Subject: [PATCH 127/796] initial work on spring security custom projecyt --- spring-security-custom/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-custom/.gitignore | 13 ++ spring-security-custom/.project | 59 +++++ spring-security-custom/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-custom/.springBeans | 14 ++ spring-security-custom/README.md | 5 + spring-security-custom/pom.xml | 215 ++++++++++++++++++ ...uestAwareAuthenticationSuccessHandler.java | 48 ++++ .../RestAuthenticationEntryPoint.java | 23 ++ .../spring/config/ClientWebConfig.java | 17 ++ .../spring/config/SecSecurityConfig.java | 16 ++ .../org/baeldung/spring/config/WebConfig.java | 14 ++ .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 29 +++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + .../src/main/webapp/WEB-INF/web.xml | 50 ++++ .../src/test/resources/.gitignore | 13 ++ 28 files changed, 774 insertions(+) create mode 100644 spring-security-custom/.classpath create mode 100644 spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-custom/.gitignore create mode 100644 spring-security-custom/.project create mode 100644 spring-security-custom/.settings/.jsdtscope create mode 100644 spring-security-custom/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-custom/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-custom/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-custom/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-custom/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-custom/.springBeans create mode 100644 spring-security-custom/README.md create mode 100644 spring-security-custom/pom.xml create mode 100644 spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java create mode 100644 spring-security-custom/src/main/resources/logback.xml create mode 100644 spring-security-custom/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 spring-security-custom/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-custom/src/test/resources/.gitignore diff --git a/spring-security-custom/.classpath b/spring-security-custom/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-custom/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-custom/.gitignore b/spring-security-custom/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-custom/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-custom/.project b/spring-security-custom/.project new file mode 100644 index 000000000000..4299cd37284c --- /dev/null +++ b/spring-security-custom/.project @@ -0,0 +1,59 @@ + + + spring-security-custom + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-security-custom/.settings/.jsdtscope b/spring-security-custom/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-custom/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-custom/.settings/org.eclipse.jdt.core.prefs b/spring-security-custom/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-custom/.settings/org.eclipse.jdt.ui.prefs b/spring-security-custom/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-custom/.settings/org.eclipse.m2e.core.prefs b/spring-security-custom/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-custom/.settings/org.eclipse.wst.common.component b/spring-security-custom/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..6322536a9b64 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-custom/.settings/org.eclipse.wst.validation.prefs b/spring-security-custom/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-custom/.springBeans b/spring-security-custom/.springBeans new file mode 100644 index 000000000000..d11fb034bdc0 --- /dev/null +++ b/spring-security-custom/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/spring-security-custom/README.md b/spring-security-custom/README.md new file mode 100644 index 000000000000..a7dd66cfbadc --- /dev/null +++ b/spring-security-custom/README.md @@ -0,0 +1,5 @@ +Spring Security for REST +========= + +Relevant Articles: +- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml new file mode 100644 index 000000000000..d2083cc1b1a1 --- /dev/null +++ b/spring-security-custom/pom.xml @@ -0,0 +1,215 @@ + + 4.0.0 + org.baeldung + spring-security-custom + 0.1-SNAPSHOT + + spring-security-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-custom + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..698052fa2b00 --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -0,0 +1,48 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; + +public class MySavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + private RequestCache requestCache = new HttpSessionRequestCache(); + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws ServletException, IOException { + final SavedRequest savedRequest = requestCache.getRequest(request, response); + + if (savedRequest == null) { + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + final String targetUrlParameter = getTargetUrlParameter(); + if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { + requestCache.removeRequest(request, response); + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + + clearAuthenticationAttributes(request); + + // Use the DefaultSavedRequest URL + // final String targetUrl = savedRequest.getRedirectUrl(); + // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); + // getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + public void setRequestCache(final RequestCache requestCache) { + this.requestCache = requestCache; + } +} diff --git a/spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java new file mode 100644 index 000000000000..77aa32ff979e --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java @@ -0,0 +1,23 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +/** + * The Entry Point will not redirect to any sort of Login - it will return the 401 + */ +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } + +} \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java new file mode 100644 index 000000000000..1a87fd8a09d7 --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java new file mode 100644 index 000000000000..8d5dfb04092e --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java new file mode 100644 index 000000000000..33efc93b2b44 --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig { + + public WebConfig() { + super(); + } + +} diff --git a/spring-security-custom/src/main/resources/logback.xml b/spring-security-custom/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-custom/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..f53b15752c57 --- /dev/null +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..d7e554666d10 --- /dev/null +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-custom/src/test/resources/.gitignore b/spring-security-custom/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-custom/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From a2e7741d7524e2f7b985d3cf3909a66e56bedff0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 12:22:09 +0300 Subject: [PATCH 128/796] custom authentication provider sample --- .../CustomAuthenticationProvider.java | 42 +++++++++++++++++++ .../src/main/resources/webSecurityConfig.xml | 7 +--- 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java diff --git a/spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java b/spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java new file mode 100644 index 000000000000..e2ea9842afc0 --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java @@ -0,0 +1,42 @@ +package org.baeldung.security; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.stereotype.Component; + +@Component +public class CustomAuthenticationProvider implements AuthenticationProvider { + + public CustomAuthenticationProvider() { + super(); + } + + // API + + @Override + public Authentication authenticate(final Authentication authentication) throws AuthenticationException { + final String name = authentication.getName(); + final String password = authentication.getCredentials().toString(); + if (name.equals("admin") && password.equals("system")) { + final List grantedAuths = new ArrayList<>(); + grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER")); + final Authentication auth = new UsernamePasswordAuthenticationToken(name, password, grantedAuths); + return auth; + } else { + return null; + } + } + + @Override + public boolean supports(final Class authentication) { + return authentication.equals(UsernamePasswordAuthenticationToken.class); + } + +} diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index f53b15752c57..b5d0c46e3f6e 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -18,12 +18,7 @@ - - - - - - + \ No newline at end of file From e5e92b6ae0232b614ce80a28af858cfc6883e33f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 19:10:14 +0300 Subject: [PATCH 129/796] security work --- .../java/org/baeldung/spring/MvcConfig.java | 40 +++++++++++++++++++ .../{config => }/SecSecurityConfig.java | 2 +- .../spring/config/ClientWebConfig.java | 17 -------- .../org/baeldung/spring/config/WebConfig.java | 14 ------- .../src/main/resources/webSecurityConfig.xml | 2 +- .../security/CustomLogoutSuccessHandler.java | 2 +- .../ClientWebConfig.java => MvcConfig.java} | 6 +-- .../{web/config => }/SecSecurityConfig.java | 2 +- 8 files changed, 47 insertions(+), 38 deletions(-) create mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java rename spring-security-custom/src/main/java/org/baeldung/spring/{config => }/SecSecurityConfig.java (91%) delete mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java delete mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java rename spring-security-login/src/main/java/org/baeldung/{spring => }/security/CustomLogoutSuccessHandler.java (96%) rename spring-security-login/src/main/java/org/baeldung/spring/{web/config/ClientWebConfig.java => MvcConfig.java} (89%) rename spring-security-login/src/main/java/org/baeldung/spring/{web/config => }/SecSecurityConfig.java (87%) diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..4570857b306d --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,40 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 91% rename from spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java rename to spring-security-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 8d5dfb04092e..4ce80dab9f1c 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java deleted file mode 100644 index 1a87fd8a09d7..000000000000 --- a/spring-security-custom/src/main/java/org/baeldung/spring/config/ClientWebConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@EnableWebMvc -@Configuration -public class ClientWebConfig extends WebMvcConfigurerAdapter { - - public ClientWebConfig() { - super(); - } - - // API - -} \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java deleted file mode 100644 index 33efc93b2b44..000000000000 --- a/spring-security-custom/src/main/java/org/baeldung/spring/config/WebConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.web") -public class WebConfig { - - public WebConfig() { - super(); - } - -} diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index b5d0c46e3f6e..85476a2a21fd 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java b/spring-security-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java similarity index 96% rename from spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java rename to spring-security-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java index 4d19744033d0..7360b4e03f07 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/security/CustomLogoutSuccessHandler.java +++ b/spring-security-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.security; +package org.baeldung.security; import java.io.IOException; diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 89% rename from spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-security-login/src/main/java/org/baeldung/spring/MvcConfig.java index 316759b24b3a..f6f3e2a429cb 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,9 +11,9 @@ @EnableWebMvc @Configuration -public class ClientWebConfig extends WebMvcConfigurerAdapter { +public class MvcConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { + public MvcConfig() { super(); } diff --git a/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java b/spring-security-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 87% rename from spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java rename to spring-security-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java index a21a05c17d2d..4da114c78b62 100644 --- a/spring-security-login/src/main/java/org/baeldung/spring/web/config/SecSecurityConfig.java +++ b/spring-security-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; From 56c520a6941ef35147b52b4bb37068e53eba2335 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 19:15:40 +0300 Subject: [PATCH 130/796] security work on custom project --- spring-security-custom/.springBeans | 2 +- .../java/org/baeldung/spring/MvcConfig.java | 2 +- .../{api-servlet.xml => mvc-servlet.xml} | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 9 +++ .../src/main/webapp/WEB-INF/web.xml | 8 +- .../src/main/webapp/WEB-INF/web.xml | 78 +++++++++---------- 6 files changed, 53 insertions(+), 46 deletions(-) rename spring-security-custom/src/main/webapp/WEB-INF/{api-servlet.xml => mvc-servlet.xml} (100%) create mode 100644 spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-custom/.springBeans b/spring-security-custom/.springBeans index d11fb034bdc0..7623a7e88836 100644 --- a/spring-security-custom/.springBeans +++ b/spring-security-custom/.springBeans @@ -7,7 +7,7 @@ - src/main/webapp/WEB-INF/api-servlet.xml + src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java index 4570857b306d..c14cf3de1176 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -23,7 +23,7 @@ public MvcConfig() { public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - registry.addViewController("/login.html"); + // registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); } diff --git a/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..5504d2f134ee --- /dev/null +++ b/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,9 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

This is the body of the sample view

+ ">Logout + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index d7e554666d10..c8d785a29842 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -15,7 +15,7 @@ contextConfigLocation - org.baeldung.spring.config + org.baeldung.spring @@ -24,13 +24,13 @@ - api + mvc org.springframework.web.servlet.DispatcherServlet 1 - api - /api/* + mvc + / diff --git a/spring-security-login/src/main/webapp/WEB-INF/web.xml b/spring-security-login/src/main/webapp/WEB-INF/web.xml index 6274cdd9fe95..c8d785a29842 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-login/src/main/webapp/WEB-INF/web.xml @@ -1,52 +1,50 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring.web.config - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file From 1696627374a4772f4360f5a28bdc618b73b36ebb Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 19:27:41 +0300 Subject: [PATCH 131/796] security work --- .../java/org/baeldung/spring/MvcConfig.java | 2 +- .../src/main/resources/webSecurityConfig.xml | 31 ++++++++++++------- .../src/main/webapp/WEB-INF/view/login.jsp | 26 ++++++++++++++++ .../src/main/resources/webSecurityConfig.xml | 12 +++---- 4 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java index c14cf3de1176..4570857b306d 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -23,7 +23,7 @@ public MvcConfig() { public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - // registry.addViewController("/login.html"); + registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); } diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index 85476a2a21fd..8f833abc2938 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -1,24 +1,31 @@ + http://www.springframework.org/schema/security + http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - + + + + - + - - - - + + + + + + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..013ceccb4e4d --- /dev/null +++ b/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,26 @@ + + + + +

Login

+ +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+ + + \ No newline at end of file diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index e2b63fe45820..6051a8505bba 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -2,16 +2,14 @@ + http://www.springframework.org/schema/security + http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - - - - + From d3bbcc89fbf997de7c8ebf0e96aabebb519415e0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 19:29:00 +0300 Subject: [PATCH 132/796] security work --- .../src/main/resources/webSecurityConfig.xml | 11 +---------- .../src/main/webapp/WEB-INF/view/homepage.jsp | 1 - 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index 8f833abc2938..d6840d0fcce0 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -7,7 +7,6 @@ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - @@ -17,15 +16,7 @@ - - - - - + - - - - \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp index 5504d2f134ee..a958bc0a0892 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -4,6 +4,5 @@

This is the body of the sample view

- ">Logout \ No newline at end of file From 124f0492ed56b800399033d2635e47d4b76109fd Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Sun, 2 Jun 2013 19:50:09 +0300 Subject: [PATCH 133/796] compiler work --- spring-security-custom/pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index d2083cc1b1a1..4477b0b41cec 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -136,7 +136,19 @@ - + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + org.apache.maven.plugins maven-surefire-plugin From d28c7a14f864e19d6587692f79fe28ea76813129 Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Sun, 2 Jun 2013 19:59:08 +0300 Subject: [PATCH 134/796] security work --- .../spring/{config => }/FrontendConfig.java | 2 +- .../{config => }/PersistenceConfig.java | 2 +- .../{config => }/SecSecurityConfig.java | 2 +- .../spring/{config => }/WebConfig.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- .../java/org/baeldung/spring/WebConfig.java | 17 ++++++++++ .../web/controller/FooController.java | 34 +++++++++++++++++++ .../main/java/org/baeldung/web/dto/Foo.java | 11 ++++++ .../spring/{config => }/ClientWebConfig.java | 2 +- .../{config => }/SecSecurityConfig.java | 2 +- .../spring/{config => }/WebConfig.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- 12 files changed, 71 insertions(+), 9 deletions(-) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{config => }/FrontendConfig.java (97%) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{config => }/PersistenceConfig.java (88%) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{config => }/SecSecurityConfig.java (91%) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{config => }/WebConfig.java (91%) create mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java rename spring-security-rest/src/main/java/org/baeldung/spring/{config => }/ClientWebConfig.java (91%) rename spring-security-rest/src/main/java/org/baeldung/spring/{config => }/SecSecurityConfig.java (91%) rename spring-security-rest/src/main/java/org/baeldung/spring/{config => }/WebConfig.java (87%) diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java similarity index 97% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java index 693b1006b5ce..b353405fc1ff 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/FrontendConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java similarity index 88% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java index 913c5d26ceb9..4ea0053f4845 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 91% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 8d5dfb04092e..4ce80dab9f1c 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java similarity index 91% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java index 20f3bf8f1839..fa6f5f6d5626 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/config/WebConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index adb3e17d7d01..d4ef6ebb8b54 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -17,7 +17,7 @@ contextConfigLocation - org.baeldung.spring.config + org.baeldung.spring diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..fa6f5f6d5626 --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..d6eeea5f771d --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,34 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.util.UriComponentsBuilder; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + +} diff --git a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..352045989daa --- /dev/null +++ b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/ClientWebConfig.java similarity index 91% rename from spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java rename to spring-security-rest/src/main/java/org/baeldung/spring/ClientWebConfig.java index 1a87fd8a09d7..601ba6633040 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/config/ClientWebConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/ClientWebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 91% rename from spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java rename to spring-security-rest/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 8d5dfb04092e..4ce80dab9f1c 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/config/SecSecurityConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java similarity index 87% rename from spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java rename to spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java index 33efc93b2b44..29ddb3eaecf1 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/config/WebConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package org.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index d7e554666d10..fe62026bc7d6 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -15,7 +15,7 @@ contextConfigLocation - org.baeldung.spring.config + org.baeldung.spring From 0eea508ede08428700915ef7edd2b2ee2bcb7c5b Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Sun, 2 Jun 2013 20:08:13 +0300 Subject: [PATCH 135/796] overall security cleanup and fixes --- spring-all/pom.xml | 11 +++++++- spring-security-custom/.springBeans | 2 +- .../java/org/baeldung/spring/MvcConfig.java | 3 +-- .../src/main/resources/webSecurityConfig.xml | 26 +++++++++++-------- .../{mvc-servlet.xml => api-servlet.xml} | 0 .../src/main/webapp/WEB-INF/web.xml | 6 ++--- 6 files changed, 30 insertions(+), 18 deletions(-) rename spring-security-custom/src/main/webapp/WEB-INF/{mvc-servlet.xml => api-servlet.xml} (100%) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 7e93da8b647c..30dd39c40012 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -131,7 +131,16 @@ - + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-custom/.springBeans b/spring-security-custom/.springBeans index 7623a7e88836..d11fb034bdc0 100644 --- a/spring-security-custom/.springBeans +++ b/spring-security-custom/.springBeans @@ -7,7 +7,7 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml + src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java index 4570857b306d..64bdf249445b 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -1,7 +1,6 @@ package org.baeldung.spring; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; @@ -9,8 +8,8 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; +// @Configuration @EnableWebMvc -@Configuration public class MvcConfig extends WebMvcConfigurerAdapter { public MvcConfig() { diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index d6840d0fcce0..590adab8cee4 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -1,22 +1,26 @@ - - - - + + + - + + - + - - - + + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index c8d785a29842..fe62026bc7d6 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -24,13 +24,13 @@ - mvc + api org.springframework.web.servlet.DispatcherServlet 1 - mvc - / + api + /api/* From 79269f8a4328fe20f51a8ff13b279a424538e899 Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Sun, 2 Jun 2013 20:45:26 +0300 Subject: [PATCH 136/796] security and rest work --- .../{FrontendConfig.java => MvcConfig.java} | 6 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- spring-security-custom/pom.xml | 443 +++++++++--------- .../java/org/baeldung/spring/WebConfig.java | 16 +- .../main/java/org/baeldung/web/dto/Foo.java | 3 + .../src/main/webapp/WEB-INF/web.xml | 78 +-- 6 files changed, 291 insertions(+), 257 deletions(-) rename spring-security-basic-auth/src/main/java/org/baeldung/spring/{FrontendConfig.java => MvcConfig.java} (92%) diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 92% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java index b353405fc1ff..74c11478ee2e 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java @@ -9,11 +9,11 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; -@EnableWebMvc @Configuration -public class FrontendConfig extends WebMvcConfigurerAdapter { +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { - public FrontendConfig() { + public MvcConfig() { super(); } diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index d4ef6ebb8b54..461f32bde524 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -6,7 +6,7 @@ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring Security Basic Auth Application diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index 4477b0b41cec..dba76c6a143a 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -1,142 +1,157 @@ - - 4.0.0 - org.baeldung - spring-security-custom - 0.1-SNAPSHOT - - spring-security-custom - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-custom - - - src/main/resources - true - - - - - + + 4.0.0 + org.baeldung + spring-security-custom + 0.1-SNAPSHOT + + spring-security-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-custom + + + src/main/resources + true + + + + + org.apache.maven.plugins maven-compiler-plugin @@ -148,80 +163,80 @@ source - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.2.Final - 5.1.25 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.0 - 1.8.9 - - - 1.4.2 - 2.14.1 - + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java index fa6f5f6d5626..8c3d677af601 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java @@ -1,10 +1,16 @@ package org.baeldung.spring; +import java.util.List; + import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration +@EnableWebMvc @ComponentScan("org.baeldung.web") public class WebConfig extends WebMvcConfigurerAdapter { @@ -12,6 +18,14 @@ public WebConfig() { super(); } - // API + // beans + + @Override + public void configureMessageConverters(final List> converters) { + super.configureMessageConverters(converters); + converters.add(new MappingJackson2HttpMessageConverter()); + } + + // } \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java index 352045989daa..09c1dac933fe 100644 --- a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java +++ b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java @@ -2,6 +2,9 @@ import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement public class Foo implements Serializable { public Foo() { diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index fe62026bc7d6..db64386b1480 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,52 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring Security Custom Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + index.html + \ No newline at end of file From 8dbb7fa83e5656bf1c78a69b0475718f61851564 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 2 Jun 2013 21:10:06 +0300 Subject: [PATCH 137/796] doc work --- spring-security-custom/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-security-custom/README.md b/spring-security-custom/README.md index a7dd66cfbadc..ebf695b9e3ec 100644 --- a/spring-security-custom/README.md +++ b/spring-security-custom/README.md @@ -2,4 +2,5 @@ Spring Security for REST ========= Relevant Articles: -- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file +- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) +- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) \ No newline at end of file From bc0ca7a54c3a71d9a50924b59f92c7e3d0ebfc21 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 17:54:58 +0300 Subject: [PATCH 138/796] git security rest full --- spring-security-rest-full/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-rest-full/.gitignore | 13 ++ spring-security-rest-full/.project | 59 +++++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-rest-full/.springBeans | 14 ++ spring-security-rest-full/README.md | 5 + spring-security-rest-full/pom.xml | 216 ++++++++++++++++++ .../persistence/service/FooService.java | 23 ++ .../MyBasicAuthenticationEntryPoint.java | 31 +++ .../java/org/baeldung/spring/MvcConfig.java | 39 ++++ .../baeldung/spring/PersistenceConfig.java | 14 ++ .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 17 ++ .../web/controller/FooController.java | 74 ++++++ .../org/baeldung/web/controller/LinkUtil.java | 30 +++ .../web/controller/ResourceCreated.java | 35 +++ ...esourceCreatedDiscoverabilityListener.java | 35 +++ .../controller/SingleResourceRetrieved.java | 29 +++ ...ourceRetrievedDiscoverabilityListener.java | 32 +++ .../web/controller/TestController.java | 28 +++ .../main/java/org/baeldung/web/dto/Foo.java | 11 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 25 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 52 +++++ .../src/test/resources/.gitignore | 13 ++ 38 files changed, 1076 insertions(+) create mode 100644 spring-security-rest-full/.classpath create mode 100644 spring-security-rest-full/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-rest-full/.gitignore create mode 100644 spring-security-rest-full/.project create mode 100644 spring-security-rest-full/.settings/.jsdtscope create mode 100644 spring-security-rest-full/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-rest-full/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-rest-full/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-rest-full/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-rest-full/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-rest-full/.springBeans create mode 100644 spring-security-rest-full/README.md create mode 100644 spring-security-rest-full/pom.xml create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-rest-full/src/main/resources/logback.xml create mode 100644 spring-security-rest-full/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-rest-full/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-rest-full/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-rest-full/src/test/resources/.gitignore diff --git a/spring-security-rest-full/.classpath b/spring-security-rest-full/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-rest-full/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-rest-full/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest-full/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-rest-full/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest-full/.gitignore b/spring-security-rest-full/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-full/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-full/.project b/spring-security-rest-full/.project new file mode 100644 index 000000000000..f2aa3ca83eb0 --- /dev/null +++ b/spring-security-rest-full/.project @@ -0,0 +1,59 @@ + + + spring-security-basic-auth + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-security-rest-full/.settings/.jsdtscope b/spring-security-rest-full/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-rest-full/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-full/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest-full/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest-full/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest-full/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-rest-full/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest-full/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-rest-full/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest-full/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.common.component b/spring-security-rest-full/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..83a7bf94e7a2 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-full/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest-full/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-rest-full/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-rest-full/.springBeans b/spring-security-rest-full/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-rest-full/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md new file mode 100644 index 000000000000..61f509f9e5a3 --- /dev/null +++ b/spring-security-rest-full/README.md @@ -0,0 +1,5 @@ +========= + +Relevant Article: +- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml new file mode 100644 index 000000000000..e6c8b1706634 --- /dev/null +++ b/spring-security-rest-full/pom.xml @@ -0,0 +1,216 @@ + + 4.0.0 + org.baeldung + spring-security-basic-auth + 0.1-SNAPSHOT + + spring-security-basic-auth + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-basic-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..02db7a733a6b --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,23 @@ +package org.baeldung.persistence.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public FooService() { + super(); + } + + // API + + public Foo getById(final Long id) { + return null; + } + + public Long create(final Foo resource) { + return null; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 000000000000..968237227f63 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,31 @@ +package org.baeldung.security.basic; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..74c11478ee2e --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java new file mode 100644 index 000000000000..4ea0053f4845 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.persistence") +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..fa6f5f6d5626 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..daa797ee368e --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,74 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.service.FooService; +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private FooService service; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java new file mode 100644 index 000000000000..a41ebb5a5cdd --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java new file mode 100644 index 000000000000..a67788810161 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfNewResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 000000000000..8d19ef82fc63 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletRequest request = resourceCreatedEvent.getRequest(); + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(request, response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + final String requestUrl = request.getRequestURL().toString(); + final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java new file mode 100644 index 000000000000..3de791810549 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java @@ -0,0 +1,29 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..45cd7c4d131a --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,32 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletRequest request = resourceRetrievedEvent.getRequest(); + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(request, response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { + final StringBuffer requestURL = request.getRequestURL(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader("Link", linkHeaderValue); + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java new file mode 100644 index 000000000000..f68cfb2eb7dc --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..352045989daa --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-rest-full/src/main/resources/logback.xml b/spring-security-rest-full/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-rest-full/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..2b55ca1c7366 --- /dev/null +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-rest-full/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..461f32bde524 --- /dev/null +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + Spring Security Basic Auth Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + + + \ No newline at end of file diff --git a/spring-security-rest-full/src/test/resources/.gitignore b/spring-security-rest-full/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-full/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 3201a925ca4dcb2d69664441b8dbd1409a764f3e Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:01:44 +0300 Subject: [PATCH 139/796] cleanup work --- spring-hibernate4/pom.xml | 389 +++++++++--------- .../baeldung/spring/PersistenceConfig.java | 2 +- spring-security-rest-full/.project | 2 +- .../org.eclipse.wst.common.component | 6 +- spring-security-rest-full/README.md | 4 - spring-security-rest-full/pom.xml | 87 ++-- .../MyBasicAuthenticationEntryPoint.java | 31 -- .../baeldung/spring/PersistenceConfig.java | 69 +++- .../src/main/resources/webSecurityConfig.xml | 2 +- 9 files changed, 324 insertions(+), 268 deletions(-) delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index fd0fe6f121de..877388483133 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -1,196 +1,197 @@ - - 4.0.0 - org.baeldung - spring-hibernate4 - 0.1-SNAPSHOT - - spring-hibernate4 - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.javassist - javassist - 3.17.1-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.apache.commons - commons-lang3 - 3.1 - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-hibernate4 - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.2.Final - 5.1.25 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.0 - 1.8.9 - - - 1.4.2 - 2.14.1 - + + 4.0.0 + org.baeldung + spring-hibernate4 + 0.1-SNAPSHOT + + spring-hibernate4 + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.apache.commons + commons-lang3 + 3.1 + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate4 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index 765a37962f62..0c79b1aaa8fa 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -21,7 +21,7 @@ @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence" }) public class PersistenceConfig { @Autowired diff --git a/spring-security-rest-full/.project b/spring-security-rest-full/.project index f2aa3ca83eb0..e914491b964d 100644 --- a/spring-security-rest-full/.project +++ b/spring-security-rest-full/.project @@ -1,6 +1,6 @@ - spring-security-basic-auth + spring-security-rest-full diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.common.component b/spring-security-rest-full/.settings/org.eclipse.wst.common.component index 83a7bf94e7a2..174b04e48ddc 100644 --- a/spring-security-rest-full/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-full/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 61f509f9e5a3..f39e977cecb9 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -1,5 +1 @@ ========= - -Relevant Article: -- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) -- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index e6c8b1706634..63905110a6db 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-basic-auth + spring-security-rest-full 0.1-SNAPSHOT - spring-security-basic-auth + spring-security-rest-full war @@ -72,6 +72,31 @@ ${org.springframework.version}
+ + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.javassist + javassist + 3.17.1-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + @@ -128,7 +153,7 @@ - spring-security-basic-auth + spring-security-rest-full src/main/resources @@ -141,7 +166,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + ${maven-surefire-plugin.version} @@ -155,7 +180,7 @@ org.codehaus.cargo cargo-maven2-plugin - ${cargo-maven2-plugin.version} + ${cargo-maven2-plugin.version} true @@ -178,39 +203,39 @@ - - 3.2.3.RELEASE - 3.1.4.RELEASE + + 3.2.3.RELEASE + 3.1.4.RELEASE - - 4.2.2.Final - 5.1.25 + + 4.2.2.Final + 5.1.25 - - 1.7.5 - 1.0.11 + + 1.7.5 + 1.0.11 - - 5.0.1.Final + + 5.0.1.Final - - 14.0.1 - 3.1 + + 14.0.1 + 3.1 - - 1.3 - 4.11 - 1.9.5 + + 1.3 + 4.11 + 1.9.5 - 4.2.4 - 4.2.5 + 4.2.4 + 4.2.5 - 1.8.0 - 1.8.9 + 1.8.0 + 1.8.9 - - 1.4.2 - 2.14.1 - + + 1.4.2 + 2.14.1 +
\ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java deleted file mode 100644 index 968237227f63..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.security.basic; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; -import org.springframework.stereotype.Component; - -@Component -public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { - - @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - final PrintWriter writer = response.getWriter(); - writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); - } - - @Override - public void afterPropertiesSet() throws Exception { - setRealmName("Baeldung"); - super.afterPropertiesSet(); - } - -} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index 4ea0053f4845..0c79b1aaa8fa 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -1,14 +1,79 @@ package org.baeldung.spring; +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; @Configuration -@ComponentScan("org.baeldung.persistence") +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) public class PersistenceConfig { + @Autowired + private Environment env; + public PersistenceConfig() { super(); } -} + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index 2b55ca1c7366..b43c76e1c83b 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -10,7 +10,7 @@ - + From 6f8e29db09a47b25c6015295066b0b5d7494250f Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:22:54 +0300 Subject: [PATCH 140/796] rest work --- .../org/baeldung/persistence/dao/IFooDao.java | 8 ++ .../dao/common/AbstractHibernateDao.java | 65 +++++++++++++++ .../dao/common/GenericHibernateDao.java | 13 +++ .../persistence/dao/common/IGenericDao.java | 7 ++ .../persistence/dao/common/IOperations.java | 20 +++++ .../org/baeldung/persistence/model/Foo.java | 83 +++++++++++++++++++ .../persistence/service/FooService.java | 23 ----- .../persistence/service/IFooService.java | 8 ++ .../service/common/AbstractService.java | 44 ++++++++++ .../persistence/service/impl/FooService.java | 30 +++++++ .../web/controller/FooController.java | 4 +- .../main/java/org/baeldung/web/dto/Foo.java | 11 --- 12 files changed, 280 insertions(+), 36 deletions(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/model/Foo.java delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..fc3928d8a648 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java new file mode 100644 index 000000000000..65e57afcb3e5 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -0,0 +1,65 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao implements IOperations { + private Class clazz; + + @Autowired + private SessionFactory sessionFactory; + + // API + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } + + @Override + public final T findOne(final long id) { + return (T) getCurrentSession().get(clazz, id); + } + + @Override + public final List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + @Override + public final void create(final T entity) { + Preconditions.checkNotNull(entity); + // getCurrentSession().persist(entity); + getCurrentSession().saveOrUpdate(entity); + } + + @Override + public final T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + @Override + public final void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public final void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java new file mode 100644 index 000000000000..47ed13087808 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java @@ -0,0 +1,13 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Repository; + +@Repository +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { + // +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java new file mode 100644 index 000000000000..b7876deea491 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java @@ -0,0 +1,7 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; + +public interface IGenericDao extends IOperations { + // +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java new file mode 100644 index 000000000000..1c84b06c8569 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java @@ -0,0 +1,20 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + void create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/model/Foo.java new file mode 100644 index 000000000000..8e1dee33e845 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java deleted file mode 100644 index 02db7a733a6b..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.web.dto.Foo; -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - public FooService() { - super(); - } - - // API - - public Foo getById(final Long id) { - return null; - } - - public Long create(final Foo resource) { - return null; - } - -} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java new file mode 100644 index 000000000000..877432045056 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java new file mode 100644 index 000000000000..3b32bc3ebb59 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -0,0 +1,44 @@ +package org.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +public abstract class AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return getDao().findOne(id); + } + + @Override + public List findAll() { + return getDao().findAll(); + } + + @Override + public void create(final T entity) { + getDao().create(entity); + } + + @Override + public T update(final T entity) { + return getDao().update(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(entityId); + } + + protected abstract IOperations getDao(); + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java new file mode 100644 index 000000000000..af77bef98192 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -0,0 +1,30 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.baeldung.persistence.service.common.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class FooService extends AbstractService implements IFooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index daa797ee368e..b20eb3005ec8 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -5,8 +5,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.baeldung.persistence.service.FooService; -import org.baeldung.web.dto.Foo; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.impl.FooService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java deleted file mode 100644 index 352045989daa..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/dto/Foo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.baeldung.web.dto; - -import java.io.Serializable; - -public class Foo implements Serializable { - - public Foo() { - super(); - } - -} From 0fd0f229701e88254f36be3ed2b1f61dc508ba47 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:35:13 +0300 Subject: [PATCH 141/796] persistence work --- spring-security-rest-full/pom.xml | 6 ++ .../{dao/common => }/IOperations.java | 4 +- .../org/baeldung/persistence/dao/IFooDao.java | 5 +- .../dao/common/AbstractHibernateDao.java | 65 ------------------- .../dao/common/GenericHibernateDao.java | 13 ---- .../persistence/dao/common/IGenericDao.java | 7 -- .../persistence/service/IFooService.java | 2 +- .../service/common/AbstractService.java | 19 ++++-- .../persistence/service/impl/FooService.java | 4 +- .../baeldung/spring/PersistenceConfig.java | 2 + .../web/controller/FooController.java | 4 +- .../resources/springDataPersistenceConfig.xml | 9 +++ 12 files changed, 39 insertions(+), 101 deletions(-) rename spring-security-rest-full/src/main/java/org/baeldung/persistence/{dao/common => }/IOperations.java (77%) delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java create mode 100644 spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 63905110a6db..57530026915f 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -80,6 +80,11 @@ spring-orm ${org.springframework.version} + + org.springframework.data + spring-data-jpa + ${spring-data-jpa.version} + org.hibernate hibernate-core @@ -210,6 +215,7 @@ 4.2.2.Final 5.1.25 + 1.3.2.RELEASE 1.7.5 diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java similarity index 77% rename from spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java rename to spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java index 1c84b06c8569..3c6f86a78bd7 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IOperations.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.common; +package org.baeldung.persistence; import java.io.Serializable; import java.util.List; @@ -9,7 +9,7 @@ public interface IOperations { List findAll(); - void create(final T entity); + T create(final T entity); T update(final T entity); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java index fc3928d8a648..b643516d06d9 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -1,8 +1,9 @@ package org.baeldung.persistence.dao; -import org.baeldung.persistence.dao.common.IOperations; import org.baeldung.persistence.model.Foo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -public interface IFooDao extends IOperations { +public interface IFooDao extends JpaRepository, JpaSpecificationExecutor { // } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java deleted file mode 100644 index 65e57afcb3e5..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; - -@SuppressWarnings("unchecked") -public abstract class AbstractHibernateDao implements IOperations { - private Class clazz; - - @Autowired - private SessionFactory sessionFactory; - - // API - - protected final void setClazz(final Class clazzToSet) { - clazz = Preconditions.checkNotNull(clazzToSet); - } - - @Override - public final T findOne(final long id) { - return (T) getCurrentSession().get(clazz, id); - } - - @Override - public final List findAll() { - return getCurrentSession().createQuery("from " + clazz.getName()).list(); - } - - @Override - public final void create(final T entity) { - Preconditions.checkNotNull(entity); - // getCurrentSession().persist(entity); - getCurrentSession().saveOrUpdate(entity); - } - - @Override - public final T update(final T entity) { - Preconditions.checkNotNull(entity); - return (T) getCurrentSession().merge(entity); - } - - @Override - public final void delete(final T entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().delete(entity); - } - - @Override - public final void deleteById(final long entityId) { - final T entity = findOne(entityId); - Preconditions.checkState(entity != null); - delete(entity); - } - - protected final Session getCurrentSession() { - return sessionFactory.getCurrentSession(); - } - -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java deleted file mode 100644 index 47ed13087808..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/GenericHibernateDao.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung.persistence.dao.common; - -import java.io.Serializable; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Repository; - -@Repository -@Scope(BeanDefinition.SCOPE_PROTOTYPE) -public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { - // -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java deleted file mode 100644 index b7876deea491..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/common/IGenericDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.baeldung.persistence.dao.common; - -import java.io.Serializable; - -public interface IGenericDao extends IOperations { - // -} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java index 877432045056..2bfe395df0b5 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -1,6 +1,6 @@ package org.baeldung.persistence.service; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.IOperations; import org.baeldung.persistence.model.Foo; public interface IFooService extends IOperations { diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 3b32bc3ebb59..406a958eec24 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -3,30 +3,35 @@ import java.io.Serializable; import java.util.List; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.IOperations; +import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.transaction.annotation.Transactional; +import com.google.common.collect.Lists; + @Transactional public abstract class AbstractService implements IOperations { @Override + @Transactional(readOnly = true) public T findOne(final long id) { return getDao().findOne(id); } @Override + @Transactional(readOnly = true) public List findAll() { - return getDao().findAll(); + return Lists.newArrayList(getDao().findAll()); } @Override - public void create(final T entity) { - getDao().create(entity); + public T create(final T entity) { + return getDao().save(entity); } @Override public T update(final T entity) { - return getDao().update(entity); + return getDao().save(entity); } @Override @@ -36,9 +41,9 @@ public void delete(final T entity) { @Override public void deleteById(final long entityId) { - getDao().deleteById(entityId); + getDao().delete(entityId); } - protected abstract IOperations getDao(); + protected abstract PagingAndSortingRepository getDao(); } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index af77bef98192..81bd37e3df6b 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -1,11 +1,11 @@ package org.baeldung.persistence.service.impl; import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.dao.common.IOperations; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +23,7 @@ public FooService() { // API @Override - protected IOperations getDao() { + protected PagingAndSortingRepository getDao() { return dao; } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index 0c79b1aaa8fa..93f7f3622fb8 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -22,6 +23,7 @@ @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) +@ImportResource("classpath*:springDataPersistenceConfig.xml") public class PersistenceConfig { @Autowired diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index b20eb3005ec8..cf4b976b907c 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -47,7 +47,7 @@ public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) @ResponseBody public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + final Foo resourceById = Preconditions.checkNotNull(service.findOne(id)); eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); return resourceById; @@ -57,7 +57,7 @@ public Foo get(@PathVariable("id") final Long id, final HttpServletRequest reque @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource); + final Long idOfCreatedResource = service.create(resource).getId(); eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); } diff --git a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml new file mode 100644 index 000000000000..a42410a49ef0 --- /dev/null +++ b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file From b51efabeb5f3bccdc2ced589d37d215c3b1819cd Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:39:05 +0300 Subject: [PATCH 142/796] persistence work --- spring-security-rest-full/pom.xml | 2 +- .../baeldung/spring/PersistenceConfig.java | 35 +++++++++++-------- .../resources/persistence-mysql.properties | 10 ++++++ .../src/main/webapp/WEB-INF/web.xml | 2 +- 4 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 spring-security-rest-full/src/main/resources/persistence-mysql.properties diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 57530026915f..00a2194f9105 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -87,7 +87,7 @@ org.hibernate - hibernate-core + hibernate-entitymanager ${hibernate.version} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index 93f7f3622fb8..91e501b39089 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -13,8 +13,10 @@ import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; @@ -34,17 +36,21 @@ public PersistenceConfig() { } @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); + public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - return sessionFactory; + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + // vendorAdapter.set + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + + return em; } @Bean - public DataSource restDataSource() { + public DataSource dataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); @@ -55,11 +61,11 @@ public DataSource restDataSource() { } @Bean - public HibernateTransactionManager transactionManager() { - final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); + public PlatformTransactionManager transactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactoryBean().getObject()); - return txManager; + return transactionManager; } @Bean @@ -67,7 +73,7 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { return new PersistenceExceptionTranslationPostProcessor(); } - final Properties hibernateProperties() { + final Properties additionalProperties() { return new Properties() { { setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); @@ -78,4 +84,5 @@ final Properties hibernateProperties() { } }; } + } \ No newline at end of file diff --git a/spring-security-rest-full/src/main/resources/persistence-mysql.properties b/spring-security-rest-full/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..8263b0d9accd --- /dev/null +++ b/spring-security-rest-full/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml index 461f32bde524..b02f62911e76 100644 --- a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml @@ -6,7 +6,7 @@ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring Security Basic Auth Application + Spring Security REST Application From 4610d3e1ba91962785ddfa99baf5ce90a0c7a83b Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:42:57 +0300 Subject: [PATCH 143/796] service work --- .../java/org/baeldung/spring/MvcConfig.java | 39 ------------------- .../baeldung/spring/SecSecurityConfig.java | 2 - .../java/org/baeldung/spring/WebConfig.java | 2 + 3 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java deleted file mode 100644 index 74c11478ee2e..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/MvcConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@Configuration -@EnableWebMvc -public class MvcConfig extends WebMvcConfigurerAdapter { - - public MvcConfig() { - super(); - } - - // API - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/homepage.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4ce80dab9f1c..4da114c78b62 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,12 +1,10 @@ package org.baeldung.spring; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java index fa6f5f6d5626..19fcde5fab6f 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java @@ -2,10 +2,12 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration @ComponentScan("org.baeldung.web") +@EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { public WebConfig() { From e68379871e02004c35ff242923889686c4892243 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:46:10 +0300 Subject: [PATCH 144/796] injection work --- spring-security-rest-full/.springBeans | 2 +- .../web/controller/FooController.java | 3 ++ .../web/controller/TestController.java | 28 ------------------- .../web/{controller => util}/LinkUtil.java | 2 +- .../{controller => util}/ResourceCreated.java | 2 +- ...esourceCreatedDiscoverabilityListener.java | 2 +- .../SingleResourceRetrieved.java | 2 +- ...ourceRetrievedDiscoverabilityListener.java | 2 +- .../{mvc-servlet.xml => api-servlet.xml} | 0 .../src/main/webapp/WEB-INF/web.xml | 4 +-- 10 files changed, 11 insertions(+), 36 deletions(-) delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java rename spring-security-rest-full/src/main/java/org/baeldung/web/{controller => util}/LinkUtil.java (95%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{controller => util}/ResourceCreated.java (95%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{controller => util}/ResourceCreatedDiscoverabilityListener.java (97%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{controller => util}/SingleResourceRetrieved.java (94%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{controller => util}/SingleResourceRetrievedDiscoverabilityListener.java (97%) rename spring-security-rest-full/src/main/webapp/WEB-INF/{mvc-servlet.xml => api-servlet.xml} (100%) diff --git a/spring-security-rest-full/.springBeans b/spring-security-rest-full/.springBeans index 7623a7e88836..d11fb034bdc0 100644 --- a/spring-security-rest-full/.springBeans +++ b/spring-security-rest-full/.springBeans @@ -7,7 +7,7 @@ - src/main/webapp/WEB-INF/mvc-servlet.xml + src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index cf4b976b907c..7452cc7c24a4 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -7,6 +7,9 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.impl.FooService; +import org.baeldung.web.util.LinkUtil; +import org.baeldung.web.util.ResourceCreated; +import org.baeldung.web.util.SingleResourceRetrieved; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java deleted file mode 100644 index f68cfb2eb7dc..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class TestController { - - public TestController() { - super(); - } - - // API - - @RequestMapping("/permitAll") - @ResponseBody - public String permitAll() { - return "Permit All"; - } - - @RequestMapping("/securityNone") - @ResponseBody - public String securityNone() { - return "Security None"; - } - -} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java similarity index 95% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java index a41ebb5a5cdd..9e8979e4bded 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/LinkUtil.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package org.baeldung.web.util; import javax.servlet.http.HttpServletResponse; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java similarity index 95% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java index a67788810161..c471cc08180b 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreated.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package org.baeldung.web.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java index 8d19ef82fc63..fbfd2fd085c5 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package org.baeldung.web.util; import java.net.URI; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java similarity index 94% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java index 3de791810549..143a73da652d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package org.baeldung.web.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java index 45cd7c4d131a..61fb601ac903 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package org.baeldung.web.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-security-rest-full/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml index b02f62911e76..d88703596fa6 100644 --- a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml @@ -26,12 +26,12 @@ - mvc + api org.springframework.web.servlet.DispatcherServlet 1 - mvc + api / From 0b4957e84e3bbca619e1dd5c3e7e456aa3a7728b Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:47:26 +0300 Subject: [PATCH 145/796] working rest service --- .../main/java/org/baeldung/web/controller/FooController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 7452cc7c24a4..cc69d42fcbc4 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletResponse; import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.impl.FooService; +import org.baeldung.persistence.service.IFooService; import org.baeldung.web.util.LinkUtil; import org.baeldung.web.util.ResourceCreated; import org.baeldung.web.util.SingleResourceRetrieved; @@ -33,7 +33,7 @@ public class FooController { private ApplicationEventPublisher eventPublisher; @Autowired - private FooService service; + private IFooService service; public FooController() { super(); From 09ad6e1402f5c1413f6d5f8d0d826df4a6a527c0 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:50:11 +0300 Subject: [PATCH 146/796] jackson added --- spring-security-rest-full/pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 00a2194f9105..a8fd265c62a2 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -72,7 +72,6 @@ ${org.springframework.version} - @@ -118,6 +117,14 @@ runtime + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + @@ -215,7 +222,11 @@ 4.2.2.Final 5.1.25 - 1.3.2.RELEASE + 1.3.2.RELEASE + + + + 2.2.2 1.7.5 From 8c532286a524c39c48b7364da65a3106aede10f1 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 3 Jun 2013 18:53:51 +0300 Subject: [PATCH 147/796] find one op --- .../main/java/org/baeldung/web/controller/FooController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index cc69d42fcbc4..bd69ecb36a52 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -26,7 +26,7 @@ import com.google.common.base.Preconditions; @Controller -@RequestMapping(value = "/foo") +@RequestMapping(value = "/foos") public class FooController { @Autowired @@ -44,7 +44,7 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - return new Foo(); + return service.findOne(id); } @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) From 0a2381468c9cd24573907c920472a2bb90fdb44b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 2 Jul 2013 11:04:53 +0300 Subject: [PATCH 148/796] minor maven upgrade --- spring-security-basic-auth/pom.xml | 2 +- spring-security-custom/pom.xml | 2 +- spring-security-login/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index e6c8b1706634..404a21d6e794 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -210,7 +210,7 @@ 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index dba76c6a143a..7e19df91ed4a 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -236,7 +236,7 @@ 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index c797ae3bcbe3..5f11ca98215f 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -202,7 +202,7 @@ 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index a8fd265c62a2..a0d81a323bb0 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -252,7 +252,7 @@ 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 909d32af74a7..0e206379d7d8 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -209,7 +209,7 @@ 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file From 29608c0b363d2b7d4de147f31bf3d38b670c6c27 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 2 Jul 2013 13:14:39 +0300 Subject: [PATCH 149/796] security work - expressions --- spring-security-login/pom.xml | 344 +++++++++--------- .../src/main/webapp/WEB-INF/view/homepage.jsp | 13 + 2 files changed, 187 insertions(+), 170 deletions(-) diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index 5f11ca98215f..48ad53880793 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -1,175 +1,179 @@ - - 4.0.0 - org.baeldung - spring-security-login - 0.1-SNAPSHOT - - spring-security-login - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-login - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin + + 4.0.0 + org.baeldung + spring-security-login + 0.1-SNAPSHOT + + spring-security-login + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-login + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + 3.2.3.RELEASE 3.1.4.RELEASE diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp index 5504d2f134ee..93f9dc2fbdf8 100644 --- a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,9 +1,22 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

This is the body of the sample view

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ ">Logout + \ No newline at end of file From 125073a9d9b9afbacfc4f41f04270f6a307ad551 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 2 Jul 2013 13:54:41 +0300 Subject: [PATCH 150/796] some security work and doc cleanup --- spring-security-login/README.md | 13 ++++++-- spring-security-rest-full/README.md | 15 +++++++++ .../persistence/service/impl/FooService.java | 14 +++++++++ .../web/controller/FooController.java | 30 ++++++++++++------ .../src/main/resources/webSecurityConfig.xml | 31 ++++++++++--------- 5 files changed, 76 insertions(+), 27 deletions(-) diff --git a/spring-security-login/README.md b/spring-security-login/README.md index 3fc9941d1edf..e1efae813e57 100644 --- a/spring-security-login/README.md +++ b/spring-security-login/README.md @@ -1,7 +1,14 @@ ========= -Relevant Articles: -- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) -- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) +## Spring Security Login Tutorial + +### Build the Project +``` +mvn clean install +``` + +### Relevant Articles: +- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) +- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index f39e977cecb9..c30bd3421672 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -1 +1,16 @@ ========= + +## Spring Security REST Tutorial + + +### Build the Project +``` +mvn clean install +``` + + +### Use the REST Service + +``` +curl http://localhost:8080/spring-security-rest-full/foos +``` diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index 81bd37e3df6b..f509068d42ff 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -1,14 +1,19 @@ package org.baeldung.persistence.service.impl; +import java.util.List; + import org.baeldung.persistence.dao.IFooDao; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.google.common.collect.Lists; + @Service @Transactional public class FooService extends AbstractService implements IFooService { @@ -27,4 +32,13 @@ protected PagingAndSortingRepository getDao() { return dao; } + // overridden to be secured + + @Override + @Transactional(readOnly = true) + @PreAuthorize("hasRole('ROLE_ADMIN')") + public List findAll() { + return Lists.newArrayList(getDao().findAll()); + } + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index bd69ecb36a52..dd87dffc4c2e 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,6 +1,7 @@ package org.baeldung.web.controller; import java.net.URI; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,12 +42,20 @@ public FooController() { // API + // read + @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { return service.findOne(id); } + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public List findAll() { + return service.findAll(); + } + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) @ResponseBody public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { @@ -56,15 +65,6 @@ public Foo get(@PathVariable("id") final Long id, final HttpServletRequest reque return resourceById; } - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { - Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource).getId(); - - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); - } - @RequestMapping(value = "admin", method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { @@ -74,4 +74,16 @@ public void adminRoot(final HttpServletRequest request, final HttpServletRespons final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); response.addHeader("Link", linkToFoo); } + + // write + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource).getId(); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + } diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index b43c76e1c83b..08e84b96ec6f 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -1,25 +1,26 @@ - - + - - + + - + - + - - - - - - - + + + + + + + + + \ No newline at end of file From 5acb28dec1fae48e379cceba454cc7f6bf3f5ed3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 10:59:37 +0300 Subject: [PATCH 151/796] minor sec work --- spring-security-login/src/main/resources/webSecurityConfig.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-login/src/main/resources/webSecurityConfig.xml index 6051a8505bba..742d9fdf03c3 100644 --- a/spring-security-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login/src/main/resources/webSecurityConfig.xml @@ -32,6 +32,7 @@ + From 0b375c6d555e6f85798d6373a72f73d6b80999ec Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 11:34:55 +0300 Subject: [PATCH 152/796] minor fixes and maven upgrades --- spring-hibernate4/pom.xml | 4 ++-- .../src/main/java/org/baeldung/spring/PersistenceConfig.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 877388483133..77efc53d64b1 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -186,12 +186,12 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 1.4.2 - 2.14.1 + 2.15
\ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index 0c79b1aaa8fa..ac148859ccf9 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -35,7 +35,7 @@ public PersistenceConfig() { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; From 812ea5881eb8100ce097db1e42a7bf2b4bdbb4c2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 11:40:51 +0300 Subject: [PATCH 153/796] minor maven upgrade --- spring-hibernate4/pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 77efc53d64b1..be921ecef920 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -38,7 +38,7 @@ org.javassist javassist - 3.17.1-GA + ${javassist.version} mysql @@ -68,7 +68,7 @@ org.apache.commons commons-lang3 - 3.1 + ${commons-lang3.version} test @@ -162,6 +162,7 @@ 3.2.3.RELEASE 3.1.4.RELEASE + 3.18.0-GA 4.2.2.Final From 270bd5b7076b0c470d7f5de20acc474869d8e739 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 12:15:44 +0300 Subject: [PATCH 154/796] introducing a real connection pool --- spring-hibernate4/pom.xml | 8 +++++++- .../main/java/org/baeldung/spring/PersistenceConfig.java | 4 ++-- spring-hibernate4/src/main/resources/hibernate4Config.xml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index be921ecef920..ad9bd7f4bb86 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -24,7 +24,7 @@ - + org.springframework spring-orm @@ -47,6 +47,12 @@ runtime + + org.apache.tomcat + tomcat-dbcp + 7.0.41 + + diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index ac148859ccf9..f66e5543169f 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -4,6 +4,7 @@ import javax.sql.DataSource; +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -11,7 +12,6 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.hibernate4.HibernateTransactionManager; import org.springframework.orm.hibernate4.LocalSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -43,7 +43,7 @@ public LocalSessionFactoryBean sessionFactory() { @Bean public DataSource restDataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml index f35de2a4c5db..fc4965255460 100644 --- a/spring-hibernate4/src/main/resources/hibernate4Config.xml +++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml @@ -19,7 +19,7 @@
- + From cb6253a2a575961652830794b8114f5f8d02b591 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 12:49:12 +0300 Subject: [PATCH 155/796] minor maven upgrades and cleanup --- spring-hibernate3/pom.xml | 381 +++++++++++++++++++------------------- spring-hibernate4/pom.xml | 3 +- 2 files changed, 197 insertions(+), 187 deletions(-) diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 1859506e71af..79280963c1e7 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -1,188 +1,197 @@ - - 4.0.0 - org.baeldung - spring-hibernate3 - 0.1-SNAPSHOT - - spring-hibernate3 - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.javassist - javassist - 3.17.1-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-hibernate3 - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 3.6.10.Final - 5.1.25 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.0 - 1.8.9 - - - 1.4.2 - 2.14.1 - + + 4.0.0 + org.baeldung + spring-hibernate3 + 0.1-SNAPSHOT + + spring-hibernate3 + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.javassist + javassist + ${javassist.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-hibernate3 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + 3.18.0-GA + + + 3.6.10.Final + 5.1.25 + 7.0.41 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + \ No newline at end of file diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index ad9bd7f4bb86..f1846c7350e5 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -50,7 +50,7 @@ org.apache.tomcat tomcat-dbcp - 7.0.41 + ${tomcat-dbcp.version} @@ -173,6 +173,7 @@ 4.2.2.Final 5.1.25 + 7.0.41 1.7.5 From 561ec82250fdd96bd8696324a8b32899c4e58b2a Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 12:51:44 +0300 Subject: [PATCH 156/796] connection pooling work --- .../main/java/org/baeldung/spring/PersistenceConfig.java | 6 +++--- spring-hibernate3/src/main/resources/persistenceConfig.xml | 2 +- .../{HibernateXmlConfig.java => PersistenceXmlConfig.java} | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename spring-hibernate4/src/main/java/org/baeldung/spring/{HibernateXmlConfig.java => PersistenceXmlConfig.java} (87%) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java index b205c27cdc63..473c0c1714b4 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -4,6 +4,7 @@ import javax.sql.DataSource; +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -11,7 +12,6 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.hibernate3.HibernateTransactionManager; import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -35,7 +35,7 @@ public PersistenceConfig() { public AnnotationSessionFactoryBean sessionFactory() { final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); sessionFactory.setDataSource(dataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; @@ -43,7 +43,7 @@ public AnnotationSessionFactoryBean sessionFactory() { @Bean public DataSource dataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); diff --git a/spring-hibernate3/src/main/resources/persistenceConfig.xml b/spring-hibernate3/src/main/resources/persistenceConfig.xml index 0dc729f815dd..62bccc1f2252 100644 --- a/spring-hibernate3/src/main/resources/persistenceConfig.xml +++ b/spring-hibernate3/src/main/resources/persistenceConfig.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java similarity index 87% rename from spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java rename to spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java index 10ead2fd6c1b..f7b11b19a225 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/HibernateXmlConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java @@ -9,9 +9,9 @@ @EnableTransactionManagement @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) @ImportResource({ "classpath:hibernate4Config.xml" }) -public class HibernateXmlConfig { +public class PersistenceXmlConfig { - public HibernateXmlConfig() { + public PersistenceXmlConfig() { super(); } From c25eaced346fc4cd9b3f2dd650e0bc5b11289e72 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 23:03:26 +0300 Subject: [PATCH 157/796] minor maven upgrade --- spring-all/pom.xml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 30dd39c40012..9dfb42a62309 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -42,7 +42,7 @@ org.javassist javassist - 3.17.1-GA + ${javassist.version} mysql @@ -71,7 +71,7 @@ javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -84,14 +84,14 @@ - + org.springframework spring-test ${org.springframework.version} test - + junit junit-dep @@ -131,8 +131,8 @@ - - + + org.apache.maven.plugins maven-war-plugin 2.3 @@ -140,7 +140,7 @@ false - + org.apache.maven.plugins maven-surefire-plugin @@ -184,6 +184,8 @@ 3.2.3.RELEASE 3.1.4.RELEASE + 3.18.0-GA + 1.2 4.2.2.Final @@ -208,12 +210,12 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 1.4.2 - 2.14.1 + 2.15 \ No newline at end of file From 3dc244109cd9e7bf9a2b045fde26ebd51fea6fdb Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 23:04:22 +0300 Subject: [PATCH 158/796] minor eclipse artifacts --- spring-all/.classpath | 3 +-- spring-all/.settings/org.eclipse.jdt.core.prefs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-all/.classpath b/spring-all/.classpath index eed10d8a8b04..75e85b7b7568 100644 --- a/spring-all/.classpath +++ b/spring-all/.classpath @@ -22,7 +22,7 @@ - + @@ -30,7 +30,6 @@ - diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-all/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..13a747365774 100644 --- a/spring-all/.settings/org.eclipse.jdt.core.prefs +++ b/spring-all/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 From ac29c2e553fe7d816cc01578c3b7d6923b4392e1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 4 Jul 2013 23:05:27 +0300 Subject: [PATCH 159/796] minor eclipse artifacts --- spring-all/.classpath | 3 ++- spring-all/.settings/org.eclipse.jdt.core.prefs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-all/.classpath b/spring-all/.classpath index 75e85b7b7568..eed10d8a8b04 100644 --- a/spring-all/.classpath +++ b/spring-all/.classpath @@ -22,7 +22,7 @@ - + @@ -30,6 +30,7 @@ + diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-all/.settings/org.eclipse.jdt.core.prefs index 13a747365774..723e5b12451a 100644 --- a/spring-all/.settings/org.eclipse.jdt.core.prefs +++ b/spring-all/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 From bdc54a57b1930af94482f6d310dfec2626523f27 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Jul 2013 01:44:43 +0300 Subject: [PATCH 160/796] bean examples --- .../main/java/org/baeldung/di/core/BeanA.java | 14 ++++++++++++++ .../main/java/org/baeldung/di/core/BeanB.java | 8 ++++++++ .../java/org/baeldung/di/core/IBeanB.java | 5 +++++ .../di/spring/ContextWithJavaConfig.java | 16 ++++++++++++++++ ...dencyInjectionWithJavaIntegrationTest.java | 19 +++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 spring-all/src/main/java/org/baeldung/di/core/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/di/core/BeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/di/core/IBeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java create mode 100644 spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java diff --git a/spring-all/src/main/java/org/baeldung/di/core/BeanA.java b/spring-all/src/main/java/org/baeldung/di/core/BeanA.java new file mode 100644 index 000000000000..714ee490153c --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/di/core/BeanA.java @@ -0,0 +1,14 @@ +package org.baeldung.di.core; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + @Qualifier("beanB2") + private IBeanB dependency; + +} diff --git a/spring-all/src/main/java/org/baeldung/di/core/BeanB.java b/spring-all/src/main/java/org/baeldung/di/core/BeanB.java new file mode 100644 index 000000000000..8ac65e502311 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/di/core/BeanB.java @@ -0,0 +1,8 @@ +package org.baeldung.di.core; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB implements IBeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java b/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java new file mode 100644 index 000000000000..3eec2adc0f8b --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.di.core; + +public interface IBeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java new file mode 100644 index 000000000000..2507a95de3b3 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.di.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.di") +public class ContextWithJavaConfig { + + public ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java new file mode 100644 index 000000000000..f06d930a7f29 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.di.core; + +import org.baeldung.di.spring.ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class DependencyInjectionWithJavaIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 843c33616a6d034242e24d0faf15d74b4a01a6bc Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Jul 2013 11:58:35 +0300 Subject: [PATCH 161/796] exception work --- .../java/org/baeldung/di/core/IBeanB.java | 5 ----- .../di/spring/ContextWithJavaConfig.java | 16 ---------------- .../cause1}/BeanA.java | 8 +++----- .../cause1/BeanB.java | 5 +++++ .../cause3/BeanA.java | 19 +++++++++++++++++++ .../cause3}/BeanB.java | 2 +- .../cause3/IBeanB.java | 5 +++++ .../spring/Cause1ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause2ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause3ContextWithJavaConfig.java | 16 ++++++++++++++++ ...anDefinitionExceptionIntegrationTest.java} | 8 ++++---- ...eanDefinitionExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...eanDefinitionExceptionIntegrationTest.java | 19 +++++++++++++++++++ 13 files changed, 123 insertions(+), 31 deletions(-) delete mode 100644 spring-all/src/main/java/org/baeldung/di/core/IBeanB.java delete mode 100644 spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java rename spring-all/src/main/java/org/baeldung/{di/core => ex/nosuchbeandefinitionexception/cause1}/BeanA.java (51%) create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java rename spring-all/src/main/java/org/baeldung/{di/core => ex/nosuchbeandefinitionexception/cause3}/BeanB.java (63%) create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java rename spring-all/src/test/java/org/baeldung/{di/core/DependencyInjectionWithJavaIntegrationTest.java => ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java} (55%) create mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java diff --git a/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java b/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java deleted file mode 100644 index 3eec2adc0f8b..000000000000 --- a/spring-all/src/main/java/org/baeldung/di/core/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.di.core; - -public interface IBeanB { - // -} diff --git a/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java deleted file mode 100644 index 2507a95de3b3..000000000000 --- a/spring-all/src/main/java/org/baeldung/di/spring/ContextWithJavaConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.di.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.di") -public class ContextWithJavaConfig { - - public ContextWithJavaConfig() { - super(); - } - - // beans - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/di/core/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java similarity index 51% rename from spring-all/src/main/java/org/baeldung/di/core/BeanA.java rename to spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java index 714ee490153c..c664309426ff 100644 --- a/spring-all/src/main/java/org/baeldung/di/core/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java @@ -1,14 +1,12 @@ -package org.baeldung.di.core; +package org.baeldung.ex.nosuchbeandefinitionexception.cause1; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component public class BeanA { @Autowired - @Qualifier("beanB2") - private IBeanB dependency; + private BeanB dependency; -} +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java new file mode 100644 index 000000000000..8a198422e801 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause1; + +public class BeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java new file mode 100644 index 000000000000..4341a11c8475 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause3; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class BeanA implements InitializingBean { + + @Autowired + private ApplicationContext context; + + @Override + public final void afterPropertiesSet() { + context.getBean("test"); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/di/core/BeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java similarity index 63% rename from spring-all/src/main/java/org/baeldung/di/core/BeanB.java rename to spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java index 8ac65e502311..e4461477be54 100644 --- a/spring-all/src/main/java/org/baeldung/di/core/BeanB.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java @@ -1,4 +1,4 @@ -package org.baeldung.di.core; +package org.baeldung.ex.nosuchbeandefinitionexception.cause3; import org.springframework.stereotype.Component; diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java new file mode 100644 index 000000000000..ac3791945227 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause3; + +public interface IBeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java new file mode 100644 index 000000000000..4eb6161f3d9f --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.di.cause1") +public class Cause1ContextWithJavaConfig { + + public Cause1ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java new file mode 100644 index 000000000000..ade8692bb4aa --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.di.cause2") +public class Cause2ContextWithJavaConfig { + + public Cause2ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java new file mode 100644 index 000000000000..21d36f2ba692 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.di.cause2") +public class Cause3ContextWithJavaConfig { + + public Cause3ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java similarity index 55% rename from spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java rename to spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java index f06d930a7f29..aed37a125a85 100644 --- a/spring-all/src/test/java/org/baeldung/di/core/DependencyInjectionWithJavaIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.di.core; +package org.baeldung.ex.nosuchbeandefinitionexception; -import org.baeldung.di.spring.ContextWithJavaConfig; +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; @@ -8,8 +8,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) -public class DependencyInjectionWithJavaIntegrationTest { +@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1NoSuchBeanDefinitionExceptionIntegrationTest { @Test public final void givenContextIsInitialized_thenNoException() { diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java new file mode 100644 index 000000000000..90d7317f4444 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception; + +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause2ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2NoSuchBeanDefinitionExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java new file mode 100644 index 000000000000..0e2123b7ffd7 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception; + +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause3ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3NoSuchBeanDefinitionExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From f380ca54f2df9ebbf9b75dff66842a5e0e37ed5c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Jul 2013 12:01:15 +0300 Subject: [PATCH 162/796] exception work --- .../nosuchbeandefinitionexception/cause2/BeanA.java | 12 ++++++++++++ .../nosuchbeandefinitionexception/cause2/BeanB1.java | 8 ++++++++ .../nosuchbeandefinitionexception/cause2/BeanB2.java | 8 ++++++++ .../nosuchbeandefinitionexception/cause2/IBeanB.java | 5 +++++ .../spring/Cause3ContextWithJavaConfig.java | 2 +- 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java new file mode 100644 index 000000000000..2b454bfabb7a --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private IBeanB dependency; + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java new file mode 100644 index 000000000000..877f40066886 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB1 implements IBeanB { + // +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java new file mode 100644 index 000000000000..6bf4160966e6 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB2 implements IBeanB { + // +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java new file mode 100644 index 000000000000..3e70126c1a94 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +public interface IBeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java index 21d36f2ba692..50fa4f7e53e8 100644 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java @@ -4,7 +4,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.di.cause2") +@ComponentScan("org.baeldung.di.cause3") public class Cause3ContextWithJavaConfig { public Cause3ContextWithJavaConfig() { From 27d0f4358931afd38ee63f33a883d9314747a0ee Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Jul 2013 12:02:10 +0300 Subject: [PATCH 163/796] exception work --- .../spring/Cause1ContextWithJavaConfig.java | 2 +- .../spring/Cause2ContextWithJavaConfig.java | 2 +- .../spring/Cause3ContextWithJavaConfig.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java index 4eb6161f3d9f..5ba971baa9d6 100644 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -4,7 +4,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.di.cause1") +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") public class Cause1ContextWithJavaConfig { public Cause1ContextWithJavaConfig() { diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java index ade8692bb4aa..9f4816ef7c00 100644 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java @@ -4,7 +4,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.di.cause2") +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause2") public class Cause2ContextWithJavaConfig { public Cause2ContextWithJavaConfig() { diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java index 50fa4f7e53e8..a8d0fbe37bf0 100644 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java @@ -4,7 +4,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.di.cause3") +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause3") public class Cause3ContextWithJavaConfig { public Cause3ContextWithJavaConfig() { From 8871fc802eea6c7fa96285e242d835fc8320b54a Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Jul 2013 12:09:10 +0300 Subject: [PATCH 164/796] spring exception work --- .../ex/nosuchbeandefinitionexception/cause3/BeanA.java | 6 +++--- .../ex/nosuchbeandefinitionexception/cause3/BeanB.java | 8 -------- .../ex/nosuchbeandefinitionexception/cause3/IBeanB.java | 5 ----- 3 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java index 4341a11c8475..091d3f1aa82b 100644 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java @@ -12,8 +12,8 @@ public class BeanA implements InitializingBean { private ApplicationContext context; @Override - public final void afterPropertiesSet() { - context.getBean("test"); + public void afterPropertiesSet() { + context.getBean("someBeanName"); } -} +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java deleted file mode 100644 index e4461477be54..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanB.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause3; - -import org.springframework.stereotype.Component; - -@Component -public class BeanB implements IBeanB { - // -} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java deleted file mode 100644 index ac3791945227..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause3; - -public interface IBeanB { - // -} From 200956b783c1c58b7f8302164057ac320a53e6cb Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 15:48:25 +0300 Subject: [PATCH 165/796] minor maven upgrades --- spring-jpa/pom.xml | 4 ++-- spring-mvc-java/pom.xml | 4 ++-- spring-mvc/pom.xml | 4 ++-- spring-security-basic-auth/pom.xml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index e3b864c3e7bb..1f8ba8d6756a 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -186,12 +186,12 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 1.4.2 - 2.14.1 + 2.15 \ No newline at end of file diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index eb3831b4aae7..66e6d8f00940 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -147,12 +147,12 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 1.4.2 - 2.14.1 + 2.15 \ No newline at end of file diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index b46d4b484e78..7427a45896ce 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -147,12 +147,12 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 1.4.2 - 2.14.1 + 2.15 \ No newline at end of file diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 404a21d6e794..16059e3e7e29 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -205,7 +205,7 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 From a07a7d51c7346989a0205f244e20b8cf48639084 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 15:49:40 +0300 Subject: [PATCH 166/796] minor maven upgrades --- spring-mvc-xml/pom.xml | 4 ++-- spring-security-custom/pom.xml | 2 +- spring-security-login/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index ecde675bfcd4..3fd260b79a58 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -131,9 +131,9 @@ 1.9.5 4.2.4 - 4.2.4 + 4.2.5 - 1.8.0 + 1.8.1 1.8.9 diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index 7e19df91ed4a..ac00c65bbce7 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -231,7 +231,7 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index 48ad53880793..4acf8ce02acd 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -201,7 +201,7 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index a0d81a323bb0..e6e4c073c39e 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -247,7 +247,7 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 0e206379d7d8..3cf7aef1285d 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -204,7 +204,7 @@ 4.2.4 4.2.5 - 1.8.0 + 1.8.1 1.8.9 From 10cff430f14d8aabe38656a599a71dada7c3efee Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 15:52:06 +0300 Subject: [PATCH 167/796] initial work on digest security project --- spring-security-digest-auth/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-digest-auth/.gitignore | 13 ++ spring-security-digest-auth/.project | 59 +++++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-digest-auth/.springBeans | 14 ++ spring-security-digest-auth/README.md | 4 + spring-security-digest-auth/pom.xml | 216 ++++++++++++++++++ .../persistence/service/FooService.java | 23 ++ .../MyBasicAuthenticationEntryPoint.java | 31 +++ .../java/org/baeldung/spring/MvcConfig.java | 39 ++++ .../baeldung/spring/PersistenceConfig.java | 14 ++ .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 17 ++ .../web/controller/FooController.java | 74 ++++++ .../org/baeldung/web/controller/LinkUtil.java | 30 +++ .../web/controller/ResourceCreated.java | 35 +++ ...esourceCreatedDiscoverabilityListener.java | 35 +++ .../controller/SingleResourceRetrieved.java | 29 +++ ...ourceRetrievedDiscoverabilityListener.java | 32 +++ .../web/controller/TestController.java | 28 +++ .../main/java/org/baeldung/web/dto/Foo.java | 11 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 25 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 52 +++++ .../src/test/resources/.gitignore | 13 ++ 38 files changed, 1075 insertions(+) create mode 100644 spring-security-digest-auth/.classpath create mode 100644 spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-digest-auth/.gitignore create mode 100644 spring-security-digest-auth/.project create mode 100644 spring-security-digest-auth/.settings/.jsdtscope create mode 100644 spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-digest-auth/.springBeans create mode 100644 spring-security-digest-auth/README.md create mode 100644 spring-security-digest-auth/pom.xml create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java create mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-digest-auth/src/main/resources/logback.xml create mode 100644 spring-security-digest-auth/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-digest-auth/src/test/resources/.gitignore diff --git a/spring-security-digest-auth/.classpath b/spring-security-digest-auth/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-digest-auth/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-digest-auth/.gitignore b/spring-security-digest-auth/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-digest-auth/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-digest-auth/.project b/spring-security-digest-auth/.project new file mode 100644 index 000000000000..a5c72c83aeb6 --- /dev/null +++ b/spring-security-digest-auth/.project @@ -0,0 +1,59 @@ + + + spring-security-digest-auth + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-security-digest-auth/.settings/.jsdtscope b/spring-security-digest-auth/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-digest-auth/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs b/spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs b/spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.common.component b/spring-security-digest-auth/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..6333967c73a3 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-digest-auth/.springBeans b/spring-security-digest-auth/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-digest-auth/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-digest-auth/README.md b/spring-security-digest-auth/README.md new file mode 100644 index 000000000000..e42590f8935a --- /dev/null +++ b/spring-security-digest-auth/README.md @@ -0,0 +1,4 @@ +========= + +Relevant Article: +- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-digest-authentication) diff --git a/spring-security-digest-auth/pom.xml b/spring-security-digest-auth/pom.xml new file mode 100644 index 000000000000..73d1ced5970b --- /dev/null +++ b/spring-security-digest-auth/pom.xml @@ -0,0 +1,216 @@ + + 4.0.0 + org.baeldung + spring-security-digest-auth + 0.1-SNAPSHOT + + spring-security-digest-auth + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-digest-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + + + \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..02db7a733a6b --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,23 @@ +package org.baeldung.persistence.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public FooService() { + super(); + } + + // API + + public Foo getById(final Long id) { + return null; + } + + public Long create(final Foo resource) { + return null; + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 000000000000..968237227f63 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,31 @@ +package org.baeldung.security.basic; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..74c11478ee2e --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java new file mode 100644 index 000000000000..4ea0053f4845 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.persistence") +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..fa6f5f6d5626 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..daa797ee368e --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,74 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.service.FooService; +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private FooService service; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java new file mode 100644 index 000000000000..a41ebb5a5cdd --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java new file mode 100644 index 000000000000..a67788810161 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfNewResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 000000000000..8d19ef82fc63 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletRequest request = resourceCreatedEvent.getRequest(); + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(request, response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + final String requestUrl = request.getRequestURL().toString(); + final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java new file mode 100644 index 000000000000..3de791810549 --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java @@ -0,0 +1,29 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..45cd7c4d131a --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,32 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletRequest request = resourceRetrievedEvent.getRequest(); + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(request, response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { + final StringBuffer requestURL = request.getRequestURL(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader("Link", linkHeaderValue); + } + +} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java new file mode 100644 index 000000000000..f68cfb2eb7dc --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..352045989daa --- /dev/null +++ b/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-digest-auth/src/main/resources/logback.xml b/spring-security-digest-auth/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-digest-auth/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..2b55ca1c7366 --- /dev/null +++ b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..461f32bde524 --- /dev/null +++ b/spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + Spring Security Basic Auth Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + + + \ No newline at end of file diff --git a/spring-security-digest-auth/src/test/resources/.gitignore b/spring-security-digest-auth/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-digest-auth/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From f7a0ef8578b1878c245c2a7b5f4bd86ec9987090 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 16:17:49 +0300 Subject: [PATCH 168/796] digest config work --- .../src/main/resources/webSecurityConfig.xml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml index 2b55ca1c7366..ae554a8b69ef 100644 --- a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml @@ -7,16 +7,27 @@ - + - - + + + + + + + + + + - + From 32f77f46138526699b47ed2044353e6b1f93820e Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 17:33:02 +0300 Subject: [PATCH 169/796] working spring security digest auth configuration --- .../src/main/resources/webSecurityConfig.xml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml index ae554a8b69ef..1d5703cb2614 100644 --- a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml @@ -5,14 +5,6 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - - - - - - - @@ -25,6 +17,13 @@ + + + + + + + From 93c635ca29d79a8e600459e1aabaef5500bdfe5a Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Jul 2013 17:34:50 +0300 Subject: [PATCH 170/796] minor readme work --- spring-security-digest-auth/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-digest-auth/README.md b/spring-security-digest-auth/README.md index e42590f8935a..507104ac6063 100644 --- a/spring-security-digest-auth/README.md +++ b/spring-security-digest-auth/README.md @@ -1,4 +1,4 @@ ========= Relevant Article: -- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-digest-authentication) +- [Spring Security Digest Authentication](http://www.baeldung.com/spring-security-digest-authentication) From e7819aab7976b7631abd25cf3c38f09716ed9fec Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 13 Jul 2013 20:05:54 +0300 Subject: [PATCH 171/796] minor cleanup --- .../baeldung/spring/config/MainWebAppInitializer.java | 2 +- .../src/main/resources/webSecurityConfig.xml | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java index 6eb2dadcf275..5ef83b8afd0b 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java @@ -19,7 +19,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer { */ @Override public void onStartup(final ServletContext sc) throws ServletException { - System.out.println("GreenhouseWebAppInitializer.onStartup()"); + System.out.println("MainWebAppInitializer.onStartup()"); // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index 08e84b96ec6f..de79430530bf 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -1,8 +1,13 @@ - + http://www.springframework.org/schema/security + http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> From f4ac4fa69916c9507bf91169ead589efe3986f08 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:03:04 +0300 Subject: [PATCH 172/796] documentation cleanup --- spring-all/README.md | 9 +++++++-- spring-hibernate3/README.md | 10 +++++++--- spring-hibernate4/README.md | 8 +++++--- spring-jpa/README.md | 5 ++++- spring-mvc-java/README.md | 6 +++++- spring-mvc-xml/README.md | 6 ++++-- spring-mvc/README.md | 5 ++++- spring-security-basic-auth/README.md | 5 ++++- spring-security-custom/README.md | 6 ++++-- spring-security-digest-auth/README.md | 5 ++++- spring-security-login/README.md | 12 ++++++------ spring-security-rest-full/README.md | 2 +- spring-security-rest/README.md | 6 ++++-- 13 files changed, 59 insertions(+), 26 deletions(-) diff --git a/spring-all/README.md b/spring-all/README.md index 78b34858c574..ae8db53b9808 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -1,6 +1,11 @@ ========= -This project is used to replicate Spring Exceptions only. -Relevant articles: + +## Spring Exceptions Example Project + +This project is used to replicate Spring Exceptions only. + + +### Relevant articles: - [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) - [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) - [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) diff --git a/spring-hibernate3/README.md b/spring-hibernate3/README.md index 6dcc602ef07d..f9839e34bff3 100644 --- a/spring-hibernate3/README.md +++ b/spring-hibernate3/README.md @@ -1,10 +1,13 @@ ========= -Relevant Article: +## Spring with Hibernate 3 Example Project + + +### Relevant ArticleS: - [Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) -Quick Start +### Quick Start ``` git clone git://github.com/eugenp/REST.git @@ -12,4 +15,5 @@ cd REST mvn install mvn cargo:run ``` -- note: starts on port 8082 + +- **note**: starts on port `8082` diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index 3c48826a2a4d..e9a6cc2be5e1 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -1,10 +1,12 @@ ========= -Relevant Article: +## Spring with Hibernate 4 Example Project + +### Relevant Articles: - [Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring) -Quick Start +### Quick Start ``` git clone git://github.com/eugenp/REST.git @@ -12,4 +14,4 @@ cd REST mvn install mvn cargo:run ``` -- note: starts on port 8082 +- **note**: starts on port `8082` diff --git a/spring-jpa/README.md b/spring-jpa/README.md index 9f63413d937d..b1a4dfcd85fb 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -1,5 +1,8 @@ ========= -Relevant Articles: +## Spring JPA Example Project + + +### Relevant Articles: - [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 1abc096086ed..e32eeec83a90 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -1,3 +1,7 @@ -[Spring MVC Tutorial Project](http://www.baeldung.com/spring-mvc-tutorial) ========= +## Spring MVC with Java Configuration Example Project + + +### Relevant Articles: +- [Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index b67f11e4e7aa..d2872a778236 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,5 +1,7 @@ -Spring MVC Tutorial ========= -Relevant Articles: +## Spring MVC with XML Configuration Example Project + + +### Relevant Articles: - \ No newline at end of file diff --git a/spring-mvc/README.md b/spring-mvc/README.md index 857e0007da57..323bf274e055 100644 --- a/spring-mvc/README.md +++ b/spring-mvc/README.md @@ -1,6 +1,9 @@ ========= -Relevant Articles: +## Spring MVC Example Project + + +### Relevant Articles: - [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md index 61f509f9e5a3..01be5f4b13b3 100644 --- a/spring-security-basic-auth/README.md +++ b/spring-security-basic-auth/README.md @@ -1,5 +1,8 @@ ========= -Relevant Article: +## Spring Security with Basic Authentication Example Project + + +### Relevant Article: - [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) - [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-custom/README.md b/spring-security-custom/README.md index ebf695b9e3ec..fc4d243e7cfa 100644 --- a/spring-security-custom/README.md +++ b/spring-security-custom/README.md @@ -1,6 +1,8 @@ -Spring Security for REST ========= -Relevant Articles: +## Spring Security for REST Example Project + + +### Relevant Articles: - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) \ No newline at end of file diff --git a/spring-security-digest-auth/README.md b/spring-security-digest-auth/README.md index 507104ac6063..3b93a84505ae 100644 --- a/spring-security-digest-auth/README.md +++ b/spring-security-digest-auth/README.md @@ -1,4 +1,7 @@ ========= -Relevant Article: +## Spring Security with Digest Authentication Example Project + + +### Relevant Article: - [Spring Security Digest Authentication](http://www.baeldung.com/spring-security-digest-authentication) diff --git a/spring-security-login/README.md b/spring-security-login/README.md index e1efae813e57..dd465e021983 100644 --- a/spring-security-login/README.md +++ b/spring-security-login/README.md @@ -1,14 +1,14 @@ ========= -## Spring Security Login Tutorial +## Spring Security Login Example Project + + +### Relevant Articles: +- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) +- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) ### Build the Project ``` mvn clean install ``` - - -### Relevant Articles: -- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) -- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index c30bd3421672..89c63f17ee69 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -1,6 +1,6 @@ ========= -## Spring Security REST Tutorial +## Spring Security REST Example Project ### Build the Project diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index a7dd66cfbadc..11522e362f47 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -1,5 +1,7 @@ -Spring Security for REST ========= -Relevant Articles: +## Spring Security for REST Example Project + + +### Relevant Articles: - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file From 47db09849e2180b9c6875a40e33cc2eeb79048e1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:21:30 +0300 Subject: [PATCH 173/796] doc work --- spring-all/README.md | 1 + spring-security-custom/README.md | 2 +- spring-security-login/README.md | 1 + spring-security-rest-full/README.md | 5 ++++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-all/README.md b/spring-all/README.md index ae8db53b9808..0541922dc9ec 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -9,4 +9,5 @@ This project is used to replicate Spring Exceptions only. - [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) - [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) - [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) +- [Spring NoSuchBeanDefinitionException](http://www.baeldung.com/spring-nosuchbeandefinitionexception) - [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file diff --git a/spring-security-custom/README.md b/spring-security-custom/README.md index fc4d243e7cfa..ecb07960eb0c 100644 --- a/spring-security-custom/README.md +++ b/spring-security-custom/README.md @@ -5,4 +5,4 @@ ### Relevant Articles: - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) -- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) \ No newline at end of file +- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) diff --git a/spring-security-login/README.md b/spring-security-login/README.md index dd465e021983..256078f4b6ed 100644 --- a/spring-security-login/README.md +++ b/spring-security-login/README.md @@ -6,6 +6,7 @@ ### Relevant Articles: - [Spring Security Form Login](http://www.baeldung.com/spring-security-login) - [Spring Security Logout](http://www.baeldung.com/spring-security-logout) +- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) ### Build the Project diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 89c63f17ee69..daa0176cad05 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -3,12 +3,15 @@ ## Spring Security REST Example Project +### Relevant Articles: +- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) + + ### Build the Project ``` mvn clean install ``` - ### Use the REST Service ``` From c1d0444ec814c17b5b9bb59e801f78ddf6e73aa2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:45:56 +0300 Subject: [PATCH 174/796] project cleanup --- {spring-all => spring-exceptions}/.classpath | 0 {spring-all => spring-exceptions}/.gitignore | 0 {spring-all => spring-exceptions}/.project | 2 +- .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 6 +- ....eclipse.wst.common.project.facet.core.xml | 0 ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 {spring-all => spring-exceptions}/README.md | 0 {spring-all => spring-exceptions}/pom.xml | 6 +- .../cause1/BeanA.java | 0 .../cause1/BeanB.java | 0 .../cause2/BeanA.java | 0 .../cause2/BeanB1.java | 0 .../cause2/BeanB2.java | 0 .../cause2/IBeanB.java | 0 .../cause3/BeanA.java | 0 .../spring/Cause1ContextWithJavaConfig.java | 0 .../spring/Cause2ContextWithJavaConfig.java | 0 .../spring/Cause3ContextWithJavaConfig.java | 0 .../java/org/baeldung/persistence/Setup.java | 0 .../core/ComponentInXmlUsingProperties.java | 0 .../core/ComponentUsingProperties.java | 0 .../spring/PropertiesWithJavaConfig.java | 0 .../spring/PropertiesWithJavaConfigOther.java | 0 .../spring/PropertiesWithXmlConfig.java | 0 .../spring/PropertiesWithXmlConfigOne.java | 0 .../spring/PropertiesWithXmlConfigTwo.java | 0 .../baeldung/spring/config/CoreConfig.java | 0 .../spring/config/MainWebAppInitializer.java | 0 .../org/baeldung/spring/config/MvcConfig.java | 0 .../spring/config/PersistenceConfig.java | 0 .../src/main/resources/bar.properties | 0 .../main/resources/configForProperties.xml | 0 .../main/resources/configForPropertiesOne.xml | 0 .../main/resources/configForPropertiesTwo.xml | 0 .../src/main/resources/foo.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web_old.xml | 0 ...eanDefinitionExceptionIntegrationTest.java | 0 ...eanDefinitionExceptionIntegrationTest.java | 0 ...eanDefinitionExceptionIntegrationTest.java | 0 .../PropertiesWithJavaIntegrationTest.java | 0 ...ertiesWithMultipleXmlsIntegrationTest.java | 0 .../PropertiesWithXmlIntegrationTest.java | 0 .../src/test/resources/.gitignore | 0 .../java/org/baeldung/spring/MvcConfig.java | 3 +- .../src/main/resources/webSecurityConfig.xml | 34 +++---- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 ++ .../src/main/webapp/WEB-INF/web.xml | 96 ++++++++++--------- 59 files changed, 85 insertions(+), 68 deletions(-) rename {spring-all => spring-exceptions}/.classpath (100%) rename {spring-all => spring-exceptions}/.gitignore (100%) rename {spring-all => spring-exceptions}/.project (98%) rename {spring-all => spring-exceptions}/.settings/.jsdtscope (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.common.component (70%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-all => spring-exceptions}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-all => spring-exceptions}/.springBeans (100%) rename {spring-all => spring-exceptions}/README.md (100%) rename {spring-all => spring-exceptions}/pom.xml (98%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/persistence/Setup.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/spring/config/CoreConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/spring/config/MvcConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/java/org/baeldung/spring/config/PersistenceConfig.java (100%) rename {spring-all => spring-exceptions}/src/main/resources/bar.properties (100%) rename {spring-all => spring-exceptions}/src/main/resources/configForProperties.xml (100%) rename {spring-all => spring-exceptions}/src/main/resources/configForPropertiesOne.xml (100%) rename {spring-all => spring-exceptions}/src/main/resources/configForPropertiesTwo.xml (100%) rename {spring-all => spring-exceptions}/src/main/resources/foo.properties (100%) rename {spring-all => spring-exceptions}/src/main/resources/logback.xml (100%) rename {spring-all => spring-exceptions}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-all => spring-exceptions}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-all => spring-exceptions}/src/main/webapp/WEB-INF/web_old.xml (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java (100%) rename {spring-all => spring-exceptions}/src/test/resources/.gitignore (100%) create mode 100644 spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-all/.classpath b/spring-exceptions/.classpath similarity index 100% rename from spring-all/.classpath rename to spring-exceptions/.classpath diff --git a/spring-all/.gitignore b/spring-exceptions/.gitignore similarity index 100% rename from spring-all/.gitignore rename to spring-exceptions/.gitignore diff --git a/spring-all/.project b/spring-exceptions/.project similarity index 98% rename from spring-all/.project rename to spring-exceptions/.project index 4ae82dabf052..8c9eba80050f 100644 --- a/spring-all/.project +++ b/spring-exceptions/.project @@ -1,6 +1,6 @@ - spring-all + spring-exceptions diff --git a/spring-all/.settings/.jsdtscope b/spring-exceptions/.settings/.jsdtscope similarity index 100% rename from spring-all/.settings/.jsdtscope rename to spring-exceptions/.settings/.jsdtscope diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-exceptions/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.jdt.core.prefs rename to spring-exceptions/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-all/.settings/org.eclipse.jdt.ui.prefs b/spring-exceptions/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.jdt.ui.prefs rename to spring-exceptions/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-all/.settings/org.eclipse.m2e.core.prefs b/spring-exceptions/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.m2e.core.prefs rename to spring-exceptions/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-all/.settings/org.eclipse.m2e.wtp.prefs b/spring-exceptions/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.m2e.wtp.prefs rename to spring-exceptions/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-all/.settings/org.eclipse.wst.common.component b/spring-exceptions/.settings/org.eclipse.wst.common.component similarity index 70% rename from spring-all/.settings/org.eclipse.wst.common.component rename to spring-exceptions/.settings/org.eclipse.wst.common.component index 847c6ff6987a..7785d041baf6 100644 --- a/spring-all/.settings/org.eclipse.wst.common.component +++ b/spring-exceptions/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-exceptions/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-exceptions/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-exceptions/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-exceptions/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-exceptions/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-exceptions/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-all/.settings/org.eclipse.wst.validation.prefs b/spring-exceptions/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.wst.validation.prefs rename to spring-exceptions/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-exceptions/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-exceptions/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-all/.springBeans b/spring-exceptions/.springBeans similarity index 100% rename from spring-all/.springBeans rename to spring-exceptions/.springBeans diff --git a/spring-all/README.md b/spring-exceptions/README.md similarity index 100% rename from spring-all/README.md rename to spring-exceptions/README.md diff --git a/spring-all/pom.xml b/spring-exceptions/pom.xml similarity index 98% rename from spring-all/pom.xml rename to spring-exceptions/pom.xml index 9dfb42a62309..ddbbd6ff1988 100644 --- a/spring-all/pom.xml +++ b/spring-exceptions/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-all + spring-exceptions 0.1-SNAPSHOT - spring-all + spring-exceptions war @@ -122,7 +122,7 @@ - spring-all + spring-exceptions src/main/resources diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java diff --git a/spring-all/src/main/java/org/baeldung/persistence/Setup.java b/spring-exceptions/src/main/java/org/baeldung/persistence/Setup.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/persistence/Setup.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/Setup.java diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java rename to spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java b/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java rename to spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java b/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java rename to spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java b/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java rename to spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java b/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java rename to spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java b/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java rename to spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/CoreConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java rename to spring-exceptions/src/main/java/org/baeldung/spring/config/CoreConfig.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java rename to spring-exceptions/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/MvcConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java rename to spring-exceptions/src/main/java/org/baeldung/spring/config/MvcConfig.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java diff --git a/spring-all/src/main/resources/bar.properties b/spring-exceptions/src/main/resources/bar.properties similarity index 100% rename from spring-all/src/main/resources/bar.properties rename to spring-exceptions/src/main/resources/bar.properties diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-exceptions/src/main/resources/configForProperties.xml similarity index 100% rename from spring-all/src/main/resources/configForProperties.xml rename to spring-exceptions/src/main/resources/configForProperties.xml diff --git a/spring-all/src/main/resources/configForPropertiesOne.xml b/spring-exceptions/src/main/resources/configForPropertiesOne.xml similarity index 100% rename from spring-all/src/main/resources/configForPropertiesOne.xml rename to spring-exceptions/src/main/resources/configForPropertiesOne.xml diff --git a/spring-all/src/main/resources/configForPropertiesTwo.xml b/spring-exceptions/src/main/resources/configForPropertiesTwo.xml similarity index 100% rename from spring-all/src/main/resources/configForPropertiesTwo.xml rename to spring-exceptions/src/main/resources/configForPropertiesTwo.xml diff --git a/spring-all/src/main/resources/foo.properties b/spring-exceptions/src/main/resources/foo.properties similarity index 100% rename from spring-all/src/main/resources/foo.properties rename to spring-exceptions/src/main/resources/foo.properties diff --git a/spring-all/src/main/resources/logback.xml b/spring-exceptions/src/main/resources/logback.xml similarity index 100% rename from spring-all/src/main/resources/logback.xml rename to spring-exceptions/src/main/resources/logback.xml diff --git a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-all/src/main/webapp/WEB-INF/view/sample.jsp b/spring-exceptions/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-exceptions/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-all/src/main/webapp/WEB-INF/web_old.xml b/spring-exceptions/src/main/webapp/WEB-INF/web_old.xml similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/web_old.xml rename to spring-exceptions/src/main/webapp/WEB-INF/web_old.xml diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java diff --git a/spring-all/src/test/resources/.gitignore b/spring-exceptions/src/test/resources/.gitignore similarity index 100% rename from spring-all/src/test/resources/.gitignore rename to spring-exceptions/src/test/resources/.gitignore diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java index 64bdf249445b..c76b6175d695 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -1,6 +1,7 @@ package org.baeldung.spring; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; @@ -8,7 +9,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; -// @Configuration +@Configuration @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-custom/src/main/resources/webSecurityConfig.xml index 590adab8cee4..55974f664da8 100644 --- a/spring-security-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-custom/src/main/resources/webSecurityConfig.xml @@ -1,26 +1,28 @@ - - - - + + + + + + + - - + - - - - - - - + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index db64386b1480..e7fbf52aaeea 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -1,52 +1,60 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring Security Custom Application + Spring Security Custom Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - index.html - + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + /* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + \ No newline at end of file From 76351a44eae68b453582b8c03dec2dd0f580ca82 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:48:25 +0300 Subject: [PATCH 175/796] spring all project --- spring-all/.classpath | 37 +++ spring-all/.gitignore | 13 ++ spring-all/.project | 60 +++++ spring-all/.settings/.jsdtscope | 12 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ spring-all/.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-all/.springBeans | 14 ++ spring-all/README.md | 13 ++ spring-all/pom.xml | 221 ++++++++++++++++++ .../cause1/BeanA.java | 12 + .../cause1/BeanB.java | 5 + .../cause2/BeanA.java | 12 + .../cause2/BeanB1.java | 8 + .../cause2/BeanB2.java | 8 + .../cause2/IBeanB.java | 5 + .../cause3/BeanA.java | 19 ++ .../spring/Cause1ContextWithJavaConfig.java | 16 ++ .../spring/Cause2ContextWithJavaConfig.java | 16 ++ .../spring/Cause3ContextWithJavaConfig.java | 16 ++ .../java/org/baeldung/persistence/Setup.java | 26 +++ .../core/ComponentInXmlUsingProperties.java | 30 +++ .../core/ComponentUsingProperties.java | 30 +++ .../spring/PropertiesWithJavaConfig.java | 25 ++ .../spring/PropertiesWithJavaConfigOther.java | 16 ++ .../spring/PropertiesWithXmlConfig.java | 16 ++ .../spring/PropertiesWithXmlConfigOne.java | 16 ++ .../spring/PropertiesWithXmlConfigTwo.java | 14 ++ .../baeldung/spring/config/CoreConfig.java | 15 ++ .../spring/config/MainWebAppInitializer.java | 41 ++++ .../org/baeldung/spring/config/MvcConfig.java | 39 ++++ .../spring/config/PersistenceConfig.java | 78 +++++++ spring-all/src/main/resources/bar.properties | 1 + .../main/resources/configForProperties.xml | 15 ++ .../main/resources/configForPropertiesOne.xml | 15 ++ .../main/resources/configForPropertiesTwo.xml | 11 + spring-all/src/main/resources/foo.properties | 1 + spring-all/src/main/resources/logback.xml | 22 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web_old.xml | 42 ++++ ...eanDefinitionExceptionIntegrationTest.java | 19 ++ ...eanDefinitionExceptionIntegrationTest.java | 19 ++ ...eanDefinitionExceptionIntegrationTest.java | 19 ++ .../PropertiesWithJavaIntegrationTest.java | 30 +++ ...ertiesWithMultipleXmlsIntegrationTest.java | 30 +++ .../PropertiesWithXmlIntegrationTest.java | 29 +++ spring-all/src/test/resources/.gitignore | 13 ++ 55 files changed, 1302 insertions(+) create mode 100644 spring-all/.classpath create mode 100644 spring-all/.gitignore create mode 100644 spring-all/.project create mode 100644 spring-all/.settings/.jsdtscope create mode 100644 spring-all/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-all/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-all/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-all/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-all/.settings/org.eclipse.wst.common.component create mode 100644 spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-all/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-all/.springBeans create mode 100644 spring-all/README.md create mode 100644 spring-all/pom.xml create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/persistence/Setup.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java create mode 100644 spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java create mode 100644 spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java create mode 100644 spring-all/src/main/resources/bar.properties create mode 100644 spring-all/src/main/resources/configForProperties.xml create mode 100644 spring-all/src/main/resources/configForPropertiesOne.xml create mode 100644 spring-all/src/main/resources/configForPropertiesTwo.xml create mode 100644 spring-all/src/main/resources/foo.properties create mode 100644 spring-all/src/main/resources/logback.xml create mode 100644 spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-all/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-all/src/main/webapp/WEB-INF/web_old.xml create mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java create mode 100644 spring-all/src/test/resources/.gitignore diff --git a/spring-all/.classpath b/spring-all/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-all/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-all/.gitignore b/spring-all/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-all/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-all/.project b/spring-all/.project new file mode 100644 index 000000000000..4ae82dabf052 --- /dev/null +++ b/spring-all/.project @@ -0,0 +1,60 @@ + + + spring-all + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-all/.settings/.jsdtscope b/spring-all/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-all/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-all/.settings/org.eclipse.jdt.core.prefs b/spring-all/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/spring-all/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-all/.settings/org.eclipse.jdt.ui.prefs b/spring-all/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-all/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-all/.settings/org.eclipse.m2e.core.prefs b/spring-all/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-all/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-all/.settings/org.eclipse.m2e.wtp.prefs b/spring-all/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-all/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-all/.settings/org.eclipse.wst.common.component b/spring-all/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..847c6ff6987a --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-all/.settings/org.eclipse.wst.validation.prefs b/spring-all/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-all/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-all/.springBeans b/spring-all/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-all/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-all/README.md b/spring-all/README.md new file mode 100644 index 000000000000..0541922dc9ec --- /dev/null +++ b/spring-all/README.md @@ -0,0 +1,13 @@ +========= + +## Spring Exceptions Example Project + +This project is used to replicate Spring Exceptions only. + + +### Relevant articles: +- [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) +- [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) +- [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) +- [Spring NoSuchBeanDefinitionException](http://www.baeldung.com/spring-nosuchbeandefinitionexception) +- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file diff --git a/spring-all/pom.xml b/spring-all/pom.xml new file mode 100644 index 000000000000..9dfb42a62309 --- /dev/null +++ b/spring-all/pom.xml @@ -0,0 +1,221 @@ + + 4.0.0 + org.baeldung + spring-all + 0.1-SNAPSHOT + + spring-all + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.javassist + javassist + ${javassist.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + ${jstl.version} + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-all + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + 3.18.0-GA + 1.2 + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + + + \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java new file mode 100644 index 000000000000..c664309426ff --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause1; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private BeanB dependency; + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java new file mode 100644 index 000000000000..8a198422e801 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause1; + +public class BeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java new file mode 100644 index 000000000000..2b454bfabb7a --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private IBeanB dependency; + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java new file mode 100644 index 000000000000..877f40066886 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB1 implements IBeanB { + // +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java new file mode 100644 index 000000000000..6bf4160966e6 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB2 implements IBeanB { + // +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java new file mode 100644 index 000000000000..3e70126c1a94 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause2; + +public interface IBeanB { + // +} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java new file mode 100644 index 000000000000..091d3f1aa82b --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.cause3; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class BeanA implements InitializingBean { + + @Autowired + private ApplicationContext context; + + @Override + public void afterPropertiesSet() { + context.getBean("someBeanName"); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java new file mode 100644 index 000000000000..5ba971baa9d6 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") +public class Cause1ContextWithJavaConfig { + + public Cause1ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java new file mode 100644 index 000000000000..9f4816ef7c00 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause2") +public class Cause2ContextWithJavaConfig { + + public Cause2ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java new file mode 100644 index 000000000000..a8d0fbe37bf0 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.nosuchbeandefinitionexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause3") +public class Cause3ContextWithJavaConfig { + + public Cause3ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/persistence/Setup.java b/spring-all/src/main/java/org/baeldung/persistence/Setup.java new file mode 100644 index 000000000000..5cba4e70fba3 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/persistence/Setup.java @@ -0,0 +1,26 @@ +package org.baeldung.persistence; + +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; + +@Component +public class Setup implements ApplicationListener { + + private boolean setupDone; + + public Setup() { + super(); + } + + // + + @Override + public final void onApplicationEvent(final ContextRefreshedEvent event) { + if (!setupDone) { + System.out.println(); + setupDone = true; + } + } + +} diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java new file mode 100644 index 000000000000..f695326cd6bd --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; + +public class ComponentInXmlUsingProperties implements InitializingBean { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + public ComponentInXmlUsingProperties(final String propertyValue) { + super(); + + System.out.println("Constructor Injection - Property Value resolted to: " + propertyValue); + } + + // + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println("in afterPropertiesSet via @Value: " + injectedProperty); + System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java new file mode 100644 index 000000000000..7e082702fe7e --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class ComponentUsingProperties implements InitializingBean { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + public ComponentUsingProperties() { + super(); + } + + // + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println("in afterPropertiesSet via @Value: " + injectedProperty); + System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java new file mode 100644 index 000000000000..9b5d7ed047b5 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java @@ -0,0 +1,25 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan("org.baeldung.properties.core") +@PropertySource("classpath:foo.properties") +public class PropertiesWithJavaConfig { + + public PropertiesWithJavaConfig() { + super(); + } + + // beans + + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java new file mode 100644 index 000000000000..594ba0a09d52 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java @@ -0,0 +1,16 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource("classpath:bar.properties") +public class PropertiesWithJavaConfigOther { + + public PropertiesWithJavaConfigOther() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java new file mode 100644 index 000000000000..9ad7febcb0c1 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource("classpath:configForProperties.xml") +@ComponentScan("org.baeldung.core") +public class PropertiesWithXmlConfig { + + public PropertiesWithXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java new file mode 100644 index 000000000000..9061cc10d48d --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java @@ -0,0 +1,16 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource("classpath:configForPropertiesOne.xml") +@ComponentScan("org.baeldung.core") +public class PropertiesWithXmlConfigOne { + + public PropertiesWithXmlConfigOne() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java new file mode 100644 index 000000000000..e4365cbc8b78 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java @@ -0,0 +1,14 @@ +package org.baeldung.properties.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource("classpath:configForPropertiesTwo.xml") +public class PropertiesWithXmlConfigTwo { + + public PropertiesWithXmlConfigTwo() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java new file mode 100644 index 000000000000..ff1742351b23 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java @@ -0,0 +1,15 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.core") +public class CoreConfig extends WebMvcConfigurerAdapter { + + public CoreConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java new file mode 100644 index 000000000000..5ef83b8afd0b --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java @@ -0,0 +1,41 @@ +package org.baeldung.spring.config; + +import java.util.Set; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + /** + * Register and configure all Servlet container components necessary to power the web application. + */ + @Override + public void onStartup(final ServletContext sc) throws ServletException { + System.out.println("MainWebAppInitializer.onStartup()"); + + // Create the 'root' Spring application context + final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.scan("org.baeldung.spring.config"); + // root.getEnvironment().setDefaultProfiles("embedded"); + + // Manages the lifecycle of the root application context + sc.addListener(new ContextLoaderListener(root)); + + // Handles requests into the application + final ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext())); + appServlet.setLoadOnStartup(1); + final Set mappingConflicts = appServlet.addMapping("/"); + if (!mappingConflicts.isEmpty()) { + throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); + } + } + +} diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java new file mode 100644 index 000000000000..f87e400fce82 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java new file mode 100644 index 000000000000..6a057fc0c741 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -0,0 +1,78 @@ +package org.baeldung.spring.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +// @Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-all/src/main/resources/bar.properties b/spring-all/src/main/resources/bar.properties new file mode 100644 index 000000000000..1a41a49c4c3c --- /dev/null +++ b/spring-all/src/main/resources/bar.properties @@ -0,0 +1 @@ +key.something2=val2 \ No newline at end of file diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml new file mode 100644 index 000000000000..20a40a319559 --- /dev/null +++ b/spring-all/src/main/resources/configForProperties.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/configForPropertiesOne.xml b/spring-all/src/main/resources/configForPropertiesOne.xml new file mode 100644 index 000000000000..ad9716fada18 --- /dev/null +++ b/spring-all/src/main/resources/configForPropertiesOne.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/configForPropertiesTwo.xml b/spring-all/src/main/resources/configForPropertiesTwo.xml new file mode 100644 index 000000000000..b9d5e86c95d9 --- /dev/null +++ b/spring-all/src/main/resources/configForPropertiesTwo.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/foo.properties b/spring-all/src/main/resources/foo.properties new file mode 100644 index 000000000000..7c47cd788002 --- /dev/null +++ b/spring-all/src/main/resources/foo.properties @@ -0,0 +1 @@ +key.something=val \ No newline at end of file diff --git a/spring-all/src/main/resources/logback.xml b/spring-all/src/main/resources/logback.xml new file mode 100644 index 000000000000..45c9697f776f --- /dev/null +++ b/spring-all/src/main/resources/logback.xml @@ -0,0 +1,22 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/sample.jsp b/spring-all/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/web_old.xml b/spring-all/src/main/webapp/WEB-INF/web_old.xml new file mode 100644 index 000000000000..ba2bb591ed01 --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/web_old.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java new file mode 100644 index 000000000000..aed37a125a85 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception; + +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1NoSuchBeanDefinitionExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java new file mode 100644 index 000000000000..90d7317f4444 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception; + +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause2ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2NoSuchBeanDefinitionExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java new file mode 100644 index 000000000000..0e2123b7ffd7 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.nosuchbeandefinitionexception; + +import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause3ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3NoSuchBeanDefinitionExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java new file mode 100644 index 000000000000..d6c99502d7db --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithJavaIntegrationTest.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithJavaConfig; +import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithJavaIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java new file mode 100644 index 000000000000..9fc793fc1bf4 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsIntegrationTest.java @@ -0,0 +1,30 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; +import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithMultipleXmlsIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java new file mode 100644 index 000000000000..ff5eaab910b1 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/PropertiesWithXmlIntegrationTest.java @@ -0,0 +1,29 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +public class PropertiesWithXmlIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + } + +} diff --git a/spring-all/src/test/resources/.gitignore b/spring-all/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-all/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From fd6fb9734331c49f4ff207396779d7fea3b8eb9f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:49:01 +0300 Subject: [PATCH 176/796] spring exceptions now have their own project - these no longer belong --- .../cause1/BeanA.java | 12 ------------ .../cause1/BeanB.java | 5 ----- .../cause2/BeanA.java | 12 ------------ .../cause2/BeanB1.java | 8 -------- .../cause2/BeanB2.java | 8 -------- .../cause2/IBeanB.java | 5 ----- .../cause3/BeanA.java | 19 ------------------- .../spring/Cause1ContextWithJavaConfig.java | 16 ---------------- .../spring/Cause2ContextWithJavaConfig.java | 16 ---------------- .../spring/Cause3ContextWithJavaConfig.java | 16 ---------------- ...eanDefinitionExceptionIntegrationTest.java | 19 ------------------- ...eanDefinitionExceptionIntegrationTest.java | 19 ------------------- ...eanDefinitionExceptionIntegrationTest.java | 19 ------------------- 13 files changed, 174 deletions(-) delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java delete mode 100644 spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java delete mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java delete mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java delete mode 100644 spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java deleted file mode 100644 index c664309426ff..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause1; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class BeanA { - - @Autowired - private BeanB dependency; - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java deleted file mode 100644 index 8a198422e801..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause1; - -public class BeanB { - // -} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java deleted file mode 100644 index 2b454bfabb7a..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class BeanA { - - @Autowired - private IBeanB dependency; - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java deleted file mode 100644 index 877f40066886..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; - -import org.springframework.stereotype.Component; - -@Component -public class BeanB1 implements IBeanB { - // -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java deleted file mode 100644 index 6bf4160966e6..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; - -import org.springframework.stereotype.Component; - -@Component -public class BeanB2 implements IBeanB { - // -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java deleted file mode 100644 index 3e70126c1a94..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; - -public interface IBeanB { - // -} diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java deleted file mode 100644 index 091d3f1aa82b..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause3; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -@Component -public class BeanA implements InitializingBean { - - @Autowired - private ApplicationContext context; - - @Override - public void afterPropertiesSet() { - context.getBean("someBeanName"); - } - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java deleted file mode 100644 index 5ba971baa9d6..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") -public class Cause1ContextWithJavaConfig { - - public Cause1ContextWithJavaConfig() { - super(); - } - - // beans - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java deleted file mode 100644 index 9f4816ef7c00..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause2") -public class Cause2ContextWithJavaConfig { - - public Cause2ContextWithJavaConfig() { - super(); - } - - // beans - -} \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java deleted file mode 100644 index a8d0fbe37bf0..000000000000 --- a/spring-all/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause3") -public class Cause3ContextWithJavaConfig { - - public Cause3ContextWithJavaConfig() { - super(); - } - - // beans - -} \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java deleted file mode 100644 index aed37a125a85..000000000000 --- a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; - -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) -public class Cause1NoSuchBeanDefinitionExceptionIntegrationTest { - - @Test - public final void givenContextIsInitialized_thenNoException() { - // - } - -} diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java deleted file mode 100644 index 90d7317f4444..000000000000 --- a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionIntegrationTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; - -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause2ContextWithJavaConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) -public class Cause2NoSuchBeanDefinitionExceptionIntegrationTest { - - @Test - public final void givenContextIsInitialized_thenNoException() { - // - } - -} diff --git a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java deleted file mode 100644 index 0e2123b7ffd7..000000000000 --- a/spring-all/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionIntegrationTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; - -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause3ContextWithJavaConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) -public class Cause3NoSuchBeanDefinitionExceptionIntegrationTest { - - @Test - public final void givenContextIsInitialized_thenNoException() { - // - } - -} From de476717ba5b701f0976e69afe3f703fcd7d54bd Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 14:49:58 +0300 Subject: [PATCH 177/796] doc work --- spring-all/README.md | 6 +----- spring-exceptions/README.md | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-all/README.md b/spring-all/README.md index 0541922dc9ec..4a3bd2507704 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -1,13 +1,9 @@ ========= -## Spring Exceptions Example Project +## Spring General Example Project This project is used to replicate Spring Exceptions only. ### Relevant articles: -- [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) -- [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) -- [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) -- [Spring NoSuchBeanDefinitionException](http://www.baeldung.com/spring-nosuchbeandefinitionexception) - [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file diff --git a/spring-exceptions/README.md b/spring-exceptions/README.md index 0541922dc9ec..ab6a9643e912 100644 --- a/spring-exceptions/README.md +++ b/spring-exceptions/README.md @@ -10,4 +10,3 @@ This project is used to replicate Spring Exceptions only. - [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) - [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) - [Spring NoSuchBeanDefinitionException](http://www.baeldung.com/spring-nosuchbeandefinitionexception) -- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file From 105ccb067acd3090b45e486dd256eef513f2fe62 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:01:13 +0300 Subject: [PATCH 178/796] clarification on the mvc vs rest projects --- spring-security-basic-auth/README.md | 4 ++ spring-security-custom/.project | 2 +- .../org.eclipse.wst.common.component | 6 +-- spring-security-custom/.springBeans | 2 +- spring-security-custom/pom.xml | 6 +-- .../java/org/baeldung/spring/MvcConfig.java | 40 ------------------- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 --- .../src/main/webapp/WEB-INF/view/homepage.jsp | 8 ---- .../src/main/webapp/WEB-INF/view/login.jsp | 26 ------------ .../src/main/webapp/WEB-INF/web.xml | 9 ----- 10 files changed, 12 insertions(+), 97 deletions(-) delete mode 100644 spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java delete mode 100644 spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md index 01be5f4b13b3..95e45ae519cb 100644 --- a/spring-security-basic-auth/README.md +++ b/spring-security-basic-auth/README.md @@ -6,3 +6,7 @@ ### Relevant Article: - [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) - [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) + + +### Notes +- the project includes both views as well as a REST layer \ No newline at end of file diff --git a/spring-security-custom/.project b/spring-security-custom/.project index 4299cd37284c..0e824c1bde6a 100644 --- a/spring-security-custom/.project +++ b/spring-security-custom/.project @@ -1,6 +1,6 @@ - spring-security-custom + spring-security-rest-custom diff --git a/spring-security-custom/.settings/org.eclipse.wst.common.component b/spring-security-custom/.settings/org.eclipse.wst.common.component index 6322536a9b64..3b22cb60bb1f 100644 --- a/spring-security-custom/.settings/org.eclipse.wst.common.component +++ b/spring-security-custom/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-custom/.springBeans b/spring-security-custom/.springBeans index d11fb034bdc0..a79097f40d30 100644 --- a/spring-security-custom/.springBeans +++ b/spring-security-custom/.springBeans @@ -1,7 +1,7 @@ 1 - + diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index ac00c65bbce7..1cf7dd867e84 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-custom + spring-security-rest-custom 0.1-SNAPSHOT - spring-security-custom + spring-security-rest-custom war @@ -142,7 +142,7 @@ - spring-security-custom + spring-security-rest-custom src/main/resources diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java deleted file mode 100644 index c76b6175d695..000000000000 --- a/spring-security-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@Configuration -@EnableWebMvc -public class MvcConfig extends WebMvcConfigurerAdapter { - - public MvcConfig() { - super(); - } - - // API - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/login.html"); - registry.addViewController("/homepage.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } -} \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index 5463820874c8..000000000000 --- a/spring-security-custom/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index a958bc0a0892..000000000000 --- a/spring-security-custom/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,8 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 013ceccb4e4d..000000000000 --- a/spring-security-custom/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,26 +0,0 @@ - - - - -

Login

- -
- - - - - - - - - - - - - -
User:
Password:
- -
- - - \ No newline at end of file diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index e7fbf52aaeea..372688c8d87e 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -33,15 +33,6 @@ /api/* - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - /* - From 5489a6a15cc831268cd1fbf9b35233cf3a9bea66 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:02:12 +0300 Subject: [PATCH 179/796] clarification on the mvc vs rest projects --- .../.classpath | 0 .../org.eclipse.wst.jsdt.core.javascriptValidator.launch | 0 .../.gitignore | 0 {spring-security-custom => spring-security-rest-custom}/.project | 0 .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../.settings/org.eclipse.wst.common.component | 0 .../.settings/org.eclipse.wst.common.project.facet.core.xml | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.container | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.name | 0 .../.settings/org.eclipse.wst.validation.prefs | 0 .../.settings/org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 {spring-security-custom => spring-security-rest-custom}/README.md | 0 {spring-security-custom => spring-security-rest-custom}/pom.xml | 0 .../java/org/baeldung/security/CustomAuthenticationProvider.java | 0 .../security/MySavedRequestAwareAuthenticationSuccessHandler.java | 0 .../java/org/baeldung/security/RestAuthenticationEntryPoint.java | 0 .../src/main/java/org/baeldung/spring/SecSecurityConfig.java | 0 .../src/main/java/org/baeldung/spring/WebConfig.java | 0 .../src/main/java/org/baeldung/web/controller/FooController.java | 0 .../src/main/java/org/baeldung/web/dto/Foo.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/api-servlet.xml | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 30 files changed, 0 insertions(+), 0 deletions(-) rename {spring-security-custom => spring-security-rest-custom}/.classpath (100%) rename {spring-security-custom => spring-security-rest-custom}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-security-custom => spring-security-rest-custom}/.gitignore (100%) rename {spring-security-custom => spring-security-rest-custom}/.project (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/.jsdtscope (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.common.component (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-security-custom => spring-security-rest-custom}/.springBeans (100%) rename {spring-security-custom => spring-security-rest-custom}/README.md (100%) rename {spring-security-custom => spring-security-rest-custom}/pom.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/spring/WebConfig.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/web/controller/FooController.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/java/org/baeldung/web/dto/Foo.java (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/resources/logback.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/webapp/WEB-INF/api-servlet.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-security-custom => spring-security-rest-custom}/src/test/resources/.gitignore (100%) diff --git a/spring-security-custom/.classpath b/spring-security-rest-custom/.classpath similarity index 100% rename from spring-security-custom/.classpath rename to spring-security-rest-custom/.classpath diff --git a/spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-security-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-security-rest-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-security-custom/.gitignore b/spring-security-rest-custom/.gitignore similarity index 100% rename from spring-security-custom/.gitignore rename to spring-security-rest-custom/.gitignore diff --git a/spring-security-custom/.project b/spring-security-rest-custom/.project similarity index 100% rename from spring-security-custom/.project rename to spring-security-rest-custom/.project diff --git a/spring-security-custom/.settings/.jsdtscope b/spring-security-rest-custom/.settings/.jsdtscope similarity index 100% rename from spring-security-custom/.settings/.jsdtscope rename to spring-security-rest-custom/.settings/.jsdtscope diff --git a/spring-security-custom/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest-custom/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.jdt.core.prefs rename to spring-security-rest-custom/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-security-custom/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest-custom/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.jdt.ui.prefs rename to spring-security-rest-custom/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-security-custom/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest-custom/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.m2e.core.prefs rename to spring-security-rest-custom/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest-custom/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.m2e.wtp.prefs rename to spring-security-rest-custom/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-security-custom/.settings/org.eclipse.wst.common.component b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.common.component rename to spring-security-rest-custom/.settings/org.eclipse.wst.common.component diff --git a/spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-custom/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-security-rest-custom/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-security-rest-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-security-rest-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-security-custom/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.validation.prefs rename to spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest-custom/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-security-custom/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-security-rest-custom/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-security-custom/.springBeans b/spring-security-rest-custom/.springBeans similarity index 100% rename from spring-security-custom/.springBeans rename to spring-security-rest-custom/.springBeans diff --git a/spring-security-custom/README.md b/spring-security-rest-custom/README.md similarity index 100% rename from spring-security-custom/README.md rename to spring-security-rest-custom/README.md diff --git a/spring-security-custom/pom.xml b/spring-security-rest-custom/pom.xml similarity index 100% rename from spring-security-custom/pom.xml rename to spring-security-rest-custom/pom.xml diff --git a/spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java rename to spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java diff --git a/spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java rename to spring-security-rest-custom/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java diff --git a/spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java rename to spring-security-rest-custom/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-rest-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/spring/WebConfig.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-security-rest-custom/src/main/java/org/baeldung/spring/WebConfig.java diff --git a/spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/web/controller/FooController.java rename to spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java diff --git a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/dto/Foo.java similarity index 100% rename from spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java rename to spring-security-rest-custom/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-custom/src/main/resources/logback.xml b/spring-security-rest-custom/src/main/resources/logback.xml similarity index 100% rename from spring-security-custom/src/main/resources/logback.xml rename to spring-security-rest-custom/src/main/resources/logback.xml diff --git a/spring-security-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-custom/src/main/resources/webSecurityConfig.xml rename to spring-security-rest-custom/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-security-custom/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-security-custom/src/main/webapp/WEB-INF/web.xml rename to spring-security-rest-custom/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-custom/src/test/resources/.gitignore b/spring-security-rest-custom/src/test/resources/.gitignore similarity index 100% rename from spring-security-custom/src/test/resources/.gitignore rename to spring-security-rest-custom/src/test/resources/.gitignore From af0578e7bf22c2be3cceb1914eef01f303a7c962 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:05:57 +0300 Subject: [PATCH 180/796] mvc and rest clarification for projects --- spring-security-rest-custom/README.md | 1 - .../src/main/resources/webSecurityConfig.xml | 8 -------- 2 files changed, 9 deletions(-) diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index ecb07960eb0c..3ec8cf92c71a 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -4,5 +4,4 @@ ### Relevant Articles: -- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) diff --git a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml index 55974f664da8..3766574f346b 100644 --- a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml @@ -7,16 +7,8 @@ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - - - From 095329b1086caf44cedb7ad40925b06c0c14b2ff Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:12:58 +0300 Subject: [PATCH 181/796] eclipse cleanup, removing unnecessary natures, namging cleanup as well --- spring-security-digest-auth/.project | 19 +---- .../org.eclipse.wst.common.component | 6 +- spring-security-digest-auth/pom.xml | 6 +- .../persistence/service/FooService.java | 23 ------ .../baeldung/spring/PersistenceConfig.java | 14 ---- .../java/org/baeldung/spring/WebConfig.java | 17 ----- .../web/controller/FooController.java | 74 ------------------- .../org/baeldung/web/controller/LinkUtil.java | 30 -------- .../web/controller/ResourceCreated.java | 35 --------- ...esourceCreatedDiscoverabilityListener.java | 35 --------- .../controller/SingleResourceRetrieved.java | 29 -------- ...ourceRetrievedDiscoverabilityListener.java | 32 -------- .../web/controller/TestController.java | 28 ------- .../main/java/org/baeldung/web/dto/Foo.java | 11 --- .../src/main/resources/webSecurityConfig.xml | 48 ++++++------ spring-security-login/.project | 19 ++--- spring-security-rest-custom/.project | 19 ++--- spring-security-rest-full/.project | 19 ++--- spring-security-rest/.project | 19 ++--- 19 files changed, 53 insertions(+), 430 deletions(-) delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java delete mode 100644 spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-digest-auth/.project b/spring-security-digest-auth/.project index a5c72c83aeb6..f387b771fcc3 100644 --- a/spring-security-digest-auth/.project +++ b/spring-security-digest-auth/.project @@ -1,21 +1,10 @@ - spring-security-digest-auth + spring-security-mvc-digest-auth - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder @@ -31,11 +20,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -54,6 +38,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.common.component b/spring-security-digest-auth/.settings/org.eclipse.wst.common.component index 6333967c73a3..0d189e36cd1e 100644 --- a/spring-security-digest-auth/.settings/org.eclipse.wst.common.component +++ b/spring-security-digest-auth/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-digest-auth/pom.xml b/spring-security-digest-auth/pom.xml index 73d1ced5970b..760d8156f384 100644 --- a/spring-security-digest-auth/pom.xml +++ b/spring-security-digest-auth/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-digest-auth + spring-security-mvc-digest-auth 0.1-SNAPSHOT - spring-security-digest-auth + spring-security-mvc-digest-auth war @@ -128,7 +128,7 @@ - spring-security-digest-auth + spring-security-mvc-digest-auth src/main/resources diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java deleted file mode 100644 index 02db7a733a6b..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.web.dto.Foo; -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - public FooService() { - super(); - } - - // API - - public Foo getById(final Long id) { - return null; - } - - public Long create(final Foo resource) { - return null; - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java deleted file mode 100644 index 4ea0053f4845..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.persistence") -public class PersistenceConfig { - - public PersistenceConfig() { - super(); - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java deleted file mode 100644 index fa6f5f6d5626..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@ComponentScan("org.baeldung.web") -public class WebConfig extends WebMvcConfigurerAdapter { - - public WebConfig() { - super(); - } - - // API - -} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java deleted file mode 100644 index daa797ee368e..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.baeldung.persistence.service.FooService; -import org.baeldung.web.dto.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.util.UriComponentsBuilder; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; - -@Controller -@RequestMapping(value = "/foo") -public class FooController { - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Autowired - private FooService service; - - public FooController() { - super(); - } - - // API - - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - return new Foo(); - } - - @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); - - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); - return resourceById; - } - - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { - Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource); - - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); - } - - @RequestMapping(value = "admin", method = RequestMethod.GET) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { - final String rootUri = request.getRequestURL().toString(); - - final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); - final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); - response.addHeader("Link", linkToFoo); - } -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java deleted file mode 100644 index a41ebb5a5cdd..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/LinkUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletResponse; - -/** - * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object - */ -public final class LinkUtil { - - private LinkUtil() { - throw new AssertionError(); - } - - // - - /** - * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user - * - * @param uri - * the base uri - * @param rel - * the relative path - * - * @return the complete url - */ - public static String createLinkHeader(final String uri, final String rel) { - return "<" + uri + ">; rel=\"" + rel + "\""; - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java deleted file mode 100644 index a67788810161..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreated.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class ResourceCreated extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - private final long idOfNewResource; - - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - super(source); - - this.request = request; - this.response = response; - this.idOfNewResource = idOfNewResource; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - - public long getIdOfNewResource() { - return idOfNewResource; - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java deleted file mode 100644 index 8d19ef82fc63..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; -import com.google.common.net.HttpHeaders; - -@Component -class ResourceCreatedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { - Preconditions.checkNotNull(resourceCreatedEvent); - - final HttpServletRequest request = resourceCreatedEvent.getRequest(); - final HttpServletResponse response = resourceCreatedEvent.getResponse(); - final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); - - addLinkHeaderOnResourceCreation(request, response, idOfNewResource); - } - - void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - final String requestUrl = request.getRequestURL().toString(); - final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); - response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); - } - -} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java deleted file mode 100644 index 3de791810549..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class SingleResourceRetrieved extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { - super(source); - - this.request = request; - this.response = response; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java deleted file mode 100644 index 45cd7c4d131a..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -@Component -class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { - Preconditions.checkNotNull(resourceRetrievedEvent); - - final HttpServletRequest request = resourceRetrievedEvent.getRequest(); - final HttpServletResponse response = resourceRetrievedEvent.getResponse(); - addLinkHeaderOnSingleResourceRetrieval(request, response); - } - - void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { - final StringBuffer requestURL = request.getRequestURL(); - final int positionOfLastSlash = requestURL.lastIndexOf("/"); - final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); - - final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); - response.addHeader("Link", linkHeaderValue); - } - -} \ No newline at end of file diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java deleted file mode 100644 index f68cfb2eb7dc..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class TestController { - - public TestController() { - super(); - } - - // API - - @RequestMapping("/permitAll") - @ResponseBody - public String permitAll() { - return "Permit All"; - } - - @RequestMapping("/securityNone") - @ResponseBody - public String securityNone() { - return "Security None"; - } - -} diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java deleted file mode 100644 index 352045989daa..000000000000 --- a/spring-security-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.baeldung.web.dto; - -import java.io.Serializable; - -public class Foo implements Serializable { - - public Foo() { - super(); - } - -} diff --git a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml index 1d5703cb2614..dfd0b853713d 100644 --- a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml @@ -1,35 +1,31 @@ - - - - - - - - - + + + + + + + + - - - + + + - - + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/spring-security-login/.project b/spring-security-login/.project index 49eecbd6a380..72e28ae1298c 100644 --- a/spring-security-login/.project +++ b/spring-security-login/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder @@ -32,8 +21,13 @@ - org.zeroturnaround.eclipse.rebelXmlBuilder + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + LaunchConfigHandle + <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch + @@ -54,6 +48,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature
diff --git a/spring-security-rest-custom/.project b/spring-security-rest-custom/.project index 0e824c1bde6a..4fe382b78e90 100644 --- a/spring-security-rest-custom/.project +++ b/spring-security-rest-custom/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder @@ -32,8 +21,13 @@ - org.zeroturnaround.eclipse.rebelXmlBuilder + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + LaunchConfigHandle + <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch + @@ -54,6 +48,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature
diff --git a/spring-security-rest-full/.project b/spring-security-rest-full/.project index e914491b964d..4436c6f0abd3 100644 --- a/spring-security-rest-full/.project +++ b/spring-security-rest-full/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder @@ -32,8 +21,13 @@ - org.zeroturnaround.eclipse.rebelXmlBuilder + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + LaunchConfigHandle + <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch + @@ -54,6 +48,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-security-rest/.project b/spring-security-rest/.project index 67be91451e64..9f44238b3616 100644 --- a/spring-security-rest/.project +++ b/spring-security-rest/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder @@ -32,8 +21,13 @@ - org.zeroturnaround.eclipse.rebelXmlBuilder + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + LaunchConfigHandle + <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch + @@ -54,6 +48,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature From e98c28cb906e6650b85254649dcafb0bbd3e0df9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:14:32 +0300 Subject: [PATCH 182/796] eclipse cleanup --- spring-all/.project | 6 ------ spring-exceptions/.project | 6 ------ spring-hibernate3/.project | 6 ------ spring-hibernate4/.project | 6 ------ spring-jpa/.project | 6 ------ spring-mvc-java/.project | 6 ------ spring-mvc-xml/.project | 6 ------ spring-mvc/.project | 6 ------ spring-security-basic-auth/.project | 6 ------ .../org.zeroturnaround.eclipse.rebelXmlBuilder.launch | 7 +++++++ .../org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch | 7 +++++++ .../org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch | 7 +++++++ .../org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch | 7 +++++++ 13 files changed, 28 insertions(+), 54 deletions(-) create mode 100644 spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch create mode 100644 spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch create mode 100644 spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch create mode 100644 spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch diff --git a/spring-all/.project b/spring-all/.project index 4ae82dabf052..e7f6943aaf99 100644 --- a/spring-all/.project +++ b/spring-all/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -55,6 +50,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-exceptions/.project b/spring-exceptions/.project index 8c9eba80050f..df494e2f1492 100644 --- a/spring-exceptions/.project +++ b/spring-exceptions/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -55,6 +50,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-hibernate3/.project b/spring-hibernate3/.project index 5725f008def9..1184fb6b23b1 100644 --- a/spring-hibernate3/.project +++ b/spring-hibernate3/.project @@ -20,11 +20,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -44,6 +39,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-hibernate4/.project b/spring-hibernate4/.project index 40591b21b2fc..b68719164667 100644 --- a/spring-hibernate4/.project +++ b/spring-hibernate4/.project @@ -20,11 +20,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -44,6 +39,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-jpa/.project b/spring-jpa/.project index 3fe887cb4569..235ae29ecfc3 100644 --- a/spring-jpa/.project +++ b/spring-jpa/.project @@ -20,11 +20,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -44,6 +39,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-mvc-java/.project b/spring-mvc-java/.project index 46209afeadc7..c8c351837639 100644 --- a/spring-mvc-java/.project +++ b/spring-mvc-java/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -55,6 +50,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-mvc-xml/.project b/spring-mvc-xml/.project index 6cdb4e0e5194..65f553ae4910 100644 --- a/spring-mvc-xml/.project +++ b/spring-mvc-xml/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -55,6 +50,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-mvc/.project b/spring-mvc/.project index 90b8ccd78f8f..bd728edc359f 100644 --- a/spring-mvc/.project +++ b/spring-mvc/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -55,6 +50,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-security-basic-auth/.project b/spring-security-basic-auth/.project index f2aa3ca83eb0..7426b8140db3 100644 --- a/spring-security-basic-auth/.project +++ b/spring-security-basic-auth/.project @@ -31,11 +31,6 @@ - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - org.springframework.ide.eclipse.core.springbuilder @@ -54,6 +49,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.zeroturnaround.eclipse.jrebelNature diff --git a/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch b/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch new file mode 100644 index 000000000000..2dc234468353 --- /dev/null +++ b/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch b/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch new file mode 100644 index 000000000000..2dc234468353 --- /dev/null +++ b/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch b/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch new file mode 100644 index 000000000000..2dc234468353 --- /dev/null +++ b/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch b/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch new file mode 100644 index 000000000000..2dc234468353 --- /dev/null +++ b/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch @@ -0,0 +1,7 @@ + + + + + + + From 402db7c1d3703bb72963c0033846a488b958c171 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:16:26 +0300 Subject: [PATCH 183/796] finishing eclipse cleanup --- spring-all/.project | 11 ----------- spring-exceptions/.project | 11 ----------- spring-mvc-java/.project | 11 ----------- spring-mvc-xml/.project | 11 ----------- spring-mvc/.project | 11 ----------- spring-security-basic-auth/.project | 11 ----------- .../org.zeroturnaround.eclipse.rebelXmlBuilder.launch | 7 ------- spring-security-login/.project | 10 ---------- ....zeroturnaround.eclipse.rebelXmlBuilder (2).launch | 7 ------- spring-security-rest-custom/.project | 10 ---------- ....zeroturnaround.eclipse.rebelXmlBuilder (3).launch | 7 ------- spring-security-rest-full/.project | 10 ---------- ....zeroturnaround.eclipse.rebelXmlBuilder (1).launch | 7 ------- spring-security-rest/.project | 10 ---------- 14 files changed, 134 deletions(-) delete mode 100644 spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch delete mode 100644 spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch delete mode 100644 spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch delete mode 100644 spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch diff --git a/spring-all/.project b/spring-all/.project index e7f6943aaf99..ce1efa888003 100644 --- a/spring-all/.project +++ b/spring-all/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-exceptions/.project b/spring-exceptions/.project index df494e2f1492..810b4a928626 100644 --- a/spring-exceptions/.project +++ b/spring-exceptions/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-mvc-java/.project b/spring-mvc-java/.project index c8c351837639..21aa8efe0fc5 100644 --- a/spring-mvc-java/.project +++ b/spring-mvc-java/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-mvc-xml/.project b/spring-mvc-xml/.project index 65f553ae4910..de41bcaace08 100644 --- a/spring-mvc-xml/.project +++ b/spring-mvc-xml/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-mvc/.project b/spring-mvc/.project index bd728edc359f..47bfed4d2afc 100644 --- a/spring-mvc/.project +++ b/spring-mvc/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-security-basic-auth/.project b/spring-security-basic-auth/.project index 7426b8140db3..74e667d477a1 100644 --- a/spring-security-basic-auth/.project +++ b/spring-security-basic-auth/.project @@ -5,17 +5,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - org.eclipse.jdt.core.javabuilder diff --git a/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch b/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch deleted file mode 100644 index 2dc234468353..000000000000 --- a/spring-security-login/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-security-login/.project b/spring-security-login/.project index 72e28ae1298c..e403abcddab9 100644 --- a/spring-security-login/.project +++ b/spring-security-login/.project @@ -20,16 +20,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder.launch - - - org.springframework.ide.eclipse.core.springbuilder diff --git a/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch b/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch deleted file mode 100644 index 2dc234468353..000000000000 --- a/spring-security-rest-custom/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-security-rest-custom/.project b/spring-security-rest-custom/.project index 4fe382b78e90..801347984eaf 100644 --- a/spring-security-rest-custom/.project +++ b/spring-security-rest-custom/.project @@ -20,16 +20,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (2).launch - - - org.springframework.ide.eclipse.core.springbuilder diff --git a/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch b/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch deleted file mode 100644 index 2dc234468353..000000000000 --- a/spring-security-rest-full/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-security-rest-full/.project b/spring-security-rest-full/.project index 4436c6f0abd3..89da95b5283f 100644 --- a/spring-security-rest-full/.project +++ b/spring-security-rest-full/.project @@ -20,16 +20,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (3).launch - - - org.springframework.ide.eclipse.core.springbuilder diff --git a/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch b/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch deleted file mode 100644 index 2dc234468353..000000000000 --- a/spring-security-rest/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/spring-security-rest/.project b/spring-security-rest/.project index 9f44238b3616..f07f8b2e06b0 100644 --- a/spring-security-rest/.project +++ b/spring-security-rest/.project @@ -20,16 +20,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.zeroturnaround.eclipse.rebelXmlBuilder (1).launch - - - org.springframework.ide.eclipse.core.springbuilder From 11e6c4ad3d46fd1a7843173e6ed11ff832970c37 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:19:31 +0300 Subject: [PATCH 184/796] project rename --- .../.classpath | 0 .../org.eclipse.wst.jsdt.core.javascriptValidator.launch | 0 .../.gitignore | 0 .../.project | 0 .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../.settings/org.eclipse.wst.common.component | 0 .../.settings/org.eclipse.wst.common.project.facet.core.xml | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.container | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.name | 0 .../.settings/org.eclipse.wst.validation.prefs | 0 .../.settings/org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 .../README.md | 0 .../pom.xml | 0 .../baeldung/security/basic/MyBasicAuthenticationEntryPoint.java | 0 .../src/main/java/org/baeldung/spring/MvcConfig.java | 0 .../src/main/java/org/baeldung/spring/SecSecurityConfig.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.classpath (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.gitignore (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.project (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/.jsdtscope (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.common.component (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/.springBeans (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/README.md (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/pom.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/java/org/baeldung/spring/MvcConfig.java (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/resources/logback.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-security-digest-auth => spring-security-mvc-digest-auth}/src/test/resources/.gitignore (100%) diff --git a/spring-security-digest-auth/.classpath b/spring-security-mvc-digest-auth/.classpath similarity index 100% rename from spring-security-digest-auth/.classpath rename to spring-security-mvc-digest-auth/.classpath diff --git a/spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-mvc-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-security-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-security-mvc-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-security-digest-auth/.gitignore b/spring-security-mvc-digest-auth/.gitignore similarity index 100% rename from spring-security-digest-auth/.gitignore rename to spring-security-mvc-digest-auth/.gitignore diff --git a/spring-security-digest-auth/.project b/spring-security-mvc-digest-auth/.project similarity index 100% rename from spring-security-digest-auth/.project rename to spring-security-mvc-digest-auth/.project diff --git a/spring-security-digest-auth/.settings/.jsdtscope b/spring-security-mvc-digest-auth/.settings/.jsdtscope similarity index 100% rename from spring-security-digest-auth/.settings/.jsdtscope rename to spring-security-mvc-digest-auth/.settings/.jsdtscope diff --git a/spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.jdt.core.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.jdt.ui.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.m2e.core.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.m2e.wtp.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.common.component b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.common.component rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.common.component diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.validation.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-security-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-security-mvc-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-security-digest-auth/.springBeans b/spring-security-mvc-digest-auth/.springBeans similarity index 100% rename from spring-security-digest-auth/.springBeans rename to spring-security-mvc-digest-auth/.springBeans diff --git a/spring-security-digest-auth/README.md b/spring-security-mvc-digest-auth/README.md similarity index 100% rename from spring-security-digest-auth/README.md rename to spring-security-mvc-digest-auth/README.md diff --git a/spring-security-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml similarity index 100% rename from spring-security-digest-auth/pom.xml rename to spring-security-mvc-digest-auth/pom.xml diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-mvc-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java similarity index 100% rename from spring-security-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java rename to spring-security-mvc-digest-auth/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 100% rename from spring-security-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java rename to spring-security-mvc-digest-auth/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 100% rename from spring-security-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-mvc-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java diff --git a/spring-security-digest-auth/src/main/resources/logback.xml b/spring-security-mvc-digest-auth/src/main/resources/logback.xml similarity index 100% rename from spring-security-digest-auth/src/main/resources/logback.xml rename to spring-security-mvc-digest-auth/src/main/resources/logback.xml diff --git a/spring-security-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-digest-auth/src/main/resources/webSecurityConfig.xml rename to spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-security-digest-auth/src/main/webapp/WEB-INF/web.xml rename to spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-digest-auth/src/test/resources/.gitignore b/spring-security-mvc-digest-auth/src/test/resources/.gitignore similarity index 100% rename from spring-security-digest-auth/src/test/resources/.gitignore rename to spring-security-mvc-digest-auth/src/test/resources/.gitignore From b546b25939ef4521550c46d2db45c051a58ac563 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:21:15 +0300 Subject: [PATCH 185/796] project cleanup --- spring-security-login/.project | 2 +- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-security-login/pom.xml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-security-login/.project b/spring-security-login/.project index e403abcddab9..d52a48244aef 100644 --- a/spring-security-login/.project +++ b/spring-security-login/.project @@ -1,6 +1,6 @@ - spring-security-login + spring-security-mvc-login diff --git a/spring-security-login/.settings/org.eclipse.wst.common.component b/spring-security-login/.settings/org.eclipse.wst.common.component index c42e29f80edc..8b704170f815 100644 --- a/spring-security-login/.settings/org.eclipse.wst.common.component +++ b/spring-security-login/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-login/pom.xml b/spring-security-login/pom.xml index 4acf8ce02acd..73968b027385 100644 --- a/spring-security-login/pom.xml +++ b/spring-security-login/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-security-login + spring-security-mvc-login 0.1-SNAPSHOT - spring-security-login + spring-security-mvc-login war @@ -124,7 +124,7 @@ - spring-security-login + spring-security-mvc-login src/main/resources From 1fd1a2e0bf85b77fc496fabfa77cc8ef73c07cf5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:22:01 +0300 Subject: [PATCH 186/796] project structure cleanup --- {spring-security-login => spring-security-mvc-login}/.classpath | 0 .../org.eclipse.wst.jsdt.core.javascriptValidator.launch | 0 {spring-security-login => spring-security-mvc-login}/.gitignore | 0 {spring-security-login => spring-security-mvc-login}/.project | 0 .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../.settings/org.eclipse.wst.common.component | 0 .../.settings/org.eclipse.wst.common.project.facet.core.xml | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.container | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.name | 0 .../.settings/org.eclipse.wst.validation.prefs | 0 .../.settings/org.eclipse.wst.ws.service.policy.prefs | 0 {spring-security-login => spring-security-mvc-login}/.springBeans | 0 {spring-security-login => spring-security-mvc-login}/README.md | 0 {spring-security-login => spring-security-mvc-login}/pom.xml | 0 .../java/org/baeldung/security/CustomLogoutSuccessHandler.java | 0 .../src/main/java/org/baeldung/spring/MvcConfig.java | 0 .../src/main/java/org/baeldung/spring/SecSecurityConfig.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/anonymous.jsp | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/view/login.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/resources/.gitignore | 0 29 files changed, 0 insertions(+), 0 deletions(-) rename {spring-security-login => spring-security-mvc-login}/.classpath (100%) rename {spring-security-login => spring-security-mvc-login}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-security-login => spring-security-mvc-login}/.gitignore (100%) rename {spring-security-login => spring-security-mvc-login}/.project (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/.jsdtscope (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.common.component (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-security-login => spring-security-mvc-login}/.springBeans (100%) rename {spring-security-login => spring-security-mvc-login}/README.md (100%) rename {spring-security-login => spring-security-mvc-login}/pom.xml (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/java/org/baeldung/spring/MvcConfig.java (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/resources/logback.xml (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/webapp/WEB-INF/view/anonymous.jsp (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/webapp/WEB-INF/view/login.jsp (100%) rename {spring-security-login => spring-security-mvc-login}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-security-login => spring-security-mvc-login}/src/test/resources/.gitignore (100%) diff --git a/spring-security-login/.classpath b/spring-security-mvc-login/.classpath similarity index 100% rename from spring-security-login/.classpath rename to spring-security-mvc-login/.classpath diff --git a/spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-mvc-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-security-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-security-mvc-login/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-security-login/.gitignore b/spring-security-mvc-login/.gitignore similarity index 100% rename from spring-security-login/.gitignore rename to spring-security-mvc-login/.gitignore diff --git a/spring-security-login/.project b/spring-security-mvc-login/.project similarity index 100% rename from spring-security-login/.project rename to spring-security-mvc-login/.project diff --git a/spring-security-login/.settings/.jsdtscope b/spring-security-mvc-login/.settings/.jsdtscope similarity index 100% rename from spring-security-login/.settings/.jsdtscope rename to spring-security-mvc-login/.settings/.jsdtscope diff --git a/spring-security-login/.settings/org.eclipse.jdt.core.prefs b/spring-security-mvc-login/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.jdt.core.prefs rename to spring-security-mvc-login/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-security-login/.settings/org.eclipse.jdt.ui.prefs b/spring-security-mvc-login/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.jdt.ui.prefs rename to spring-security-mvc-login/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-security-login/.settings/org.eclipse.m2e.core.prefs b/spring-security-mvc-login/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.m2e.core.prefs rename to spring-security-mvc-login/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-security-login/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-mvc-login/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.m2e.wtp.prefs rename to spring-security-mvc-login/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-security-login/.settings/org.eclipse.wst.common.component b/spring-security-mvc-login/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.common.component rename to spring-security-mvc-login/.settings/org.eclipse.wst.common.component diff --git a/spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-mvc-login/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-security-mvc-login/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-mvc-login/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-security-mvc-login/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-mvc-login/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-security-mvc-login/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-security-login/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.validation.prefs rename to spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-mvc-login/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-security-login/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-security-mvc-login/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-security-login/.springBeans b/spring-security-mvc-login/.springBeans similarity index 100% rename from spring-security-login/.springBeans rename to spring-security-mvc-login/.springBeans diff --git a/spring-security-login/README.md b/spring-security-mvc-login/README.md similarity index 100% rename from spring-security-login/README.md rename to spring-security-mvc-login/README.md diff --git a/spring-security-login/pom.xml b/spring-security-mvc-login/pom.xml similarity index 100% rename from spring-security-login/pom.xml rename to spring-security-mvc-login/pom.xml diff --git a/spring-security-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java b/spring-security-mvc-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java similarity index 100% rename from spring-security-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java rename to spring-security-mvc-login/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java diff --git a/spring-security-login/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-login/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 100% rename from spring-security-login/src/main/java/org/baeldung/spring/MvcConfig.java rename to spring-security-mvc-login/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 100% rename from spring-security-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-mvc-login/src/main/java/org/baeldung/spring/SecSecurityConfig.java diff --git a/spring-security-login/src/main/resources/logback.xml b/spring-security-mvc-login/src/main/resources/logback.xml similarity index 100% rename from spring-security-login/src/main/resources/logback.xml rename to spring-security-mvc-login/src/main/resources/logback.xml diff --git a/spring-security-login/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-login/src/main/resources/webSecurityConfig.xml rename to spring-security-mvc-login/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-mvc-login/src/main/webapp/WEB-INF/view/anonymous.jsp similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/view/anonymous.jsp rename to spring-security-mvc-login/src/main/webapp/WEB-INF/view/anonymous.jsp diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-login/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-security-mvc-login/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/view/login.jsp rename to spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-login/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-security-login/src/main/webapp/WEB-INF/web.xml rename to spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-login/src/test/resources/.gitignore b/spring-security-mvc-login/src/test/resources/.gitignore similarity index 100% rename from spring-security-login/src/test/resources/.gitignore rename to spring-security-mvc-login/src/test/resources/.gitignore From cd5e64c6880f45e3ae87d9369087ad2d07362260 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:25:28 +0300 Subject: [PATCH 187/796] initial work on custom mvc project for spring security --- spring-security-mvc-custom/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-mvc-custom/.gitignore | 13 ++ spring-security-mvc-custom/.project | 42 ++++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-mvc-custom/.springBeans | 14 ++ spring-security-mvc-custom/README.md | 15 ++ spring-security-mvc-custom/pom.xml | 212 ++++++++++++++++++ .../security/CustomLogoutSuccessHandler.java | 29 +++ .../java/org/baeldung/spring/MvcConfig.java | 42 ++++ .../baeldung/spring/SecSecurityConfig.java | 14 ++ .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 40 ++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../main/webapp/WEB-INF/view/anonymous.jsp | 10 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 22 ++ .../src/main/webapp/WEB-INF/view/login.jsp | 26 +++ .../src/main/webapp/WEB-INF/web.xml | 50 +++++ .../src/test/resources/.gitignore | 13 ++ 29 files changed, 800 insertions(+) create mode 100644 spring-security-mvc-custom/.classpath create mode 100644 spring-security-mvc-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-mvc-custom/.gitignore create mode 100644 spring-security-mvc-custom/.project create mode 100644 spring-security-mvc-custom/.settings/.jsdtscope create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-mvc-custom/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-mvc-custom/.springBeans create mode 100644 spring-security-mvc-custom/README.md create mode 100644 spring-security-mvc-custom/pom.xml create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-mvc-custom/src/main/resources/logback.xml create mode 100644 spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/view/anonymous.jsp create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-mvc-custom/src/test/resources/.gitignore diff --git a/spring-security-mvc-custom/.classpath b/spring-security-mvc-custom/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-mvc-custom/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-mvc-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-mvc-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-mvc-custom/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-mvc-custom/.gitignore b/spring-security-mvc-custom/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-mvc-custom/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-mvc-custom/.project b/spring-security-mvc-custom/.project new file mode 100644 index 000000000000..81c640f9e3e2 --- /dev/null +++ b/spring-security-mvc-custom/.project @@ -0,0 +1,42 @@ + + + spring-security-mvc-custom + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-security-mvc-custom/.settings/.jsdtscope b/spring-security-mvc-custom/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-mvc-custom/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-mvc-custom/.settings/org.eclipse.jdt.core.prefs b/spring-security-mvc-custom/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-mvc-custom/.settings/org.eclipse.jdt.ui.prefs b/spring-security-mvc-custom/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-mvc-custom/.settings/org.eclipse.m2e.core.prefs b/spring-security-mvc-custom/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-mvc-custom/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-mvc-custom/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..8b704170f815 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-mvc-custom/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-mvc-custom/.springBeans b/spring-security-mvc-custom/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-mvc-custom/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md new file mode 100644 index 000000000000..256078f4b6ed --- /dev/null +++ b/spring-security-mvc-custom/README.md @@ -0,0 +1,15 @@ +========= + +## Spring Security Login Example Project + + +### Relevant Articles: +- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) +- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) +- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) + + +### Build the Project +``` +mvn clean install +``` diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml new file mode 100644 index 000000000000..73968b027385 --- /dev/null +++ b/spring-security-mvc-custom/pom.xml @@ -0,0 +1,212 @@ + + 4.0.0 + org.baeldung + spring-security-mvc-login + 0.1-SNAPSHOT + + spring-security-mvc-login + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-login + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java new file mode 100644 index 000000000000..7360b4e03f07 --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java @@ -0,0 +1,29 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; +import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; + +public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler { + + public CustomLogoutSuccessHandler() { + super(); + } + + // API + + @Override + public void onLogoutSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { + final String refererUrl = request.getHeader("Referer"); + System.out.println(refererUrl); + + super.onLogoutSuccess(request, response, authentication); + } + +} diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..f6f3e2a429cb --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,42 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/anonymous.html"); + + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4da114c78b62 --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-mvc-custom/src/main/resources/logback.xml b/spring-security-mvc-custom/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-mvc-custom/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..742d9fdf03c3 --- /dev/null +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/anonymous.jsp new file mode 100644 index 000000000000..d4e9c0289b29 --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/anonymous.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Anonymous page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..93f9dc2fbdf8 --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the body of the sample view

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..013ceccb4e4d --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,26 @@ + + + + +

Login

+ +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+ + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..c8d785a29842 --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/test/resources/.gitignore b/spring-security-mvc-custom/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-mvc-custom/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 6858e46070aea7dae3321b8029a58c9f43c5e01d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Jul 2013 15:26:29 +0300 Subject: [PATCH 188/796] finishing up the initial state of the custom mvc project --- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-security-mvc-custom/pom.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component index 8b704170f815..0a268a3d82a0 100644 --- a/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 73968b027385..6c6d4de4e9b7 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-security-mvc-login + spring-security-mvc-custom 0.1-SNAPSHOT - spring-security-mvc-login + spring-security-mvc-custom war @@ -124,7 +124,7 @@ - spring-security-mvc-login + spring-security-mvc-custom src/main/resources From 909f05af95e9ddf48276fa490461109023ff01e8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 17:56:43 +0300 Subject: [PATCH 189/796] cleanup work on mvc custom project --- spring-security-mvc-custom/README.md | 3 - .../security/CustomLogoutSuccessHandler.java | 29 --------- ...SimpleUrlAuthenticationSuccessHandler.java | 62 +++++++++++++++++++ .../src/main/resources/webSecurityConfig.xml | 19 +++--- 4 files changed, 72 insertions(+), 41 deletions(-) delete mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 256078f4b6ed..a4e96afc2a29 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -4,9 +4,6 @@ ### Relevant Articles: -- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) -- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) -- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) ### Build the Project diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java deleted file mode 100644 index 7360b4e03f07..000000000000 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/security/CustomLogoutSuccessHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.security; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; - -public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler { - - public CustomLogoutSuccessHandler() { - super(); - } - - // API - - @Override - public void onLogoutSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { - final String refererUrl = request.getHeader("Referer"); - System.out.println(refererUrl); - - super.onLogoutSuccess(request, response, authentication); - } - -} diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..c736e7974313 --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,62 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +/** + * AuthenticationSuccessHandler which can be configured with a default URL which users should be + * sent to upon successful authentication. + *

+ * The logic used is that of the {@link AbstractAuthenticationTargetUrlRequestHandler parent class}. + * + * @author Luke Taylor + * @since 3.0 + */ +public class MySimpleUrlAuthenticationSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler implements AuthenticationSuccessHandler { + + public MySimpleUrlAuthenticationSuccessHandler() { + super(); + } + + /** + * Constructor which sets the defaultTargetUrl property of the base class. + * @param defaultTargetUrl the URL to which the user should be redirected on successful authentication. + */ + public MySimpleUrlAuthenticationSuccessHandler(final String defaultTargetUrl) { + setDefaultTargetUrl(defaultTargetUrl); + } + + /** + * Calls the parent class {@code handle()} method to forward or redirect to the target URL, and + * then calls {@code clearAuthenticationAttributes()} to remove any leftover session data. + */ + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { + handle(request, response, authentication); + clearAuthenticationAttributes(request); + } + + /** + * Removes temporary authentication-related data which may have been stored in the session + * during the authentication process. + */ + protected final void clearAuthenticationAttributes(final HttpServletRequest request) { + final HttpSession session = request.getSession(false); + + if (session == null) { + return; + } + + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + +} diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index 742d9fdf03c3..dffbcf0d0459 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -15,18 +15,19 @@ + authentication-success-handler-ref="myAuthenticationSuccessHandler" + authentication-failure-url="/login.html?error=true" + /> - + - - + + From 3a1897d610c0585e27c93cabd42018b92b3f000f Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 18:08:19 +0300 Subject: [PATCH 190/796] redirect after login --- ...SimpleUrlAuthenticationSuccessHandler.java | 69 ++++++++++++++----- .../java/org/baeldung/spring/MvcConfig.java | 1 + .../src/main/resources/webSecurityConfig.xml | 1 + .../src/main/webapp/WEB-INF/view/console.jsp | 22 ++++++ 4 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index c736e7974313..aa5a666e9aad 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -7,32 +7,67 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.security.core.Authentication; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; import org.springframework.security.web.WebAttributes; -import org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; -/** - * AuthenticationSuccessHandler which can be configured with a default URL which users should be - * sent to upon successful authentication. - *

- * The logic used is that of the {@link AbstractAuthenticationTargetUrlRequestHandler parent class}. - * - * @author Luke Taylor - * @since 3.0 - */ -public class MySimpleUrlAuthenticationSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler implements AuthenticationSuccessHandler { - - public MySimpleUrlAuthenticationSuccessHandler() { +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + protected final Log logger = LogFactory.getLog(this.getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + protected MySimpleUrlAuthenticationSuccessHandler() { super(); } /** - * Constructor which sets the defaultTargetUrl property of the base class. - * @param defaultTargetUrl the URL to which the user should be redirected on successful authentication. + * Invokes the configured {@code RedirectStrategy} with the URL returned by the {@code determineTargetUrl} method. + *

+ * The redirect will not be performed if the response has already been committed. + */ + protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { + final String targetUrl = determineTargetUrl(request, response); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + /** + * Builds the target URL according to the logic defined in the main class Javadoc. */ - public MySimpleUrlAuthenticationSuccessHandler(final String defaultTargetUrl) { - setDefaultTargetUrl(defaultTargetUrl); + protected String determineTargetUrl(final HttpServletRequest requestRaw, final HttpServletResponse response) { + // Check for the parameter and use that if available + + final SecurityContextHolderAwareRequestWrapper req = (SecurityContextHolderAwareRequestWrapper) requestRaw; + final boolean isUser = req.isUserInRole("ROLE_USER"); + final boolean isAdmin = req.isUserInRole("ROLE_ADMIN"); + if (isUser) { + return "/homepage.html"; + } else if (isAdmin) { + return "/console.html"; + } else { + throw new IllegalStateException(); + } + } + + /** + * Allows overriding of the behavior when redirecting to a target URL. + */ + public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; } /** diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java index f6f3e2a429cb..2229516633ff 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -27,6 +27,7 @@ public void addViewControllers(final ViewControllerRegistry registry) { registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); + registry.addViewController("/console.html"); } @Bean diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index dffbcf0d0459..edf077615135 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -34,6 +34,7 @@ + diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..93f9dc2fbdf8 --- /dev/null +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the body of the sample view

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file From 984a0bfa478ddccee8cce5b5a30dd5324b25b5b9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 18:11:45 +0300 Subject: [PATCH 191/796] finishing up redirect work --- ...SimpleUrlAuthenticationSuccessHandler.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index aa5a666e9aad..ba0c1c8c0d95 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -1,6 +1,7 @@ package org.baeldung.security; import java.io.IOException; +import java.util.Collection; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -10,11 +11,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; import org.springframework.security.web.DefaultRedirectStrategy; import org.springframework.security.web.RedirectStrategy; import org.springframework.security.web.WebAttributes; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; -import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { protected final Log logger = LogFactory.getLog(this.getClass()); @@ -47,9 +48,20 @@ protected void handle(final HttpServletRequest request, final HttpServletRespons protected String determineTargetUrl(final HttpServletRequest requestRaw, final HttpServletResponse response) { // Check for the parameter and use that if available - final SecurityContextHolderAwareRequestWrapper req = (SecurityContextHolderAwareRequestWrapper) requestRaw; - final boolean isUser = req.isUserInRole("ROLE_USER"); - final boolean isAdmin = req.isUserInRole("ROLE_ADMIN"); + boolean isUser = false; + boolean isAdmin = false; + final Authentication authentication = org.springframework.security.core.context.SecurityContextHolder.getContext().getAuthentication(); + final Collection authorities = authentication.getAuthorities(); + for (final GrantedAuthority grantedAuthority : authorities) { + if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + isUser = true; + break; + } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + isAdmin = true; + break; + } + } + if (isUser) { return "/homepage.html"; } else if (isAdmin) { From 495a13537d844a34f9923a51f39502d743b48609 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 19:42:05 +0300 Subject: [PATCH 192/796] redirect after login work --- ...SimpleUrlAuthenticationSuccessHandler.java | 5 +- .../src/main/resources/webSecurityConfig.xml | 47 +++++++------------ .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 12 ++--- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index ba0c1c8c0d95..ee63df11300c 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -12,6 +12,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.DefaultRedirectStrategy; import org.springframework.security.web.RedirectStrategy; import org.springframework.security.web.WebAttributes; @@ -46,11 +47,9 @@ protected void handle(final HttpServletRequest request, final HttpServletRespons * Builds the target URL according to the logic defined in the main class Javadoc. */ protected String determineTargetUrl(final HttpServletRequest requestRaw, final HttpServletResponse response) { - // Check for the parameter and use that if available - boolean isUser = false; boolean isAdmin = false; - final Authentication authentication = org.springframework.security.core.context.SecurityContextHolder.getContext().getAuthentication(); + final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); final Collection authorities = authentication.getAuthorities(); for (final GrantedAuthority grantedAuthority : authorities) { if (grantedAuthority.getAuthority().equals("ROLE_USER")) { diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index edf077615135..de7bd9b9818a 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -1,42 +1,31 @@ - - - + + - - - - - + - + - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp index 93f9dc2fbdf8..8f73dbfd0387 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp @@ -4,7 +4,7 @@ -

This is the body of the sample view

+

This is the landing page for the admin

This text is only visible to a user diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp index 93f9dc2fbdf8..43f86bb059f2 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,22 +1,22 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%> -

This is the body of the sample view

+

This is the homepage for the user

This text is only visible to a user -
+
- + This text is only visible to an admin -
+
">Logout - + \ No newline at end of file From dc2323f12d42ee6d4f19739095e855b91314c662 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 19:46:19 +0300 Subject: [PATCH 193/796] standard login and logout --- .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp index 8f73dbfd0387..d18b59a10caf 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp index 43f86bb059f2..afd2c6da594f 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp index 013ceccb4e4d..ba8b7748042b 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -4,7 +4,7 @@

Login

-
+ From 6458f2f32a11c6762e50982ba45f2c872b17f398 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Jul 2013 22:37:16 +0300 Subject: [PATCH 194/796] work on custom success handler --- ...SimpleUrlAuthenticationSuccessHandler.java | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index ee63df11300c..19f1ca76a6ce 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.Collection; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -12,7 +11,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.DefaultRedirectStrategy; import org.springframework.security.web.RedirectStrategy; import org.springframework.security.web.WebAttributes; @@ -27,13 +25,18 @@ protected MySimpleUrlAuthenticationSuccessHandler() { super(); } - /** - * Invokes the configured {@code RedirectStrategy} with the URL returned by the {@code determineTargetUrl} method. - *

- * The redirect will not be performed if the response has already been committed. - */ - protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { - final String targetUrl = determineTargetUrl(request, response); + // API + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + handle(request, response, authentication); + clearAuthenticationAttributes(request); + } + + // IMPL + + protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + final String targetUrl = determineTargetUrl(authentication); if (response.isCommitted()) { logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); @@ -43,13 +46,9 @@ protected void handle(final HttpServletRequest request, final HttpServletRespons redirectStrategy.sendRedirect(request, response, targetUrl); } - /** - * Builds the target URL according to the logic defined in the main class Javadoc. - */ - protected String determineTargetUrl(final HttpServletRequest requestRaw, final HttpServletResponse response) { + protected String determineTargetUrl(final Authentication authentication) { boolean isUser = false; boolean isAdmin = false; - final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); final Collection authorities = authentication.getAuthorities(); for (final GrantedAuthority grantedAuthority : authorities) { if (grantedAuthority.getAuthority().equals("ROLE_USER")) { @@ -70,27 +69,6 @@ protected String determineTargetUrl(final HttpServletRequest requestRaw, final H } } - /** - * Allows overriding of the behavior when redirecting to a target URL. - */ - public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { - this.redirectStrategy = redirectStrategy; - } - - protected RedirectStrategy getRedirectStrategy() { - return redirectStrategy; - } - - /** - * Calls the parent class {@code handle()} method to forward or redirect to the target URL, and - * then calls {@code clearAuthenticationAttributes()} to remove any leftover session data. - */ - @Override - public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { - handle(request, response, authentication); - clearAuthenticationAttributes(request); - } - /** * Removes temporary authentication-related data which may have been stored in the session * during the authentication process. @@ -105,4 +83,12 @@ protected final void clearAuthenticationAttributes(final HttpServletRequest requ session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); } + public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } + } From aef5e030974c3d8f608417101c5e3426b908464c Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 17 Jul 2013 22:44:08 +0300 Subject: [PATCH 195/796] work on different mechanisms of accessing the currently authenticated principal --- .../security/AuthenticationFacade.java | 21 ++++++++++ .../security/IAuthenticationFacade.java | 9 +++++ .../web/controller/FooController.java | 5 +-- .../web/controller/SecurityController1.java | 39 +++++++++++++++++++ .../web/controller/SecurityController2.java | 25 ++++++++++++ .../web/controller/SecurityController3.java | 24 ++++++++++++ .../web/controller/SecurityController4.java | 28 +++++++++++++ .../web/controller/SecurityController5.java | 30 ++++++++++++++ 8 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/security/AuthenticationFacade.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/security/IAuthenticationFacade.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController1.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController2.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController4.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController5.java diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/security/AuthenticationFacade.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/AuthenticationFacade.java new file mode 100644 index 000000000000..5a3c77b070f3 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/security/AuthenticationFacade.java @@ -0,0 +1,21 @@ +package org.baeldung.security; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +@Component +public class AuthenticationFacade implements IAuthenticationFacade { + + public AuthenticationFacade() { + super(); + } + + // API + + @Override + public final Authentication getAuthentication() { + return SecurityContextHolder.getContext().getAuthentication(); + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/security/IAuthenticationFacade.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/IAuthenticationFacade.java new file mode 100644 index 000000000000..d1223e41cf3a --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/security/IAuthenticationFacade.java @@ -0,0 +1,9 @@ +package org.baeldung.security; + +import org.springframework.security.core.Authentication; + +public interface IAuthenticationFacade { + + Authentication getAuthentication(); + +} \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java index d6eeea5f771d..ff5a00fd9509 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,7 +1,5 @@ package org.baeldung.web.controller; -import javax.servlet.http.HttpServletResponse; - import org.baeldung.web.dto.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; @@ -10,7 +8,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.util.UriComponentsBuilder; @Controller @RequestMapping(value = "/foo") @@ -27,7 +24,7 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + public Foo findOne(@PathVariable("id") final Long id) { return new Foo(); } diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController1.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController1.java new file mode 100644 index 000000000000..d06f15af93e0 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController1.java @@ -0,0 +1,39 @@ +package org.baeldung.web.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController1 { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public SecurityController1() { + super(); + } + + // API + + @RequestMapping(value = "/username1", method = RequestMethod.GET) + @ResponseBody + public String currentUserName() { + final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (!(authentication instanceof AnonymousAuthenticationToken)) { + final String currentPrincipalName = authentication.getName(); + System.out.println("Authentication: " + authentication); + System.out.println("Principal: " + authentication.getPrincipal()); + return currentPrincipalName; + } + + return null; + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController2.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController2.java new file mode 100644 index 000000000000..ac02738d0cd2 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController2.java @@ -0,0 +1,25 @@ +package org.baeldung.web.controller; + +import java.security.Principal; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController2 { + + public SecurityController2() { + super(); + } + + // API + + @RequestMapping(value = "/username2", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final Principal principal) { + return principal.getName(); + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java new file mode 100644 index 000000000000..a4f2e804693b --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java @@ -0,0 +1,24 @@ +package org.baeldung.web.controller; + +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController3 { + + public SecurityController3() { + super(); + } + + // API + + @RequestMapping(value = "/username3", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final Authentication authentication) { + return authentication.getName(); + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController4.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController4.java new file mode 100644 index 000000000000..0434cc5fdc49 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController4.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import java.security.Principal; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController4 { + + public SecurityController4() { + super(); + } + + // API + + @RequestMapping(value = "/username4", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final HttpServletRequest request) { + final Principal principal = request.getUserPrincipal(); + return principal.getName(); + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController5.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController5.java new file mode 100644 index 000000000000..e1a0c35cc691 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController5.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import org.baeldung.security.IAuthenticationFacade; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController5 { + + @Autowired + private IAuthenticationFacade authenticationFacade; + + public SecurityController5() { + super(); + } + + // API + + @RequestMapping(value = "/username5", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple() { + final Authentication authentication = authenticationFacade.getAuthentication(); + return authentication.getName(); + } + +} From 7bdb8ec66dca8e3589d329db7dfbd790b1443bdd Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 17 Jul 2013 23:17:36 +0300 Subject: [PATCH 196/796] finished work on the user access post --- .../org/baeldung/security/CustomAuthenticationProvider.java | 5 ++++- .../org/baeldung/web/controller/SecurityController3.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java b/spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java index e2ea9842afc0..4b9b3e8ee926 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java @@ -9,6 +9,8 @@ import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; @Component @@ -27,7 +29,8 @@ public Authentication authenticate(final Authentication authentication) throws A if (name.equals("admin") && password.equals("system")) { final List grantedAuths = new ArrayList<>(); grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER")); - final Authentication auth = new UsernamePasswordAuthenticationToken(name, password, grantedAuths); + final UserDetails principal = new User(name, password, grantedAuths); + final Authentication auth = new UsernamePasswordAuthenticationToken(principal, password, grantedAuths); return auth; } else { return null; diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java index a4f2e804693b..fb207b43ddf3 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/SecurityController3.java @@ -1,6 +1,7 @@ package org.baeldung.web.controller; import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -18,6 +19,8 @@ public SecurityController3() { @RequestMapping(value = "/username3", method = RequestMethod.GET) @ResponseBody public String currentUserNameSimple(final Authentication authentication) { + UserDetails userDetails = (UserDetails) authentication.getPrincipal(); + System.out.println("Retrieved user with authorities: " + userDetails.getAuthorities()); return authentication.getName(); } From ce7f1f11fc73a36c5a9b9687508dd19404d8ec04 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 24 Jul 2013 01:22:15 +0300 Subject: [PATCH 197/796] initial work on the exception handler example --- .../RestResponseEntityExceptionHandler.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java new file mode 100644 index 000000000000..95e8bcb677d1 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -0,0 +1,78 @@ +package org.baeldung.web.error; + +import javax.persistence.EntityNotFoundException; + +import org.hibernate.exception.ConstraintViolationException; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +@ControllerAdvice +public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { + + public RestResponseEntityExceptionHandler() { + super(); + } + + // API + + // 400 + + @ExceptionHandler({ ConstraintViolationException.class, DataIntegrityViolationException.class }) + public ResponseEntity handleBadRequest(final RuntimeException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleHttpMessageNotReadable(final HttpMessageNotReadableException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + // ex.getCause() instanceof JsonMappingException, JsonParseException // for additional information later on + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + // 403 + + // 404 + + @ExceptionHandler(value = { EntityNotFoundException.class }) + protected ResponseEntity handleBadRequest(final EntityNotFoundException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); + } + + // 409 + + @ExceptionHandler({ InvalidDataAccessApiUsageException.class, DataAccessException.class }) + protected ResponseEntity handleConflict(final RuntimeException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request); + } + + // 412 + + // 500 + + @ExceptionHandler({ NullPointerException.class, IllegalArgumentException.class, IllegalStateException.class }) + /*500*/public ResponseEntity handleInternal(final RuntimeException ex, final WebRequest request) { + logger.error("500 Status Code", ex); + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); + } + +} From 4232fa188ac2cbb3fe47cf20b949a47479ace5b0 Mon Sep 17 00:00:00 2001 From: eparaschiv Date: Wed, 24 Jul 2013 23:36:55 +0300 Subject: [PATCH 198/796] adding controller, cleanup --- spring-security-rest/pom.xml | 440 +++++++++--------- .../org/baeldung/persistence/model/Foo.java | 73 +++ .../java/org/baeldung/spring/WebConfig.java | 5 +- .../web/controller/FooController.java | 48 ++ 4 files changed, 352 insertions(+), 214 deletions(-) create mode 100644 spring-security-rest/src/main/java/org/baeldung/persistence/model/Foo.java create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 3cf7aef1285d..1a847975829a 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -1,215 +1,229 @@ - - 4.0.0 - org.baeldung - spring-security-rest - 0.1-SNAPSHOT - - spring-security-rest - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.2.Final - 5.1.25 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.1 - 1.8.9 - - - 1.4.2 - 2.15 - + + 4.0.0 + org.baeldung + spring-security-rest + 0.1-SNAPSHOT + + spring-security-rest + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + 3.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + \ No newline at end of file diff --git a/spring-security-rest/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-security-rest/src/main/java/org/baeldung/persistence/model/Foo.java new file mode 100644 index 000000000000..0124424f5969 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/persistence/model/Foo.java @@ -0,0 +1,73 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +public class Foo implements Serializable { + + private long id; + + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java index 29ddb3eaecf1..4d1d6e6403b4 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/WebConfig.java @@ -2,10 +2,13 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration @ComponentScan("org.baeldung.web") -public class WebConfig { +@EnableWebMvc +public class WebConfig extends WebMvcConfigurerAdapter { public WebConfig() { super(); diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..642878b91826 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,48 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.util.UriComponentsBuilder; + +import com.google.common.collect.Lists; + +@Controller +@RequestMapping(value = "/foos") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + // read + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(randomAlphabetic(6)); + } + + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public List findAll() { + return Lists.newArrayList(new Foo(randomAlphabetic(6))); + } + +} From 1b2cf960af4e9a40792ef6816e57a883ab215acb Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 00:06:35 +0300 Subject: [PATCH 199/796] initial work on the rest template tutorial project --- spring-security-rest-template/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-rest-template/.gitignore | 13 + spring-security-rest-template/.project | 42 +++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 +++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 + .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-rest-template/.springBeans | 14 + spring-security-rest-template/README.md | 7 + spring-security-rest-template/pom.xml | 242 ++++++++++++++++++ .../security/AuthenticationFacade.java | 21 ++ .../CustomAuthenticationProvider.java | 45 ++++ .../security/IAuthenticationFacade.java | 9 + ...uestAwareAuthenticationSuccessHandler.java | 48 ++++ .../RestAuthenticationEntryPoint.java | 23 ++ .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 31 +++ .../web/controller/FooController.java | 31 +++ .../web/controller/SecurityController1.java | 39 +++ .../web/controller/SecurityController2.java | 25 ++ .../web/controller/SecurityController3.java | 27 ++ .../web/controller/SecurityController4.java | 28 ++ .../web/controller/SecurityController5.java | 30 +++ .../main/java/org/baeldung/web/dto/Foo.java | 14 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 20 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + .../src/main/webapp/WEB-INF/web.xml | 51 ++++ .../src/test/resources/.gitignore | 13 + 37 files changed, 1047 insertions(+) create mode 100644 spring-security-rest-template/.classpath create mode 100644 spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-rest-template/.gitignore create mode 100644 spring-security-rest-template/.project create mode 100644 spring-security-rest-template/.settings/.jsdtscope create mode 100644 spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-rest-template/.springBeans create mode 100644 spring-security-rest-template/README.md create mode 100644 spring-security-rest-template/pom.xml create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-rest-template/src/main/resources/logback.xml create mode 100644 spring-security-rest-template/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 spring-security-rest-template/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-rest-template/src/test/resources/.gitignore diff --git a/spring-security-rest-template/.classpath b/spring-security-rest-template/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-rest-template/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest-template/.gitignore b/spring-security-rest-template/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-template/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-template/.project b/spring-security-rest-template/.project new file mode 100644 index 000000000000..1e6360f7e2a8 --- /dev/null +++ b/spring-security-rest-template/.project @@ -0,0 +1,42 @@ + + + spring-security-rest-template + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-security-rest-template/.settings/.jsdtscope b/spring-security-rest-template/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-rest-template/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.common.component b/spring-security-rest-template/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..d81a71a7eb1a --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-rest-template/.springBeans b/spring-security-rest-template/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/spring-security-rest-template/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/spring-security-rest-template/README.md b/spring-security-rest-template/README.md new file mode 100644 index 000000000000..3ec8cf92c71a --- /dev/null +++ b/spring-security-rest-template/README.md @@ -0,0 +1,7 @@ +========= + +## Spring Security for REST Example Project + + +### Relevant Articles: +- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-template/pom.xml new file mode 100644 index 000000000000..51fb1db96d66 --- /dev/null +++ b/spring-security-rest-template/pom.xml @@ -0,0 +1,242 @@ + + 4.0.0 + org.baeldung + spring-security-rest-template + 0.1-SNAPSHOT + + spring-security-rest-template + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-template + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.2.Final + 5.1.25 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.2 + 2.15 + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java b/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java new file mode 100644 index 000000000000..5a3c77b070f3 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java @@ -0,0 +1,21 @@ +package org.baeldung.security; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +@Component +public class AuthenticationFacade implements IAuthenticationFacade { + + public AuthenticationFacade() { + super(); + } + + // API + + @Override + public final Authentication getAuthentication() { + return SecurityContextHolder.getContext().getAuthentication(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java b/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java new file mode 100644 index 000000000000..4b9b3e8ee926 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java @@ -0,0 +1,45 @@ +package org.baeldung.security; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; + +@Component +public class CustomAuthenticationProvider implements AuthenticationProvider { + + public CustomAuthenticationProvider() { + super(); + } + + // API + + @Override + public Authentication authenticate(final Authentication authentication) throws AuthenticationException { + final String name = authentication.getName(); + final String password = authentication.getCredentials().toString(); + if (name.equals("admin") && password.equals("system")) { + final List grantedAuths = new ArrayList<>(); + grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER")); + final UserDetails principal = new User(name, password, grantedAuths); + final Authentication auth = new UsernamePasswordAuthenticationToken(principal, password, grantedAuths); + return auth; + } else { + return null; + } + } + + @Override + public boolean supports(final Class authentication) { + return authentication.equals(UsernamePasswordAuthenticationToken.class); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java b/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java new file mode 100644 index 000000000000..d1223e41cf3a --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java @@ -0,0 +1,9 @@ +package org.baeldung.security; + +import org.springframework.security.core.Authentication; + +public interface IAuthenticationFacade { + + Authentication getAuthentication(); + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..698052fa2b00 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -0,0 +1,48 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; + +public class MySavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + private RequestCache requestCache = new HttpSessionRequestCache(); + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws ServletException, IOException { + final SavedRequest savedRequest = requestCache.getRequest(request, response); + + if (savedRequest == null) { + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + final String targetUrlParameter = getTargetUrlParameter(); + if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { + requestCache.removeRequest(request, response); + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + + clearAuthenticationAttributes(request); + + // Use the DefaultSavedRequest URL + // final String targetUrl = savedRequest.getRedirectUrl(); + // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); + // getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + public void setRequestCache(final RequestCache requestCache) { + this.requestCache = requestCache; + } +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java new file mode 100644 index 000000000000..77aa32ff979e --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java @@ -0,0 +1,23 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +/** + * The Entry Point will not redirect to any sort of Login - it will return the 401 + */ +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..8c3d677af601 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,31 @@ +package org.baeldung.spring; + +import java.util.List; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // beans + + @Override + public void configureMessageConverters(final List> converters) { + super.configureMessageConverters(converters); + converters.add(new MappingJackson2HttpMessageConverter()); + } + + // + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..ff5a00fd9509 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,31 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id) { + return new Foo(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java new file mode 100644 index 000000000000..d06f15af93e0 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java @@ -0,0 +1,39 @@ +package org.baeldung.web.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController1 { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public SecurityController1() { + super(); + } + + // API + + @RequestMapping(value = "/username1", method = RequestMethod.GET) + @ResponseBody + public String currentUserName() { + final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (!(authentication instanceof AnonymousAuthenticationToken)) { + final String currentPrincipalName = authentication.getName(); + System.out.println("Authentication: " + authentication); + System.out.println("Principal: " + authentication.getPrincipal()); + return currentPrincipalName; + } + + return null; + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java new file mode 100644 index 000000000000..ac02738d0cd2 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java @@ -0,0 +1,25 @@ +package org.baeldung.web.controller; + +import java.security.Principal; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController2 { + + public SecurityController2() { + super(); + } + + // API + + @RequestMapping(value = "/username2", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final Principal principal) { + return principal.getName(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java new file mode 100644 index 000000000000..fb207b43ddf3 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java @@ -0,0 +1,27 @@ +package org.baeldung.web.controller; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController3 { + + public SecurityController3() { + super(); + } + + // API + + @RequestMapping(value = "/username3", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final Authentication authentication) { + UserDetails userDetails = (UserDetails) authentication.getPrincipal(); + System.out.println("Retrieved user with authorities: " + userDetails.getAuthorities()); + return authentication.getName(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java new file mode 100644 index 000000000000..0434cc5fdc49 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import java.security.Principal; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController4 { + + public SecurityController4() { + super(); + } + + // API + + @RequestMapping(value = "/username4", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple(final HttpServletRequest request) { + final Principal principal = request.getUserPrincipal(); + return principal.getName(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java new file mode 100644 index 000000000000..e1a0c35cc691 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import org.baeldung.security.IAuthenticationFacade; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class SecurityController5 { + + @Autowired + private IAuthenticationFacade authenticationFacade; + + public SecurityController5() { + super(); + } + + // API + + @RequestMapping(value = "/username5", method = RequestMethod.GET) + @ResponseBody + public String currentUserNameSimple() { + final Authentication authentication = authenticationFacade.getAuthentication(); + return authentication.getName(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..09c1dac933fe --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-rest-template/src/main/resources/logback.xml b/spring-security-rest-template/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-rest-template/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..3766574f346b --- /dev/null +++ b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..372688c8d87e --- /dev/null +++ b/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + Spring Security Custom Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/test/resources/.gitignore b/spring-security-rest-template/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-template/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 67844d3320d508bc0e37c007d08066de6df309bb Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 00:54:33 +0300 Subject: [PATCH 200/796] rest template work --- spring-security-rest-template/.classpath | 6 + .../org.eclipse.wst.common.component | 1 + spring-security-rest-template/pom.xml | 516 ++++++++++-------- ...entsClientHttpRequestFactoryBasicAuth.java | 42 ++ .../baeldung/client/RestTemplateFactory.java | 40 ++ .../org/baeldung/spring/ClientConfig.java | 16 + .../org/baeldung/client/ClientLiveTest.java | 26 + 7 files changed, 407 insertions(+), 240 deletions(-) create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java create mode 100644 spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java diff --git a/spring-security-rest-template/.classpath b/spring-security-rest-template/.classpath index 5dea19367768..ca257cf1f962 100644 --- a/spring-security-rest-template/.classpath +++ b/spring-security-rest-template/.classpath @@ -16,6 +16,12 @@ + + + + + + diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.common.component b/spring-security-rest-template/.settings/org.eclipse.wst.common.component index d81a71a7eb1a..7092dce0b65f 100644 --- a/spring-security-rest-template/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-template/.settings/org.eclipse.wst.common.component @@ -4,6 +4,7 @@ + diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-template/pom.xml index 51fb1db96d66..768b791119d5 100644 --- a/spring-security-rest-template/pom.xml +++ b/spring-security-rest-template/pom.xml @@ -1,242 +1,278 @@ - - 4.0.0 - org.baeldung - spring-security-rest-template - 0.1-SNAPSHOT - - spring-security-rest-template - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-template - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.2.Final - 5.1.25 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.1 - 1.8.9 - - - 1.4.2 - 2.15 - + + 4.0.0 + org.baeldung + spring-security-rest-template + 0.1-SNAPSHOT + + spring-security-rest-template + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-template + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.25 + + + 4.2.4 + 4.2.5 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java new file mode 100644 index 000000000000..5f808413ce8d --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java @@ -0,0 +1,42 @@ +package org.baeldung.client; + +import java.net.URI; + +import org.apache.http.HttpHost; +import org.apache.http.client.AuthCache; +import org.apache.http.client.protocol.ClientContext; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; +import org.springframework.http.HttpMethod; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; + +public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { + HttpHost host; + + public HttpComponentsClientHttpRequestFactoryBasicAuth(final HttpHost host) { + super(); + this.host = host; + } + + // + + @Override + protected HttpContext createHttpContext(final HttpMethod httpMethod, final URI uri) { + return createHttpContext(); + } + + private HttpContext createHttpContext() { + // Create AuthCache instance + final AuthCache authCache = new BasicAuthCache(); + // Generate BASIC scheme object and add it to the local auth cache + final BasicScheme basicAuth = new BasicScheme(); + authCache.put(host, basicAuth); + // Add AuthCache to the execution context + final BasicHttpContext localcontext = new BasicHttpContext(); + localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); + return localcontext; + } + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java new file mode 100644 index 000000000000..3401d14d852a --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -0,0 +1,40 @@ +package org.baeldung.client; + +import org.apache.http.HttpHost; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +@Component +public class RestTemplateFactory implements FactoryBean, InitializingBean { + private RestTemplate restTemplate; + + public RestTemplateFactory() { + super(); + } + + // API + + @Override + public RestTemplate getObject() { + return restTemplate; + } + + @Override + public Class getObjectType() { + return RestTemplate.class; + } + + @Override + public boolean isSingleton() { + return true; + } + + @Override + public void afterPropertiesSet() { + final HttpHost host = new HttpHost("localhost", 8080, "http"); + restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactoryBasicAuth(host)); + } + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java b/spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java new file mode 100644 index 000000000000..a0c90b51aee1 --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.client") +public class ClientConfig { + + public ClientConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java new file mode 100644 index 000000000000..be215bf959c4 --- /dev/null +++ b/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -0,0 +1,26 @@ +package org.baeldung.client; + +import org.baeldung.spring.ClientConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.web.client.RestTemplate; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) +public class ClientLiveTest { + + @Autowired + private RestTemplate restTemplate; + + // tests + + @Test + public final void whenSecuredRestApiIsConsumed_then200OK() { + System.out.println(); + } + +} From 91a244e8e9406c993aad2c192e4dfa220b2f19d3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 01:03:26 +0300 Subject: [PATCH 201/796] further rest template work --- .../{ => client}/spring/ClientConfig.java | 2 +- .../security/AuthenticationFacade.java | 21 --------- .../CustomAuthenticationProvider.java | 45 ------------------- .../security/IAuthenticationFacade.java | 9 ---- .../web/controller/FooController.java | 4 +- .../web/controller/SecurityController1.java | 39 ---------------- .../web/controller/SecurityController2.java | 25 ----------- .../web/controller/SecurityController3.java | 27 ----------- .../web/controller/SecurityController4.java | 28 ------------ .../web/controller/SecurityController5.java | 30 ------------- .../src/main/resources/webSecurityConfig.xml | 8 +++- .../org/baeldung/client/ClientLiveTest.java | 16 ++++++- 12 files changed, 24 insertions(+), 230 deletions(-) rename spring-security-rest-template/src/main/java/org/baeldung/{ => client}/spring/ClientConfig.java (88%) delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java delete mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java b/spring-security-rest-template/src/main/java/org/baeldung/client/spring/ClientConfig.java similarity index 88% rename from spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java rename to spring-security-rest-template/src/main/java/org/baeldung/client/spring/ClientConfig.java index a0c90b51aee1..73e602855c7e 100644 --- a/spring-security-rest-template/src/main/java/org/baeldung/spring/ClientConfig.java +++ b/spring-security-rest-template/src/main/java/org/baeldung/client/spring/ClientConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package org.baeldung.client.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java b/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java deleted file mode 100644 index 5a3c77b070f3..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/security/AuthenticationFacade.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.baeldung.security; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; - -@Component -public class AuthenticationFacade implements IAuthenticationFacade { - - public AuthenticationFacade() { - super(); - } - - // API - - @Override - public final Authentication getAuthentication() { - return SecurityContextHolder.getContext().getAuthentication(); - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java b/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java deleted file mode 100644 index 4b9b3e8ee926..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/security/CustomAuthenticationProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.baeldung.security; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.security.authentication.AuthenticationProvider; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.stereotype.Component; - -@Component -public class CustomAuthenticationProvider implements AuthenticationProvider { - - public CustomAuthenticationProvider() { - super(); - } - - // API - - @Override - public Authentication authenticate(final Authentication authentication) throws AuthenticationException { - final String name = authentication.getName(); - final String password = authentication.getCredentials().toString(); - if (name.equals("admin") && password.equals("system")) { - final List grantedAuths = new ArrayList<>(); - grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER")); - final UserDetails principal = new User(name, password, grantedAuths); - final Authentication auth = new UsernamePasswordAuthenticationToken(principal, password, grantedAuths); - return auth; - } else { - return null; - } - } - - @Override - public boolean supports(final Class authentication) { - return authentication.equals(UsernamePasswordAuthenticationToken.class); - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java b/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java deleted file mode 100644 index d1223e41cf3a..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/security/IAuthenticationFacade.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.baeldung.security; - -import org.springframework.security.core.Authentication; - -public interface IAuthenticationFacade { - - Authentication getAuthentication(); - -} \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java index ff5a00fd9509..b50edb2dcf2f 100644 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java @@ -3,6 +3,7 @@ import org.baeldung.web.dto.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,7 +11,7 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller -@RequestMapping(value = "/foo") +@RequestMapping(value = "/foos") public class FooController { @Autowired @@ -24,6 +25,7 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody + @PreAuthorize("hasRole('ROLE_USER')") public Foo findOne(@PathVariable("id") final Long id) { return new Foo(); } diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java deleted file mode 100644 index d06f15af93e0..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController1.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.security.authentication.AnonymousAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SecurityController1 { - - @Autowired - private ApplicationEventPublisher eventPublisher; - - public SecurityController1() { - super(); - } - - // API - - @RequestMapping(value = "/username1", method = RequestMethod.GET) - @ResponseBody - public String currentUserName() { - final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (!(authentication instanceof AnonymousAuthenticationToken)) { - final String currentPrincipalName = authentication.getName(); - System.out.println("Authentication: " + authentication); - System.out.println("Principal: " + authentication.getPrincipal()); - return currentPrincipalName; - } - - return null; - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java deleted file mode 100644 index ac02738d0cd2..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController2.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.baeldung.web.controller; - -import java.security.Principal; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SecurityController2 { - - public SecurityController2() { - super(); - } - - // API - - @RequestMapping(value = "/username2", method = RequestMethod.GET) - @ResponseBody - public String currentUserNameSimple(final Principal principal) { - return principal.getName(); - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java deleted file mode 100644 index fb207b43ddf3..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController3.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SecurityController3 { - - public SecurityController3() { - super(); - } - - // API - - @RequestMapping(value = "/username3", method = RequestMethod.GET) - @ResponseBody - public String currentUserNameSimple(final Authentication authentication) { - UserDetails userDetails = (UserDetails) authentication.getPrincipal(); - System.out.println("Retrieved user with authorities: " + userDetails.getAuthorities()); - return authentication.getName(); - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java deleted file mode 100644 index 0434cc5fdc49..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController4.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.web.controller; - -import java.security.Principal; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SecurityController4 { - - public SecurityController4() { - super(); - } - - // API - - @RequestMapping(value = "/username4", method = RequestMethod.GET) - @ResponseBody - public String currentUserNameSimple(final HttpServletRequest request) { - final Principal principal = request.getUserPrincipal(); - return principal.getName(); - } - -} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java deleted file mode 100644 index e1a0c35cc691..000000000000 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/SecurityController5.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.baeldung.web.controller; - -import org.baeldung.security.IAuthenticationFacade; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.Authentication; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SecurityController5 { - - @Autowired - private IAuthenticationFacade authenticationFacade; - - public SecurityController5() { - super(); - } - - // API - - @RequestMapping(value = "/username5", method = RequestMethod.GET) - @ResponseBody - public String currentUserNameSimple() { - final Authentication authentication = authenticationFacade.getAuthentication(); - return authentication.getName(); - } - -} diff --git a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml index 3766574f346b..14b432aaef0b 100644 --- a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml @@ -8,13 +8,17 @@ - + - + + + + + \ No newline at end of file diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java index be215bf959c4..c880ddc854eb 100644 --- a/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -1,9 +1,16 @@ package org.baeldung.client; -import org.baeldung.spring.ClientConfig; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.impl.client.DefaultHttpClient; +import org.baeldung.client.spring.ClientConfig; +import org.baeldung.web.dto.Foo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -20,7 +27,12 @@ public class ClientLiveTest { @Test public final void whenSecuredRestApiIsConsumed_then200OK() { - System.out.println(); + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); + httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + + final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-template/api/foos/1", HttpMethod.GET, null, Foo.class); + System.out.println(responseEntity.getStatusCode()); } } From ad6923017d3d2b09817697f222143648d20876ee Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 01:05:45 +0300 Subject: [PATCH 202/796] doc work --- spring-security-rest-template/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-template/README.md b/spring-security-rest-template/README.md index 3ec8cf92c71a..038b71615fae 100644 --- a/spring-security-rest-template/README.md +++ b/spring-security-rest-template/README.md @@ -1,7 +1,7 @@ ========= -## Spring Security for REST Example Project +## Spring Security with RestTemplate - Example Project ### Relevant Articles: -- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) +- [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) From a71bba8654a2e313f64d7f6d6bcf86be85a1ac99 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 16:42:47 +0300 Subject: [PATCH 203/796] minor maven cleanup --- spring-security-rest-template/pom.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-template/pom.xml index 768b791119d5..f657b318b1c1 100644 --- a/spring-security-rest-template/pom.xml +++ b/spring-security-rest-template/pom.xml @@ -202,7 +202,7 @@ ${maven-surefire-plugin.version} - + **/*LiveTest.java @@ -264,9 +264,6 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 - 1.8.1 1.8.9 From 7d17c4dd9d556ea1bbec5ae3f04a5ecdd1e4bd59 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 18:25:32 +0300 Subject: [PATCH 204/796] http work --- .../baeldung/client/RestTemplateFactory.java | 20 +++++++++- .../baeldung/client/RawClientLiveTest.java | 40 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java index 3401d14d852a..e8df87524c89 100644 --- a/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -1,6 +1,9 @@ package org.baeldung.client; import org.apache.http.HttpHost; +import org.apache.http.client.HttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; @@ -34,7 +37,22 @@ public boolean isSingleton() { @Override public void afterPropertiesSet() { final HttpHost host = new HttpHost("localhost", 8080, "http"); - restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactoryBasicAuth(host)); + final HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); + restTemplate = new RestTemplate(requestFactory); + + final int timeout = 5; + final HttpClient httpClient = requestFactory.getHttpClient(); + // - note: timeout via raw String parameters + // httpClient.getParams().setParameter("http.connection.timeout", timeout * 1000); + // httpClient.getParams().setParameter("http.socket.timeout", timeout * 1000); + + // httpClient.getParams().setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); + // httpClient.getParams().setParameter("http.protocol.head-body-timeout", timeout * 1000); + + // - note: timeout via the API + final HttpParams httpParams = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout } } \ No newline at end of file diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java new file mode 100644 index 000000000000..a66be953b98e --- /dev/null +++ b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -0,0 +1,40 @@ +package org.baeldung.client; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.baeldung.client.spring.ClientConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.web.client.RestTemplate; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) +public class RawClientLiveTest { + + @Autowired + private RestTemplate restTemplate; + + // tests + + @Test + public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); + httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + + final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1")); + final int statusCode = response.getStatusLine().getStatusCode(); + System.out.println(statusCode); + } +} From a830caca39dedbc738a7dbac37ba9c36bc9339a5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Jul 2013 19:05:28 +0300 Subject: [PATCH 205/796] timeout work --- spring-security-rest-template/pom.xml | 565 +++++++++--------- .../web/controller/FooController.java | 6 + .../src/main/resources/logback.xml | 2 + .../baeldung/client/RawClientLiveTest.java | 29 +- 4 files changed, 317 insertions(+), 285 deletions(-) diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-template/pom.xml index f657b318b1c1..2176778c975d 100644 --- a/spring-security-rest-template/pom.xml +++ b/spring-security-rest-template/pom.xml @@ -1,275 +1,294 @@ - - 4.0.0 - org.baeldung - spring-security-rest-template - 0.1-SNAPSHOT - - spring-security-rest-template - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - commons-logging - commons-logging - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-template - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.3.Final - 5.1.25 - - - 4.2.4 - 4.2.5 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 1.8.1 - 1.8.9 - - - 1.4.3 - 2.15 - + + 4.0.0 + org.baeldung + spring-security-rest-template + 0.1-SNAPSHOT + + spring-security-rest-template + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + + + + + + + + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-template + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*LiveTest.java + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.25 + + + 4.2.4 + 4.2.5 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java index b50edb2dcf2f..9b74c79ca804 100644 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java @@ -30,4 +30,10 @@ public Foo findOne(@PathVariable("id") final Long id) { return new Foo(); } + @RequestMapping(value = "/{id}/unsecured", method = RequestMethod.GET) + @ResponseBody + public Foo findOneUnsecured(@PathVariable("id") final Long id) { + return new Foo(); + } + } diff --git a/spring-security-rest-template/src/main/resources/logback.xml b/spring-security-rest-template/src/main/resources/logback.xml index 1146dade632e..90f61a95bc55 100644 --- a/spring-security-rest-template/src/main/resources/logback.xml +++ b/spring-security-rest-template/src/main/resources/logback.xml @@ -7,6 +7,8 @@ + + diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java index a66be953b98e..76668ab41c2b 100644 --- a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -3,38 +3,43 @@ import java.io.IOException; import org.apache.http.HttpResponse; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; import org.baeldung.client.spring.ClientConfig; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.web.client.RestTemplate; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) public class RawClientLiveTest { - @Autowired - private RestTemplate restTemplate; - // tests @Test public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { - final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); - final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); - httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + final DefaultHttpClient httpClient = new DefaultHttpClient(); + + final int timeout = 5; // seconds + final HttpParams httpParams = httpClient.getParams(); + // - note: timeout via raw String parameters + // httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); + // httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); + // httpParams.setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); + // httpParams.setParameter("http.protocol.head-body-timeout", timeout * 1000); - final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1")); + // - note: timeout via the API + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + + final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1/unsecured")); final int statusCode = response.getStatusLine().getStatusCode(); System.out.println(statusCode); } + } From 1e7f8dc2b0ddd51afcfb5c5e077cbad2e82d52d1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 01:10:43 +0300 Subject: [PATCH 206/796] http client configuration work --- spring-security-rest-template/pom.xml | 608 +++++++++--------- .../web/controller/BarController.java | 31 + .../web/controller/FooController.java | 6 - .../main/java/org/baeldung/web/dto/Bar.java | 14 + .../src/main/resources/webSecurityConfig.xml | 3 +- .../baeldung/client/RawClientLiveTest.java | 44 +- 6 files changed, 396 insertions(+), 310 deletions(-) create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java create mode 100644 spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-template/pom.xml index 2176778c975d..b35dca5ec9ea 100644 --- a/spring-security-rest-template/pom.xml +++ b/spring-security-rest-template/pom.xml @@ -1,294 +1,318 @@ - - 4.0.0 - org.baeldung - spring-security-rest-template - 0.1-SNAPSHOT - - spring-security-rest-template - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - - - - - - - - - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - commons-logging - commons-logging - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-template - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.3.RELEASE - 3.1.4.RELEASE - - - 4.2.3.Final - 5.1.25 - - - 4.2.4 - 4.2.5 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 1.8.1 - 1.8.9 - - - 1.4.3 - 2.15 - + + 4.0.0 + org.baeldung + spring-security-rest-template + 0.1-SNAPSHOT + + spring-security-rest-template + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + + + + + + + + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-template + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*LiveTest.java + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.25 + + + 4.2.4 + 4.2.5 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + \ No newline at end of file diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java new file mode 100644 index 000000000000..2bc314baa22f --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java @@ -0,0 +1,31 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Bar; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/bars") +public class BarController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public BarController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Bar findOne(@PathVariable("id") final Long id) { + return new Bar(); + } + +} diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java index 9b74c79ca804..b50edb2dcf2f 100644 --- a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java @@ -30,10 +30,4 @@ public Foo findOne(@PathVariable("id") final Long id) { return new Foo(); } - @RequestMapping(value = "/{id}/unsecured", method = RequestMethod.GET) - @ResponseBody - public Foo findOneUnsecured(@PathVariable("id") final Long id) { - return new Foo(); - } - } diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java b/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java new file mode 100644 index 000000000000..d33e39a8233d --- /dev/null +++ b/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Bar implements Serializable { + + public Bar() { + super(); + } + +} diff --git a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml index 14b432aaef0b..fa64cf242ade 100644 --- a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml @@ -7,7 +7,6 @@ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - @@ -21,4 +20,6 @@ + + \ No newline at end of file diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java index 76668ab41c2b..f849eda492f3 100644 --- a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -1,11 +1,15 @@ package org.baeldung.client; import java.io.IOException; +import java.util.Timer; +import java.util.TimerTask; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.params.ClientPNames; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.baeldung.client.spring.ClientConfig; @@ -25,21 +29,39 @@ public class RawClientLiveTest { public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { final DefaultHttpClient httpClient = new DefaultHttpClient(); - final int timeout = 5; // seconds + final int timeout = 20; // seconds final HttpParams httpParams = httpClient.getParams(); - // - note: timeout via raw String parameters - // httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); - // httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); - // httpParams.setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); - // httpParams.setParameter("http.protocol.head-body-timeout", timeout * 1000); + configureViaRawApi(timeout, httpParams); + // configureViaHighLevelApi(timeout, httpParams); - // - note: timeout via the API + final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-template/api/bars/1"); + + final int hardTimeout = 5; // seconds + final TimerTask task = new TimerTask() { + @Override + public void run() { + if (getMethod != null) { + getMethod.abort(); + } + } + }; + new Timer(true).schedule(task, hardTimeout * 1000); + + final HttpResponse response = httpClient.execute(getMethod); + System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode()); + } + + // util + + final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) { HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout - - final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1/unsecured")); - final int statusCode = response.getStatusLine().getStatusCode(); - System.out.println(statusCode); + httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); } + final void configureViaRawApi(final int timeout, final HttpParams httpParams) { + httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); + httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); + httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); + } } From 3d729427356089bf21dad52f41b54ad48eb4679b Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:27:15 +0300 Subject: [PATCH 207/796] maven work and initial new project --- spring-mvc-no-xml/.classpath | 37 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-mvc-no-xml/.gitignore | 13 ++ spring-mvc-no-xml/.project | 43 ++++++ spring-mvc-no-xml/.project~ | 60 +++++++++ spring-mvc-no-xml/.settings/.jsdtscope | 12 ++ .../.settings/org.eclipse.jdt.core.prefs | 91 +++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-mvc-no-xml/.springBeans | 14 ++ spring-mvc-no-xml/README.md | 7 + spring-mvc-no-xml/pom.xml | 126 ++++++++++++++++++ .../spring/web/config/ClientWebConfig.java | 39 ++++++ .../src/main/resources/logback.xml | 20 +++ .../src/main/resources/webSecurityConfig.xml | 36 +++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 36 +++++ .../src/test/resources/.gitignore | 13 ++ spring-mvc-xml/pom.xml | 24 +--- 27 files changed, 666 insertions(+), 20 deletions(-) create mode 100644 spring-mvc-no-xml/.classpath create mode 100644 spring-mvc-no-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-mvc-no-xml/.gitignore create mode 100644 spring-mvc-no-xml/.project create mode 100644 spring-mvc-no-xml/.project~ create mode 100644 spring-mvc-no-xml/.settings/.jsdtscope create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.common.component create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-mvc-no-xml/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-mvc-no-xml/.springBeans create mode 100644 spring-mvc-no-xml/README.md create mode 100644 spring-mvc-no-xml/pom.xml create mode 100644 spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java create mode 100644 spring-mvc-no-xml/src/main/resources/logback.xml create mode 100644 spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml create mode 100644 spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc-no-xml/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-mvc-no-xml/src/test/resources/.gitignore diff --git a/spring-mvc-no-xml/.classpath b/spring-mvc-no-xml/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/spring-mvc-no-xml/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc-no-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-mvc-no-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-mvc-no-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-mvc-no-xml/.gitignore b/spring-mvc-no-xml/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc-no-xml/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-no-xml/.project b/spring-mvc-no-xml/.project new file mode 100644 index 000000000000..9e6d8019900a --- /dev/null +++ b/spring-mvc-no-xml/.project @@ -0,0 +1,43 @@ + + + spring-mvc-no-xml + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-mvc-no-xml/.project~ b/spring-mvc-no-xml/.project~ new file mode 100644 index 000000000000..90b8ccd78f8f --- /dev/null +++ b/spring-mvc-no-xml/.project~ @@ -0,0 +1,60 @@ + + + spring-mvc + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.zeroturnaround.eclipse.rebelXmlBuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + org.zeroturnaround.eclipse.jrebelNature + + diff --git a/spring-mvc-no-xml/.settings/.jsdtscope b/spring-mvc-no-xml/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/spring-mvc-no-xml/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-mvc-no-xml/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-no-xml/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0924ed68cff2 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,91 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc-no-xml/.settings/org.eclipse.jdt.ui.prefs b/spring-mvc-no-xml/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-mvc-no-xml/.settings/org.eclipse.m2e.core.prefs b/spring-mvc-no-xml/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-mvc-no-xml/.settings/org.eclipse.m2e.wtp.prefs b/spring-mvc-no-xml/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9784ac36ee68 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-mvc-no-xml/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-mvc-no-xml/.springBeans b/spring-mvc-no-xml/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-mvc-no-xml/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-mvc-no-xml/README.md b/spring-mvc-no-xml/README.md new file mode 100644 index 000000000000..d2872a778236 --- /dev/null +++ b/spring-mvc-no-xml/README.md @@ -0,0 +1,7 @@ +========= + +## Spring MVC with XML Configuration Example Project + + +### Relevant Articles: +- \ No newline at end of file diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml new file mode 100644 index 000000000000..34a644ef11c1 --- /dev/null +++ b/spring-mvc-no-xml/pom.xml @@ -0,0 +1,126 @@ + + 4.0.0 + org.baeldung + 0.1-SNAPSHOT + spring-mvc-no-xml + + spring-mvc-no-xml + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + + + + + + 3.2.3.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + + + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 000000000000..2758a707e6bc --- /dev/null +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + public ClientWebConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/resources/logback.xml b/spring-mvc-no-xml/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-mvc-no-xml/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..5569cc69508a --- /dev/null +++ b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc-no-xml/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..d1256535ab4a --- /dev/null +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + + Spring MVC Application + + + + contextConfigLocation + /WEB-INF/mvc-servlet.xml + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + index.html + + + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/test/resources/.gitignore b/spring-mvc-no-xml/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-mvc-no-xml/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 3fd260b79a58..03e0282f33af 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -83,6 +83,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${maven-surefire-plugin.version} @@ -93,26 +94,6 @@ - - org.codehaus.cargo - cargo-maven2-plugin - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - @@ -136,6 +117,9 @@ 1.8.1 1.8.9 + + 1.4.3 + 2.15 spring-mvc-xml From 8641b957827e23237d390f8033601834d3443ec8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:29:11 +0300 Subject: [PATCH 208/796] minor cleanup --- .../FooServicePersistenceIntegrationTest.java | 1 - spring-mvc-no-xml/.project~ | 60 ------------------- spring-mvc-xml/pom.xml | 4 +- 3 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 spring-mvc-no-xml/.project~ diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index e6c9d8ff1828..da40949cf3d1 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -3,7 +3,6 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.FooService; import org.baeldung.spring.PersistenceJPAConfig; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-mvc-no-xml/.project~ b/spring-mvc-no-xml/.project~ deleted file mode 100644 index 90b8ccd78f8f..000000000000 --- a/spring-mvc-no-xml/.project~ +++ /dev/null @@ -1,60 +0,0 @@ - - - spring-mvc - - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature - - diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 03e0282f33af..26d421ca44cc 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -3,6 +3,7 @@ 4.0.0 org.baeldung 0.1-SNAPSHOT + spring-mvc-xml spring-mvc-xml war @@ -100,7 +101,7 @@ - 3.2.2.RELEASE + 3.2.3.RELEASE 1.7.5 @@ -122,5 +123,4 @@ 2.15 - spring-mvc-xml
\ No newline at end of file From 9db9f19673d038d9ce1e3472c1163a9ef153c81d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:30:58 +0300 Subject: [PATCH 209/796] cleanup of project artifacts --- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/.settings/org.eclipse.wst.common.component | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component index 9784ac36ee68..a37385bf84ed 100644 --- a/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 34a644ef11c1..28ffe6367000 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -71,7 +71,7 @@ - spring-mvc + spring-mvc-no-xml src/main/resources diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-xml/.settings/org.eclipse.wst.common.component index 9784ac36ee68..4d41b2e1b495 100644 --- a/spring-mvc-xml/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-xml/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + From 819fb33d2a087824b71fc6c868286c64c4bbe401 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:34:51 +0300 Subject: [PATCH 210/796] minor cleanup --- .../spring/web/config/ClientWebConfig.java | 34 +++++++++---------- .../spring/web/config/ClientWebConfig.java | 34 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2758a707e6bc..945c1794fba9 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -13,27 +13,27 @@ @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + registry.addViewController("/sample.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 2758a707e6bc..945c1794fba9 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -13,27 +13,27 @@ @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } + registry.addViewController("/sample.html"); + } - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); - return bean; - } + return bean; + } } \ No newline at end of file From e9e91d801937651cc41f22c749f9bb5597a1867c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:38:44 +0300 Subject: [PATCH 211/796] MVC work --- .../{web/config => }/ClientWebConfig.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 10 ++- .../src/main/webapp/WEB-INF/web.xml | 82 ++++++++++--------- 3 files changed, 51 insertions(+), 43 deletions(-) rename spring-mvc-no-xml/src/main/java/org/baeldung/spring/{web/config => }/ClientWebConfig.java (96%) diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java similarity index 96% rename from spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-mvc-no-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java index 945c1794fba9..eaefb0984b77 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml index d1256535ab4a..ebd3eaeb60bf 100644 --- a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml @@ -6,12 +6,18 @@ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC No XML Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + contextConfigLocation - /WEB-INF/mvc-servlet.xml + org.baeldung.spring diff --git a/spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml index c8d785a29842..6ea098864983 100644 --- a/spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-login/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,52 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file From c3ef5ed5e4ddfcf8bde1ec3d2d6efe0073a9e2fc Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:40:11 +0300 Subject: [PATCH 212/796] MVC work --- spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml | 2 ++ .../spring/{web/config => }/ClientWebConfig.java | 2 +- spring-mvc-xml/src/main/webapp/WEB-INF/web.xml | 14 +++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) rename spring-mvc-xml/src/main/java/org/baeldung/spring/{web/config => }/ClientWebConfig.java (96%) diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml index ebd3eaeb60bf..bb6d3ce59951 100644 --- a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml @@ -35,6 +35,8 @@ / + + index.html diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java similarity index 96% rename from spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java rename to spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java index 945c1794fba9..eaefb0984b77 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index d1256535ab4a..6a81621c4bbd 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -6,18 +6,24 @@ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC XML Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + contextConfigLocation - /WEB-INF/mvc-servlet.xml + org.baeldung.spring org.springframework.web.context.ContextLoaderListener - + mvc @@ -29,6 +35,8 @@ / + + index.html From 813295c4d17fa25e93fc68dd82850db65596ed4d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 11:55:43 +0300 Subject: [PATCH 213/796] initial work on replacing the web.xml --- .../java/org/baeldung/servlet/NewWebApp.java | 40 +++++++++++++++++++ .../java/org/baeldung/servlet/WebApp.java | 31 ++++++++++++++ .../webapp/WEB-INF/{web.xml => web_old.xml} | 0 3 files changed, 71 insertions(+) create mode 100644 spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java create mode 100644 spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java rename spring-mvc-no-xml/src/main/webapp/WEB-INF/{web.xml => web_old.xml} (100%) diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java new file mode 100644 index 000000000000..a0181aedaa27 --- /dev/null +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java @@ -0,0 +1,40 @@ +package org.baeldung.servlet; + +// +//public class NewWebApp extends AbstractAnnotationConfigDispatcherServletInitializer { +// +// public NewWebApp() { +// super(); +// } +// +// // API +// +// @Override +// public void onStartup(final ServletContext servletContext) throws ServletException { +// final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); +// root.setServletContext(servletContext); +// root.scan("org.baeldung.spring"); +// root.refresh(); +// +// final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root)); +// servlet.setLoadOnStartup(1); +// servlet.addMapping("/*"); +// } +// +// @Override +// protected Class[] getRootConfigClasses() { +// return null; +// } +// +// @Override +// protected Class[] getServletConfigClasses() { +// return new Class[] { ClientWebConfig.class }; +// } +// +// @Override +// protected String[] getServletMappings() { +// return new String[] { "/*" }; +// } +// +//} + diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java new file mode 100644 index 000000000000..583d083c1cb4 --- /dev/null +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java @@ -0,0 +1,31 @@ +package org.baeldung.servlet; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration.Dynamic; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class WebApp implements WebApplicationInitializer { + + public WebApp() { + super(); + } + + // API + + @Override + public void onStartup(final ServletContext servletContext) throws ServletException { + final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.setServletContext(servletContext); + root.scan("org.baeldung.spring"); + root.refresh(); + + final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root)); + servlet.setLoadOnStartup(1); + servlet.addMapping("/"); + } + +} diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/web_old.xml similarity index 100% rename from spring-mvc-no-xml/src/main/webapp/WEB-INF/web.xml rename to spring-mvc-no-xml/src/main/webapp/WEB-INF/web_old.xml From abb54b915c6305e7229044329171240b0fa8469c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:00:19 +0300 Subject: [PATCH 214/796] no xml support --- .../java/org/baeldung/servlet/WebApp.java | 31 ------------------- .../java/org/baeldung/servlet/WebAppNew.java | 29 +++++++++++++++++ .../{NewWebApp.java => WebAppOld.java} | 26 +++------------- 3 files changed, 34 insertions(+), 52 deletions(-) delete mode 100644 spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java create mode 100644 spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java rename spring-mvc-no-xml/src/main/java/org/baeldung/servlet/{NewWebApp.java => WebAppOld.java} (52%) diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java deleted file mode 100644 index 583d083c1cb4..000000000000 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebApp.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.servlet; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration.Dynamic; - -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -public class WebApp implements WebApplicationInitializer { - - public WebApp() { - super(); - } - - // API - - @Override - public void onStartup(final ServletContext servletContext) throws ServletException { - final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.setServletContext(servletContext); - root.scan("org.baeldung.spring"); - root.refresh(); - - final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root)); - servlet.setLoadOnStartup(1); - servlet.addMapping("/"); - } - -} diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java new file mode 100644 index 000000000000..81a74b56163e --- /dev/null +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java @@ -0,0 +1,29 @@ +package org.baeldung.servlet; + +import org.baeldung.spring.ClientWebConfig; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +public class WebAppNew extends AbstractAnnotationConfigDispatcherServletInitializer { + + public WebAppNew() { + super(); + } + + // API + + @Override + protected Class[] getRootConfigClasses() { + return null; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[] { ClientWebConfig.class }; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + +} diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java similarity index 52% rename from spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java rename to spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java index a0181aedaa27..155597e888ba 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/NewWebApp.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java @@ -1,9 +1,9 @@ package org.baeldung.servlet; + +//public class WebApp implements WebApplicationInitializer { // -//public class NewWebApp extends AbstractAnnotationConfigDispatcherServletInitializer { -// -// public NewWebApp() { +// public WebApp() { // super(); // } // @@ -18,23 +18,7 @@ // // final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root)); // servlet.setLoadOnStartup(1); -// servlet.addMapping("/*"); -// } -// -// @Override -// protected Class[] getRootConfigClasses() { -// return null; -// } -// -// @Override -// protected Class[] getServletConfigClasses() { -// return new Class[] { ClientWebConfig.class }; -// } -// -// @Override -// protected String[] getServletMappings() { -// return new String[] { "/*" }; +// servlet.addMapping("/"); // } // -//} - +// } From e1d9737d9f727eb2f48726e52ee2a33bad783bb9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:06:38 +0300 Subject: [PATCH 215/796] project cleanup --- .../src/main/java/org/baeldung/servlet/WebAppNew.java | 6 ++++++ .../org/baeldung/{spring/web => }/config/MvcConfig.java | 4 ++-- .../{spring/web => }/controller/BarController.java | 2 +- .../{spring/web => }/controller/FooController.java | 2 +- spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp | 7 ------- spring-mvc/src/main/webapp/WEB-INF/web.xml | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) rename spring-mvc/src/main/java/org/baeldung/{spring/web => }/config/MvcConfig.java (75%) rename spring-mvc/src/main/java/org/baeldung/{spring/web => }/controller/BarController.java (96%) rename spring-mvc/src/main/java/org/baeldung/{spring/web => }/controller/FooController.java (98%) delete mode 100644 spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java index 81a74b56163e..4779048099bd 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java @@ -3,6 +3,12 @@ import org.baeldung.spring.ClientWebConfig; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; +/** + * Further reading:
+ * - http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-container-config
+ * - http://geowarin.wordpress.com/2013/01/23/complete-example-of-a-spring-mvc-3-2-project/
+ * - http://www.objectpartners.com/2012/01/16/introduction-to-servlet-3-0/
+ */ public class WebAppNew extends AbstractAnnotationConfigDispatcherServletInitializer { public WebAppNew() { diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java b/spring-mvc/src/main/java/org/baeldung/config/MvcConfig.java similarity index 75% rename from spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java rename to spring-mvc/src/main/java/org/baeldung/config/MvcConfig.java index 1325da321df3..18924ad855b1 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/config/MvcConfig.java +++ b/spring-mvc/src/main/java/org/baeldung/config/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.config; +package org.baeldung.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -6,7 +6,7 @@ @EnableWebMvc @Configuration -@ComponentScan({ "org.baeldung.spring.web.controller" }) +@ComponentScan({ "org.baeldung.controller" }) public class MvcConfig { public MvcConfig() { diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java b/spring-mvc/src/main/java/org/baeldung/controller/BarController.java similarity index 96% rename from spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java rename to spring-mvc/src/main/java/org/baeldung/controller/BarController.java index 4c2202791ca1..d85c41086298 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/BarController.java +++ b/spring-mvc/src/main/java/org/baeldung/controller/BarController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.controller; +package org.baeldung.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/controller/FooController.java similarity index 98% rename from spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java rename to spring-mvc/src/main/java/org/baeldung/controller/FooController.java index 32019a4571b7..292f46729abf 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/controller/FooController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.web.controller; +package org.baeldung.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; diff --git a/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/spring-mvc/src/main/webapp/WEB-INF/view/sample.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index 5c163a20ad57..c6d7ff0e9617 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -17,7 +17,7 @@ contextConfigLocation - org.baeldung.spring.web.config + org.baeldung.config From d6f20b1e7d4deeb6c3dcec6ad02cd883d0c59382 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:08:21 +0300 Subject: [PATCH 216/796] project restructure for cleanup purposes --- {spring-mvc => spring-rest}/.classpath | 0 .../org.eclipse.wst.jsdt.core.javascriptValidator.launch | 0 {spring-mvc => spring-rest}/.gitignore | 0 {spring-mvc => spring-rest}/.project | 2 +- {spring-mvc => spring-rest}/.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 {spring-mvc => spring-rest}/.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 {spring-mvc => spring-rest}/.settings/org.eclipse.m2e.wtp.prefs | 0 .../.settings/org.eclipse.wst.common.component | 0 .../.settings/org.eclipse.wst.common.project.facet.core.xml | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.container | 0 .../.settings/org.eclipse.wst.jsdt.ui.superType.name | 0 .../.settings/org.eclipse.wst.validation.prefs | 0 .../.settings/org.eclipse.wst.ws.service.policy.prefs | 0 {spring-mvc => spring-rest}/.springBeans | 0 {spring-mvc => spring-rest}/README.md | 0 {spring-mvc => spring-rest}/pom.xml | 0 .../src/main/java/org/baeldung/config/MvcConfig.java | 0 .../src/main/java/org/baeldung/controller/BarController.java | 0 .../src/main/java/org/baeldung/controller/FooController.java | 0 {spring-mvc => spring-rest}/src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 {spring-mvc => spring-rest}/src/main/webapp/WEB-INF/web.xml | 0 {spring-mvc => spring-rest}/src/test/resources/.gitignore | 0 25 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc => spring-rest}/.classpath (100%) rename {spring-mvc => spring-rest}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-mvc => spring-rest}/.gitignore (100%) rename {spring-mvc => spring-rest}/.project (97%) rename {spring-mvc => spring-rest}/.settings/.jsdtscope (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.common.component (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-mvc => spring-rest}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-mvc => spring-rest}/.springBeans (100%) rename {spring-mvc => spring-rest}/README.md (100%) rename {spring-mvc => spring-rest}/pom.xml (100%) rename {spring-mvc => spring-rest}/src/main/java/org/baeldung/config/MvcConfig.java (100%) rename {spring-mvc => spring-rest}/src/main/java/org/baeldung/controller/BarController.java (100%) rename {spring-mvc => spring-rest}/src/main/java/org/baeldung/controller/FooController.java (100%) rename {spring-mvc => spring-rest}/src/main/resources/logback.xml (100%) rename {spring-mvc => spring-rest}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc => spring-rest}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-mvc => spring-rest}/src/test/resources/.gitignore (100%) diff --git a/spring-mvc/.classpath b/spring-rest/.classpath similarity index 100% rename from spring-mvc/.classpath rename to spring-rest/.classpath diff --git a/spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-mvc/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-rest/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-mvc/.gitignore b/spring-rest/.gitignore similarity index 100% rename from spring-mvc/.gitignore rename to spring-rest/.gitignore diff --git a/spring-mvc/.project b/spring-rest/.project similarity index 97% rename from spring-mvc/.project rename to spring-rest/.project index 47bfed4d2afc..894841d6903f 100644 --- a/spring-mvc/.project +++ b/spring-rest/.project @@ -1,6 +1,6 @@ - spring-mvc + spring-rest diff --git a/spring-mvc/.settings/.jsdtscope b/spring-rest/.settings/.jsdtscope similarity index 100% rename from spring-mvc/.settings/.jsdtscope rename to spring-rest/.settings/.jsdtscope diff --git a/spring-mvc/.settings/org.eclipse.jdt.core.prefs b/spring-rest/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.jdt.core.prefs rename to spring-rest/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-mvc/.settings/org.eclipse.jdt.ui.prefs b/spring-rest/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.jdt.ui.prefs rename to spring-rest/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-mvc/.settings/org.eclipse.m2e.core.prefs b/spring-rest/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.m2e.core.prefs rename to spring-rest/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-mvc/.settings/org.eclipse.m2e.wtp.prefs b/spring-rest/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.m2e.wtp.prefs rename to spring-rest/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-rest/.settings/org.eclipse.wst.common.component similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.common.component rename to spring-rest/.settings/org.eclipse.wst.common.component diff --git a/spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-rest/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-rest/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-rest/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-rest/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-mvc/.settings/org.eclipse.wst.validation.prefs b/spring-rest/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.validation.prefs rename to spring-rest/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-rest/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-mvc/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-rest/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-mvc/.springBeans b/spring-rest/.springBeans similarity index 100% rename from spring-mvc/.springBeans rename to spring-rest/.springBeans diff --git a/spring-mvc/README.md b/spring-rest/README.md similarity index 100% rename from spring-mvc/README.md rename to spring-rest/README.md diff --git a/spring-mvc/pom.xml b/spring-rest/pom.xml similarity index 100% rename from spring-mvc/pom.xml rename to spring-rest/pom.xml diff --git a/spring-mvc/src/main/java/org/baeldung/config/MvcConfig.java b/spring-rest/src/main/java/org/baeldung/config/MvcConfig.java similarity index 100% rename from spring-mvc/src/main/java/org/baeldung/config/MvcConfig.java rename to spring-rest/src/main/java/org/baeldung/config/MvcConfig.java diff --git a/spring-mvc/src/main/java/org/baeldung/controller/BarController.java b/spring-rest/src/main/java/org/baeldung/controller/BarController.java similarity index 100% rename from spring-mvc/src/main/java/org/baeldung/controller/BarController.java rename to spring-rest/src/main/java/org/baeldung/controller/BarController.java diff --git a/spring-mvc/src/main/java/org/baeldung/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/controller/FooController.java similarity index 100% rename from spring-mvc/src/main/java/org/baeldung/controller/FooController.java rename to spring-rest/src/main/java/org/baeldung/controller/FooController.java diff --git a/spring-mvc/src/main/resources/logback.xml b/spring-rest/src/main/resources/logback.xml similarity index 100% rename from spring-mvc/src/main/resources/logback.xml rename to spring-rest/src/main/resources/logback.xml diff --git a/spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-rest/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-rest/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-rest/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-mvc/src/main/webapp/WEB-INF/web.xml rename to spring-rest/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc/src/test/resources/.gitignore b/spring-rest/src/test/resources/.gitignore similarity index 100% rename from spring-mvc/src/test/resources/.gitignore rename to spring-rest/src/test/resources/.gitignore From d3e1fb128101c44a4eb53d9963378fdf3f36f8ed Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:11:39 +0300 Subject: [PATCH 217/796] maven upgrade --- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- spring-jpa/pom.xml | 2 +- spring-mvc-java/pom.xml | 2 +- spring-rest/.settings/org.eclipse.wst.common.component | 6 +++--- spring-rest/README.md | 2 +- spring-rest/pom.xml | 10 +++++----- spring-security-basic-auth/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 2 +- spring-security-mvc-login/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 9dfb42a62309..854e56ba74a6 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -188,7 +188,7 @@ 1.2 - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index ddbbd6ff1988..c6e3848b8ece 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -188,7 +188,7 @@ 1.2 - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index f1846c7350e5..a11aaa5d3162 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -171,7 +171,7 @@ 3.18.0-GA - 4.2.2.Final + 4.2.3.Final 5.1.25 7.0.41 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 1f8ba8d6756a..9f22e8b12005 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -164,7 +164,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 66e6d8f00940..7c3d7e93eece 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -125,7 +125,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-rest/.settings/org.eclipse.wst.common.component b/spring-rest/.settings/org.eclipse.wst.common.component index 9784ac36ee68..8bb4ef127aa6 100644 --- a/spring-rest/.settings/org.eclipse.wst.common.component +++ b/spring-rest/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-rest/README.md b/spring-rest/README.md index 323bf274e055..b979f263ed51 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -1,6 +1,6 @@ ========= -## Spring MVC Example Project +## Spring REST Example Project ### Relevant Articles: diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 7427a45896ce..96a6e57de172 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-mvc + spring-rest 0.1-SNAPSHOT - spring-mvc + spring-rest war @@ -70,7 +70,7 @@ - spring-mvc + spring-rest src/main/resources @@ -125,7 +125,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 @@ -151,7 +151,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 16059e3e7e29..906271916989 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -183,7 +183,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 6c6d4de4e9b7..4f83f8f32876 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -179,7 +179,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 760d8156f384..9357cafda02a 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -183,7 +183,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 73968b027385..dc5aa6ba60ef 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -179,7 +179,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 1cf7dd867e84..f9d3db19782f 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -209,7 +209,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index e6e4c073c39e..14ae9bd4bfec 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -220,7 +220,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 1.3.2.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 1a847975829a..1bf71c0e663d 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -196,7 +196,7 @@ 3.1.4.RELEASE - 4.2.2.Final + 4.2.3.Final 5.1.25 From d367e6b476756496960572f9e34cdd5d02c511c3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:12:47 +0300 Subject: [PATCH 218/796] maven upgrade --- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- spring-hibernate3/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- spring-jpa/pom.xml | 2 +- spring-mvc-java/pom.xml | 2 +- spring-security-basic-auth/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 2 +- spring-security-mvc-login/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 854e56ba74a6..bdb860df18d1 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -214,7 +214,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index c6e3848b8ece..9794ac8ed7d9 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -214,7 +214,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 79280963c1e7..fe1e3e5f697a 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -190,7 +190,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index a11aaa5d3162..86e09ee2405f 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -198,7 +198,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 9f22e8b12005..5509cfc07998 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -190,7 +190,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 7c3d7e93eece..a469078e903d 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -151,7 +151,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 906271916989..bd7bc85cb397 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -209,7 +209,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 4f83f8f32876..ab09d621779e 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -205,7 +205,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 9357cafda02a..29e5734130c1 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -209,7 +209,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index dc5aa6ba60ef..b0310c5e7f50 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -205,7 +205,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index f9d3db19782f..6f046baf7cbe 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -235,7 +235,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 14ae9bd4bfec..206f7a132c2b 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -251,7 +251,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 1bf71c0e663d..56931f7ba64c 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -222,7 +222,7 @@ 1.8.9 - 1.4.2 + 1.4.3 2.15 From 110cbb3c22251481938ab01d4383a9fae04d4080 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:14:08 +0300 Subject: [PATCH 219/796] artifacts renamed according to the goal of the project --- spring-rest/.springBeans | 4 ++-- .../webapp/WEB-INF/{mvc-servlet.xml => api-servlet.xml} | 0 spring-rest/src/main/webapp/WEB-INF/web.xml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename spring-rest/src/main/webapp/WEB-INF/{mvc-servlet.xml => api-servlet.xml} (100%) diff --git a/spring-rest/.springBeans b/spring-rest/.springBeans index 7623a7e88836..a79097f40d30 100644 --- a/spring-rest/.springBeans +++ b/spring-rest/.springBeans @@ -1,13 +1,13 @@ 1 - + - src/main/webapp/WEB-INF/mvc-servlet.xml + src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-rest/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-rest/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-rest/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-rest/src/main/webapp/WEB-INF/web.xml b/spring-rest/src/main/webapp/WEB-INF/web.xml index c6d7ff0e9617..48d4b8fe61af 100644 --- a/spring-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-rest/src/main/webapp/WEB-INF/web.xml @@ -12,8 +12,8 @@ contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + contextConfigLocation @@ -26,12 +26,12 @@ - mvc + api org.springframework.web.servlet.DispatcherServlet 1 - mvc + api / From 4f6e4f3c3cc6c47825c8bdee86780fd04b9f9e4e Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:18:25 +0300 Subject: [PATCH 220/796] minor cleanup --- spring-mvc-xml/.project~ | 60 ---------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 spring-mvc-xml/.project~ diff --git a/spring-mvc-xml/.project~ b/spring-mvc-xml/.project~ deleted file mode 100644 index 90b8ccd78f8f..000000000000 --- a/spring-mvc-xml/.project~ +++ /dev/null @@ -1,60 +0,0 @@ - - - spring-mvc - - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.zeroturnaround.eclipse.rebelXmlBuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - org.zeroturnaround.eclipse.jrebelNature - - From fd416a00a2fe23acd39b0593b0e30592fd8f6b73 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 12:36:54 +0300 Subject: [PATCH 221/796] maven work --- spring-mvc-no-xml/pom.xml | 16 +++++++++++++--- .../java/org/baeldung/servlet/WebAppNew.java | 7 +++++++ spring-mvc-xml/src/main/webapp/WEB-INF/web.xml | 8 ++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 28ffe6367000..248fa398d21c 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -81,6 +81,15 @@ + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + org.apache.maven.plugins maven-surefire-plugin @@ -118,9 +127,10 @@ 1.8.1 1.8.9 - - 1.4.3 - 2.15 + + 1.4.3 + 2.15 + 2.4 \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java index 4779048099bd..2422f2110aba 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppNew.java @@ -1,5 +1,7 @@ package org.baeldung.servlet; +import javax.servlet.ServletRegistration.Dynamic; + import org.baeldung.spring.ClientWebConfig; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @@ -32,4 +34,9 @@ protected String[] getServletMappings() { return new String[] { "/" }; } + @Override + protected void customizeRegistration(final Dynamic registration) { + super.customizeRegistration(registration); + } + } diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index 6a81621c4bbd..055c645e3874 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -23,7 +23,7 @@ org.springframework.web.context.ContextLoaderListener - + mvc @@ -36,7 +36,11 @@ - + + + 10 + + index.html From cae5866cae4e26d83f948ae9d91972cafdc24a32 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 26 Jul 2013 14:16:35 +0300 Subject: [PATCH 222/796] minor cleanup --- spring-mvc-xml/src/main/webapp/WEB-INF/web.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index 055c645e3874..872154064a45 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -36,11 +36,11 @@ - + 10 - + index.html From 0d8cd51f87e32658a33753031a0b4380b9532ac5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 01:33:59 +0300 Subject: [PATCH 223/796] minor doc work --- spring-mvc-no-xml/README.md | 2 +- spring-mvc-xml/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-mvc-no-xml/README.md b/spring-mvc-no-xml/README.md index d2872a778236..5ffe2385b541 100644 --- a/spring-mvc-no-xml/README.md +++ b/spring-mvc-no-xml/README.md @@ -1,6 +1,6 @@ ========= -## Spring MVC with XML Configuration Example Project +## Spring MVC with NO XML Configuration Example Project ### Relevant Articles: diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index d2872a778236..6943393ce333 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: -- \ No newline at end of file +- [Servlet Session Timeout](http://www.baeldung.com/servlet-session-timeout) From 37df9c6cc744cdd5d2f9503f70f9e6a44f79ea1c Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 12:48:05 +0300 Subject: [PATCH 224/796] initial remember me work --- spring-security-mvc-custom/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 4 +- .../src/main/webapp/WEB-INF/view/login.jsp | 4 + .../src/main/webapp/WEB-INF/web.xml | 82 ++++++++++--------- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index ab09d621779e..f41caec94666 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -198,8 +198,8 @@ 4.11 1.9.5 - 4.2.4 4.2.5 + 4.2.4 1.8.1 1.8.9 diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index de7bd9b9818a..318f69822785 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -14,7 +14,9 @@ - + + + diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp index ba8b7748042b..0eb857c62aee 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -15,6 +15,10 @@

+ + + + diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml index c8d785a29842..73216e669f2e 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,56 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Custom Application - - - contextClass - + + 1 + + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file From 93e597f76acc9df0b9ed69a12ada4738ee614706 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 17:03:22 +0300 Subject: [PATCH 225/796] minor remember me work --- .../src/main/resources/webSecurityConfig.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index 318f69822785..186a435cdb99 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -15,7 +15,7 @@ - + From 3bf23594cd55f8fad330d5a2f5787463d3a2c826 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 20:00:37 +0300 Subject: [PATCH 226/796] doc work --- spring-security-mvc-custom/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index a4e96afc2a29..cb5d14883bd3 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -1,6 +1,7 @@ ========= ## Spring Security Login Example Project +- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) ### Relevant Articles: From 9d37cea5b2c71ee820812b6f843ba1e9d44895e0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 23:46:25 +0300 Subject: [PATCH 227/796] doc work --- spring-security-mvc-custom/README.md | 1 + spring-security-rest-template/README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index cb5d14883bd3..ea03f5664efb 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -2,6 +2,7 @@ ## Spring Security Login Example Project - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) +- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) ### Relevant Articles: diff --git a/spring-security-rest-template/README.md b/spring-security-rest-template/README.md index 038b71615fae..9030dffbd741 100644 --- a/spring-security-rest-template/README.md +++ b/spring-security-rest-template/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) +- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) From 33cc1f297a0a390829407a8422161bf022d8ef53 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 1 Aug 2013 23:53:50 +0300 Subject: [PATCH 228/796] session listener initial work --- .../src/main/webapp/WEB-INF/web.xml | 77 ++++++------- .../web/SessionListenerWithMetrics.java | 32 ++++++ .../src/main/webapp/WEB-INF/web.xml | 105 +++++++++--------- 3 files changed, 122 insertions(+), 92 deletions(-) create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index 872154064a45..671813ac90c6 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -1,48 +1,45 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC XML Application + Spring MVC XML Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - - - 10 - - - - index.html - + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + + 10 + + + index.html + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java new file mode 100644 index 000000000000..7119b7023eca --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java @@ -0,0 +1,32 @@ +package org.baeldung.web; + +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +public class SessionListenerWithMetrics implements HttpSessionListener { + + private static int totalActiveSessions; + + public SessionListenerWithMetrics() { + super(); + } + + // API + + public static int getTotalActiveSession() { + return totalActiveSessions; + } + + @Override + public void sessionCreated(final HttpSessionEvent arg0) { + totalActiveSessions++; + System.out.println("sessionCreated - add one session into counter"); + } + + @Override + public void sessionDestroyed(final HttpSessionEvent arg0) { + totalActiveSessions--; + System.out.println("sessionDestroyed - deduct one session from counter"); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml index 73216e669f2e..bf691dc491f1 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml @@ -1,56 +1,57 @@ - - - Spring MVC Custom Application - - - 1 - - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + + Spring MVC Custom Application + + + 1 + + + org.baeldung.web.SessionListenerWithMetrics + + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + \ No newline at end of file From 6a77eb56b0793f5f7cb701a798a62148f06aec5d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 2 Aug 2013 01:15:49 +0300 Subject: [PATCH 229/796] tracking http sessions with metrics --- spring-security-mvc-custom/pom.xml | 8 +++++ .../monitoring/MetricRegistrySingleton.java | 13 +++++++++ .../web/SessionListenerWithMetrics.java | 29 +++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index f41caec94666..6e0391e1dd0b 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -92,6 +92,14 @@ runtime + + + + com.codahale.metrics + metrics-core + 3.0.1 + + diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java new file mode 100644 index 000000000000..8720283f172e --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java @@ -0,0 +1,13 @@ +package org.baeldung.monitoring; + +import com.codahale.metrics.MetricRegistry; + +public final class MetricRegistrySingleton { + + public static final MetricRegistry metrics = new MetricRegistry(); + + private MetricRegistrySingleton() { + throw new AssertionError(); + } + +} diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java index 7119b7023eca..46bf2708f748 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java @@ -1,32 +1,43 @@ package org.baeldung.web; +import java.util.concurrent.atomic.AtomicInteger; + import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; +import org.baeldung.monitoring.MetricRegistrySingleton; + +import com.codahale.metrics.Counter; + public class SessionListenerWithMetrics implements HttpSessionListener { - private static int totalActiveSessions; + private final AtomicInteger activeSessions; + + private final Counter counterOfActiveSessions; public SessionListenerWithMetrics() { super(); + + activeSessions = new AtomicInteger(); + counterOfActiveSessions = MetricRegistrySingleton.metrics.counter("web.sessions.active.count"); } // API - public static int getTotalActiveSession() { - return totalActiveSessions; + public final int getTotalActiveSession() { + return activeSessions.get(); } @Override - public void sessionCreated(final HttpSessionEvent arg0) { - totalActiveSessions++; - System.out.println("sessionCreated - add one session into counter"); + public final void sessionCreated(final HttpSessionEvent event) { + activeSessions.incrementAndGet(); + counterOfActiveSessions.inc(); } @Override - public void sessionDestroyed(final HttpSessionEvent arg0) { - totalActiveSessions--; - System.out.println("sessionDestroyed - deduct one session from counter"); + public final void sessionDestroyed(final HttpSessionEvent event) { + activeSessions.decrementAndGet(); + counterOfActiveSessions.dec(); } } \ No newline at end of file From 17da38213cebcf7a104df4c63463b6f06c02066f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 2 Aug 2013 13:53:46 +0300 Subject: [PATCH 230/796] minor metrics reporting change --- .../baeldung/monitoring/MetricRegistrySingleton.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java index 8720283f172e..ed253305edf1 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java @@ -1,11 +1,23 @@ package org.baeldung.monitoring; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.Slf4jReporter; public final class MetricRegistrySingleton { public static final MetricRegistry metrics = new MetricRegistry(); + static { + Logger logger = LoggerFactory.getLogger("org.baeldung.monitoring"); + final Slf4jReporter reporter = Slf4jReporter.forRegistry(metrics).outputTo(logger).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(); + reporter.start(5, TimeUnit.MINUTES); + } + private MetricRegistrySingleton() { throw new AssertionError(); } From b3c957773f1843b063b4f42b40b02ecf6ac7f81e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 3 Aug 2013 18:01:45 +0300 Subject: [PATCH 231/796] adding new tutorial --- spring-security-rest-digest-auth/.classpath | 37 ++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-rest-digest-auth/.gitignore | 13 + spring-security-rest-digest-auth/.project | 42 +++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 11 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 + .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-rest-digest-auth/.springBeans | 14 + spring-security-rest-digest-auth/README.md | 8 + spring-security-rest-digest-auth/pom.xml | 318 ++++++++++++++++++ ...entsClientHttpRequestFactoryBasicAuth.java | 42 +++ .../baeldung/client/RestTemplateFactory.java | 58 ++++ .../baeldung/client/spring/ClientConfig.java | 16 + ...uestAwareAuthenticationSuccessHandler.java | 48 +++ .../RestAuthenticationEntryPoint.java | 23 ++ .../baeldung/spring/SecSecurityConfig.java | 16 + .../java/org/baeldung/spring/WebConfig.java | 31 ++ .../web/controller/BarController.java | 31 ++ .../web/controller/FooController.java | 33 ++ .../main/java/org/baeldung/web/dto/Bar.java | 14 + .../main/java/org/baeldung/web/dto/Foo.java | 14 + .../src/main/resources/logback.xml | 22 ++ .../src/main/resources/webSecurityConfig.xml | 25 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + .../src/main/webapp/WEB-INF/web.xml | 51 +++ .../org/baeldung/client/ClientLiveTest.java | 38 +++ .../baeldung/client/RawClientLiveTest.java | 67 ++++ .../src/test/resources/.gitignore | 13 + .../src/main/resources/webSecurityConfig.xml | 4 +- 37 files changed, 1184 insertions(+), 2 deletions(-) create mode 100644 spring-security-rest-digest-auth/.classpath create mode 100644 spring-security-rest-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-rest-digest-auth/.gitignore create mode 100644 spring-security-rest-digest-auth/.project create mode 100644 spring-security-rest-digest-auth/.settings/.jsdtscope create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-rest-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-rest-digest-auth/.springBeans create mode 100644 spring-security-rest-digest-auth/README.md create mode 100644 spring-security-rest-digest-auth/pom.xml create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/BarController.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Bar.java create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-rest-digest-auth/src/main/resources/logback.xml create mode 100644 spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 spring-security-rest-digest-auth/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java create mode 100644 spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java create mode 100644 spring-security-rest-digest-auth/src/test/resources/.gitignore diff --git a/spring-security-rest-digest-auth/.classpath b/spring-security-rest-digest-auth/.classpath new file mode 100644 index 000000000000..ca257cf1f962 --- /dev/null +++ b/spring-security-rest-digest-auth/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-rest-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-rest-digest-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-rest-digest-auth/.gitignore b/spring-security-rest-digest-auth/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-digest-auth/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-digest-auth/.project b/spring-security-rest-digest-auth/.project new file mode 100644 index 000000000000..7c286666855c --- /dev/null +++ b/spring-security-rest-digest-auth/.project @@ -0,0 +1,42 @@ + + + spring-security-rest-digest-auth + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-security-rest-digest-auth/.settings/.jsdtscope b/spring-security-rest-digest-auth/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..9e1a61e740ae --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-rest-digest-auth/.springBeans b/spring-security-rest-digest-auth/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/spring-security-rest-digest-auth/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/spring-security-rest-digest-auth/README.md b/spring-security-rest-digest-auth/README.md new file mode 100644 index 000000000000..9030dffbd741 --- /dev/null +++ b/spring-security-rest-digest-auth/README.md @@ -0,0 +1,8 @@ +========= + +## Spring Security with RestTemplate - Example Project + + +### Relevant Articles: +- [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) +- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml new file mode 100644 index 000000000000..8bd8cd765614 --- /dev/null +++ b/spring-security-rest-digest-auth/pom.xml @@ -0,0 +1,318 @@ + + 4.0.0 + org.baeldung + spring-security-rest-digest-auth + 0.1-SNAPSHOT + + spring-security-rest-digest-auth + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + + + + + + + + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-digest-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*LiveTest.java + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.3.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.25 + + + 4.2.4 + 4.2.5 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java new file mode 100644 index 000000000000..5f808413ce8d --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java @@ -0,0 +1,42 @@ +package org.baeldung.client; + +import java.net.URI; + +import org.apache.http.HttpHost; +import org.apache.http.client.AuthCache; +import org.apache.http.client.protocol.ClientContext; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; +import org.springframework.http.HttpMethod; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; + +public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { + HttpHost host; + + public HttpComponentsClientHttpRequestFactoryBasicAuth(final HttpHost host) { + super(); + this.host = host; + } + + // + + @Override + protected HttpContext createHttpContext(final HttpMethod httpMethod, final URI uri) { + return createHttpContext(); + } + + private HttpContext createHttpContext() { + // Create AuthCache instance + final AuthCache authCache = new BasicAuthCache(); + // Generate BASIC scheme object and add it to the local auth cache + final BasicScheme basicAuth = new BasicScheme(); + authCache.put(host, basicAuth); + // Add AuthCache to the execution context + final BasicHttpContext localcontext = new BasicHttpContext(); + localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); + return localcontext; + } + +} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java new file mode 100644 index 000000000000..e8df87524c89 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -0,0 +1,58 @@ +package org.baeldung.client; + +import org.apache.http.HttpHost; +import org.apache.http.client.HttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +@Component +public class RestTemplateFactory implements FactoryBean, InitializingBean { + private RestTemplate restTemplate; + + public RestTemplateFactory() { + super(); + } + + // API + + @Override + public RestTemplate getObject() { + return restTemplate; + } + + @Override + public Class getObjectType() { + return RestTemplate.class; + } + + @Override + public boolean isSingleton() { + return true; + } + + @Override + public void afterPropertiesSet() { + final HttpHost host = new HttpHost("localhost", 8080, "http"); + final HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); + restTemplate = new RestTemplate(requestFactory); + + final int timeout = 5; + final HttpClient httpClient = requestFactory.getHttpClient(); + // - note: timeout via raw String parameters + // httpClient.getParams().setParameter("http.connection.timeout", timeout * 1000); + // httpClient.getParams().setParameter("http.socket.timeout", timeout * 1000); + + // httpClient.getParams().setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); + // httpClient.getParams().setParameter("http.protocol.head-body-timeout", timeout * 1000); + + // - note: timeout via the API + final HttpParams httpParams = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + } + +} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java new file mode 100644 index 000000000000..73e602855c7e --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.client.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.client") +public class ClientConfig { + + public ClientConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..698052fa2b00 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -0,0 +1,48 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; + +public class MySavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + private RequestCache requestCache = new HttpSessionRequestCache(); + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws ServletException, IOException { + final SavedRequest savedRequest = requestCache.getRequest(request, response); + + if (savedRequest == null) { + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + final String targetUrlParameter = getTargetUrlParameter(); + if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { + requestCache.removeRequest(request, response); + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + + clearAuthenticationAttributes(request); + + // Use the DefaultSavedRequest URL + // final String targetUrl = savedRequest.getRedirectUrl(); + // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); + // getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + public void setRequestCache(final RequestCache requestCache) { + this.requestCache = requestCache; + } +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java new file mode 100644 index 000000000000..77aa32ff979e --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java @@ -0,0 +1,23 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +/** + * The Entry Point will not redirect to any sort of Login - it will return the 401 + */ +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } + +} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..8c3d677af601 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,31 @@ +package org.baeldung.spring; + +import java.util.List; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // beans + + @Override + public void configureMessageConverters(final List> converters) { + super.configureMessageConverters(converters); + converters.add(new MappingJackson2HttpMessageConverter()); + } + + // + +} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/BarController.java new file mode 100644 index 000000000000..2bc314baa22f --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/BarController.java @@ -0,0 +1,31 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Bar; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/bars") +public class BarController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public BarController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Bar findOne(@PathVariable("id") final Long id) { + return new Bar(); + } + +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..b50edb2dcf2f --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,33 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/foos") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + @PreAuthorize("hasRole('ROLE_USER')") + public Foo findOne(@PathVariable("id") final Long id) { + return new Foo(); + } + +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Bar.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Bar.java new file mode 100644 index 000000000000..d33e39a8233d --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Bar.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Bar implements Serializable { + + public Bar() { + super(); + } + +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..09c1dac933fe --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-rest-digest-auth/src/main/resources/logback.xml b/spring-security-rest-digest-auth/src/main/resources/logback.xml new file mode 100644 index 000000000000..90f61a95bc55 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/resources/logback.xml @@ -0,0 +1,22 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..e30e9120a16f --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..372688c8d87e --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + Spring Security Custom Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java new file mode 100644 index 000000000000..f63537ae6ba9 --- /dev/null +++ b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -0,0 +1,38 @@ +package org.baeldung.client; + +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.impl.client.DefaultHttpClient; +import org.baeldung.client.spring.ClientConfig; +import org.baeldung.web.dto.Foo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.web.client.RestTemplate; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) +public class ClientLiveTest { + + @Autowired + private RestTemplate restTemplate; + + // tests + + @Test + public final void whenSecuredRestApiIsConsumed_then200OK() { + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); + httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + + final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-digest-auth/api/foos/1", HttpMethod.GET, null, Foo.class); + System.out.println(responseEntity.getStatusCode()); + } + +} diff --git a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java new file mode 100644 index 000000000000..a535c246efdb --- /dev/null +++ b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -0,0 +1,67 @@ +package org.baeldung.client; + +import java.io.IOException; +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.params.ClientPNames; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.CoreConnectionPNames; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.baeldung.client.spring.ClientConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) +public class RawClientLiveTest { + + // tests + + @Test + public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { + final DefaultHttpClient httpClient = new DefaultHttpClient(); + + final int timeout = 20; // seconds + final HttpParams httpParams = httpClient.getParams(); + configureViaRawApi(timeout, httpParams); + // configureViaHighLevelApi(timeout, httpParams); + + final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-digest-auth/api/bars/1"); + + final int hardTimeout = 5; // seconds + final TimerTask task = new TimerTask() { + @Override + public void run() { + if (getMethod != null) { + getMethod.abort(); + } + } + }; + new Timer(true).schedule(task, hardTimeout * 1000); + + final HttpResponse response = httpClient.execute(getMethod); + System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode()); + } + + // util + + final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) { + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); + } + + final void configureViaRawApi(final int timeout, final HttpParams httpParams) { + httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); + httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); + httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); + } +} diff --git a/spring-security-rest-digest-auth/src/test/resources/.gitignore b/spring-security-rest-digest-auth/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-rest-digest-auth/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml index fa64cf242ade..e30e9120a16f 100644 --- a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-template/src/main/resources/webSecurityConfig.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + @@ -21,5 +21,5 @@ - + \ No newline at end of file From 98ad7671b5cf138b8d4f35bf371e2cb10b84a84b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 00:59:50 +0300 Subject: [PATCH 232/796] security work --- spring-security-rest-digest-auth/README.md | 2 -- .../src/main/resources/webSecurityConfig.xml | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spring-security-rest-digest-auth/README.md b/spring-security-rest-digest-auth/README.md index 9030dffbd741..2d44547c77f6 100644 --- a/spring-security-rest-digest-auth/README.md +++ b/spring-security-rest-digest-auth/README.md @@ -4,5 +4,3 @@ ### Relevant Articles: -- [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) -- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index e30e9120a16f..7727d904c9af 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -6,10 +6,19 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + + + + + + + + - + + + From 098c1070d6b2e4640f7923b4e73acaeeee8916be Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 01:03:29 +0300 Subject: [PATCH 233/796] security work --- .../src/main/resources/webSecurityConfig.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 7727d904c9af..55dd9d1edc7d 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -6,13 +6,13 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + - + - + @@ -23,7 +23,7 @@ - + From a7a0328b2df6ed04f924ec4f9d04ec5c54762f67 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 01:07:38 +0300 Subject: [PATCH 234/796] security work --- .../src/main/resources/webSecurityConfig.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 55dd9d1edc7d..ba3b0f901759 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -16,15 +16,14 @@ - - - + + From 2b9f237c9435cce051668aaab0ac3153aad78557 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 13:14:03 +0300 Subject: [PATCH 235/796] security work --- .../ClientPreemptiveDigestAuthentication.java | 70 +++++++++++++++++++ ...tsClientHttpRequestFactoryDigestAuth.java} | 17 +++-- .../baeldung/client/RestTemplateFactory.java | 58 --------------- .../baeldung/client/spring/ClientConfig.java | 39 ++++++++++- .../src/main/resources/webSecurityConfig.xml | 2 +- .../org/baeldung/client/ClientLiveTest.java | 5 +- spring-security-rest-template/README.md | 2 + 7 files changed, 124 insertions(+), 69 deletions(-) create mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/client/ClientPreemptiveDigestAuthentication.java rename spring-security-rest-digest-auth/src/main/java/org/baeldung/client/{HttpComponentsClientHttpRequestFactoryBasicAuth.java => HttpComponentsClientHttpRequestFactoryDigestAuth.java} (61%) delete mode 100644 spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/ClientPreemptiveDigestAuthentication.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/ClientPreemptiveDigestAuthentication.java new file mode 100644 index 000000000000..5887d2dcabc5 --- /dev/null +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/ClientPreemptiveDigestAuthentication.java @@ -0,0 +1,70 @@ +package org.baeldung.client; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.AuthCache; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.ClientContext; +import org.apache.http.impl.auth.DigestScheme; +import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.util.EntityUtils; + +/** + * An example of HttpClient can be customized to authenticate + * preemptively using DIGEST scheme. + * + * Generally, preemptive authentication can be considered less + * secure than a response to an authentication challenge + * and therefore discouraged. + */ +public class ClientPreemptiveDigestAuthentication { + + public static void main(final String[] args) throws Exception { + final HttpHost targetHost = new HttpHost("localhost", 8080, "http"); + + final DefaultHttpClient httpclient = new DefaultHttpClient(); + try { + httpclient.getCredentialsProvider().setCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("user1", "user1Pass")); + + // Create AuthCache instance + final AuthCache authCache = new BasicAuthCache(); + // Generate DIGEST scheme object, initialize it and add it to the local auth cache + final DigestScheme digestAuth = new DigestScheme(); + // Suppose we already know the realm name + digestAuth.overrideParamter("realm", "Custom Realm Name"); + + // digestAuth.overrideParamter("nonce", "whatever"); + authCache.put(targetHost, digestAuth); + + // Add AuthCache to the execution context + final BasicHttpContext localcontext = new BasicHttpContext(); + localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); + + final HttpGet httpget = new HttpGet("http://localhost:8080/spring-security-rest-digest-auth/api/foos/1"); + + System.out.println("executing request: " + httpget.getRequestLine()); + System.out.println("to target: " + targetHost); + + for (int i = 0; i < 3; i++) { + final HttpResponse response = httpclient.execute(targetHost, httpget, localcontext); + final HttpEntity entity = response.getEntity(); + + System.out.println("----------------------------------------"); + System.out.println(response.getStatusLine()); + if (entity != null) { + System.out.println("Response content length: " + entity.getContentLength()); + } + EntityUtils.consume(entity); + } + } finally { + // When HttpClient instance is no longer needed, shut down the connection manager to ensure immediate deallocation of all system resources + httpclient.getConnectionManager().shutdown(); + } + } + +} diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryDigestAuth.java similarity index 61% rename from spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java rename to spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryDigestAuth.java index 5f808413ce8d..d9d89db224be 100644 --- a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryDigestAuth.java @@ -5,17 +5,17 @@ import org.apache.http.HttpHost; import org.apache.http.client.AuthCache; import org.apache.http.client.protocol.ClientContext; -import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.auth.DigestScheme; import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.springframework.http.HttpMethod; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { +public class HttpComponentsClientHttpRequestFactoryDigestAuth extends HttpComponentsClientHttpRequestFactory { HttpHost host; - public HttpComponentsClientHttpRequestFactoryBasicAuth(final HttpHost host) { + public HttpComponentsClientHttpRequestFactoryDigestAuth(final HttpHost host) { super(); this.host = host; } @@ -30,9 +30,14 @@ protected HttpContext createHttpContext(final HttpMethod httpMethod, final URI u private HttpContext createHttpContext() { // Create AuthCache instance final AuthCache authCache = new BasicAuthCache(); - // Generate BASIC scheme object and add it to the local auth cache - final BasicScheme basicAuth = new BasicScheme(); - authCache.put(host, basicAuth); + // Generate DIGEST scheme object, initialize it and add it to the local auth cache + final DigestScheme digestAuth = new DigestScheme(); + // If we already know the realm name + digestAuth.overrideParamter("realm", "Custom Realm Name"); + + // digestAuth.overrideParamter("nonce", "MTM3NTU2OTU4MDAwNzoyYWI5YTQ5MTlhNzc5N2UxMGM5M2Y5M2ViOTc4ZmVhNg=="); + authCache.put(host, digestAuth); + // Add AuthCache to the execution context final BasicHttpContext localcontext = new BasicHttpContext(); localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java deleted file mode 100644 index e8df87524c89..000000000000 --- a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.baeldung.client; - -import org.apache.http.HttpHost; -import org.apache.http.client.HttpClient; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; - -@Component -public class RestTemplateFactory implements FactoryBean, InitializingBean { - private RestTemplate restTemplate; - - public RestTemplateFactory() { - super(); - } - - // API - - @Override - public RestTemplate getObject() { - return restTemplate; - } - - @Override - public Class getObjectType() { - return RestTemplate.class; - } - - @Override - public boolean isSingleton() { - return true; - } - - @Override - public void afterPropertiesSet() { - final HttpHost host = new HttpHost("localhost", 8080, "http"); - final HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); - restTemplate = new RestTemplate(requestFactory); - - final int timeout = 5; - final HttpClient httpClient = requestFactory.getHttpClient(); - // - note: timeout via raw String parameters - // httpClient.getParams().setParameter("http.connection.timeout", timeout * 1000); - // httpClient.getParams().setParameter("http.socket.timeout", timeout * 1000); - - // httpClient.getParams().setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); - // httpClient.getParams().setParameter("http.protocol.head-body-timeout", timeout * 1000); - - // - note: timeout via the API - final HttpParams httpParams = httpClient.getParams(); - HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout - HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout - } - -} \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java index 73e602855c7e..615be8f52498 100644 --- a/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java +++ b/spring-security-rest-digest-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java @@ -1,10 +1,16 @@ package org.baeldung.client.spring; -import org.springframework.context.annotation.ComponentScan; +import org.apache.http.HttpHost; +import org.apache.http.client.HttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.baeldung.client.HttpComponentsClientHttpRequestFactoryDigestAuth; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; @Configuration -@ComponentScan("org.baeldung.client") public class ClientConfig { public ClientConfig() { @@ -13,4 +19,33 @@ public ClientConfig() { // beans + @Bean + public RestTemplate restTemplate() { + final HttpHost host = new HttpHost("localhost", 8080, "http"); + final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactoryDigestAuth(host); + final RestTemplate restTemplate = new RestTemplate(requestFactory); + + final int timeout = 5; + configureTimeouts(requestFactory, timeout); + + return restTemplate; + } + + // util + + private final void configureTimeouts(final HttpComponentsClientHttpRequestFactory requestFactory, final int timeout) { + final HttpClient httpClient = requestFactory.getHttpClient(); + // - note: timeout via raw String parameters + // httpClient.getParams().setParameter("http.connection.timeout", timeout * 1000); + // httpClient.getParams().setParameter("http.socket.timeout", timeout * 1000); + + // httpClient.getParams().setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); + // httpClient.getParams().setParameter("http.protocol.head-body-timeout", timeout * 1000); + + // - note: timeout via the API + final HttpParams httpParams = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + } + } \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index ba3b0f901759..2dbcf84eeeaa 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -11,7 +11,7 @@ - + diff --git a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index f63537ae6ba9..9ab6854f61ff 100644 --- a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -29,9 +29,10 @@ public class ClientLiveTest { public final void whenSecuredRestApiIsConsumed_then200OK() { final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); - httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user1", "user1Pass")); - final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-digest-auth/api/foos/1", HttpMethod.GET, null, Foo.class); + final String uri = "http://localhost:8080/spring-security-rest-digest-auth/api/foos/1"; + final ResponseEntity responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, Foo.class); System.out.println(responseEntity.getStatusCode()); } diff --git a/spring-security-rest-template/README.md b/spring-security-rest-template/README.md index 9030dffbd741..a857ddc778cc 100644 --- a/spring-security-rest-template/README.md +++ b/spring-security-rest-template/README.md @@ -6,3 +6,5 @@ ### Relevant Articles: - [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) - [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) + +TODO: rename to: spring-security-rest-basic-auth \ No newline at end of file From aaf7a64711136945f161659e2119d22848c5325d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 13:16:16 +0300 Subject: [PATCH 236/796] initial rename of template project --- .../.classpath | 0 ...e.wst.jsdt.core.javascriptValidator.launch | 0 .../.gitignore | 0 .../.project | 2 +- .../.settings/.jsdtscope | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 .../.settings/org.eclipse.m2e.wtp.prefs | 0 .../org.eclipse.wst.common.component | 6 +-- ....eclipse.wst.common.project.facet.core.xml | 0 ...rg.eclipse.wst.jsdt.ui.superType.container | 0 .../org.eclipse.wst.jsdt.ui.superType.name | 0 .../org.eclipse.wst.validation.prefs | 0 .../org.eclipse.wst.ws.service.policy.prefs | 0 .../.springBeans | 0 .../README.md | 0 .../pom.xml | 0 ...entsClientHttpRequestFactoryBasicAuth.java | 0 .../baeldung/client/RestTemplateFactory.java | 0 .../baeldung/client/spring/ClientConfig.java | 0 ...uestAwareAuthenticationSuccessHandler.java | 0 .../RestAuthenticationEntryPoint.java | 0 .../baeldung/spring/SecSecurityConfig.java | 0 .../java/org/baeldung/spring/WebConfig.java | 0 .../web/controller/BarController.java | 0 .../web/controller/FooController.java | 0 .../main/java/org/baeldung/web/dto/Bar.java | 0 .../main/java/org/baeldung/web/dto/Foo.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/api-servlet.xml | 0 .../src/main/webapp/WEB-INF/web.xml | 34 +++++++++++++ .../org/baeldung/client/ClientLiveTest.java | 0 .../baeldung/client/RawClientLiveTest.java | 0 .../src/test/resources/.gitignore | 0 .../src/main/webapp/WEB-INF/web.xml | 51 ------------------- 37 files changed, 38 insertions(+), 55 deletions(-) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.classpath (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.gitignore (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.project (96%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/.jsdtscope (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.jdt.core.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.m2e.core.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.m2e.wtp.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.common.component (85%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.common.project.facet.core.xml (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.container (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.jsdt.ui.superType.name (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.validation.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.settings/org.eclipse.wst.ws.service.policy.prefs (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/.springBeans (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/README.md (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/pom.xml (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/client/RestTemplateFactory.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/client/spring/ClientConfig.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/spring/WebConfig.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/web/controller/BarController.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/web/controller/FooController.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/web/dto/Bar.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/java/org/baeldung/web/dto/Foo.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/resources/logback.xml (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/main/webapp/WEB-INF/api-servlet.xml (100%) create mode 100644 spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/test/java/org/baeldung/client/ClientLiveTest.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/test/java/org/baeldung/client/RawClientLiveTest.java (100%) rename {spring-security-rest-template => spring-security-rest-basic-auth}/src/test/resources/.gitignore (100%) delete mode 100644 spring-security-rest-template/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-rest-template/.classpath b/spring-security-rest-basic-auth/.classpath similarity index 100% rename from spring-security-rest-template/.classpath rename to spring-security-rest-basic-auth/.classpath diff --git a/spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-rest-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch similarity index 100% rename from spring-security-rest-template/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch rename to spring-security-rest-basic-auth/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-security-rest-template/.gitignore b/spring-security-rest-basic-auth/.gitignore similarity index 100% rename from spring-security-rest-template/.gitignore rename to spring-security-rest-basic-auth/.gitignore diff --git a/spring-security-rest-template/.project b/spring-security-rest-basic-auth/.project similarity index 96% rename from spring-security-rest-template/.project rename to spring-security-rest-basic-auth/.project index 1e6360f7e2a8..17907f163694 100644 --- a/spring-security-rest-template/.project +++ b/spring-security-rest-basic-auth/.project @@ -1,6 +1,6 @@ - spring-security-rest-template + spring-security-rest-basic-auth diff --git a/spring-security-rest-template/.settings/.jsdtscope b/spring-security-rest-basic-auth/.settings/.jsdtscope similarity index 100% rename from spring-security-rest-template/.settings/.jsdtscope rename to spring-security-rest-basic-auth/.settings/.jsdtscope diff --git a/spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.jdt.core.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.jdt.core.prefs diff --git a/spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.jdt.ui.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.jdt.ui.prefs diff --git a/spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.m2e.core.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.m2e.core.prefs diff --git a/spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.m2e.wtp.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.m2e.wtp.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.m2e.wtp.prefs diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.common.component b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component similarity index 85% rename from spring-security-rest-template/.settings/org.eclipse.wst.common.component rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component index 7092dce0b65f..d7495fe4b086 100644 --- a/spring-security-rest-template/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component @@ -1,11 +1,11 @@ - + - - + + diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.wst.common.project.facet.core.xml rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.wst.validation.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs diff --git a/spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.ws.service.policy.prefs similarity index 100% rename from spring-security-rest-template/.settings/org.eclipse.wst.ws.service.policy.prefs rename to spring-security-rest-basic-auth/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/spring-security-rest-template/.springBeans b/spring-security-rest-basic-auth/.springBeans similarity index 100% rename from spring-security-rest-template/.springBeans rename to spring-security-rest-basic-auth/.springBeans diff --git a/spring-security-rest-template/README.md b/spring-security-rest-basic-auth/README.md similarity index 100% rename from spring-security-rest-template/README.md rename to spring-security-rest-basic-auth/README.md diff --git a/spring-security-rest-template/pom.xml b/spring-security-rest-basic-auth/pom.xml similarity index 100% rename from spring-security-rest-template/pom.xml rename to spring-security-rest-basic-auth/pom.xml diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/client/RestTemplateFactory.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/client/spring/ClientConfig.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/client/spring/ClientConfig.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/client/spring/ClientConfig.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/web/controller/BarController.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/web/controller/BarController.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/web/controller/BarController.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/web/controller/FooController.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/web/controller/FooController.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/web/dto/Bar.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/web/dto/Bar.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/web/dto/Bar.java diff --git a/spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/web/dto/Foo.java similarity index 100% rename from spring-security-rest-template/src/main/java/org/baeldung/web/dto/Foo.java rename to spring-security-rest-basic-auth/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-security-rest-template/src/main/resources/logback.xml b/spring-security-rest-basic-auth/src/main/resources/logback.xml similarity index 100% rename from spring-security-rest-template/src/main/resources/logback.xml rename to spring-security-rest-basic-auth/src/main/resources/logback.xml diff --git a/spring-security-rest-template/src/main/resources/webSecurityConfig.xml b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-rest-template/src/main/resources/webSecurityConfig.xml rename to spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-security-rest-template/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..712c84acdfd5 --- /dev/null +++ b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + Spring Security Custom Application + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + \ No newline at end of file diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java similarity index 100% rename from spring-security-rest-template/src/test/java/org/baeldung/client/ClientLiveTest.java rename to spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java diff --git a/spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java similarity index 100% rename from spring-security-rest-template/src/test/java/org/baeldung/client/RawClientLiveTest.java rename to spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java diff --git a/spring-security-rest-template/src/test/resources/.gitignore b/spring-security-rest-basic-auth/src/test/resources/.gitignore similarity index 100% rename from spring-security-rest-template/src/test/resources/.gitignore rename to spring-security-rest-basic-auth/src/test/resources/.gitignore diff --git a/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 372688c8d87e..000000000000 --- a/spring-security-rest-template/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - Spring Security Custom Application - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - - - - \ No newline at end of file From 7c23ee9dde48d6679878d2bbb47359d00a5a3f68 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 13:18:12 +0300 Subject: [PATCH 237/796] finishing move --- spring-security-rest-basic-auth/pom.xml | 6 +++--- .../src/test/java/org/baeldung/client/ClientLiveTest.java | 2 +- .../test/java/org/baeldung/client/RawClientLiveTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index b35dca5ec9ea..30385ecc6a8f 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-security-rest-template + spring-security-rest-basic-auth 0.1-SNAPSHOT - spring-security-rest-template + spring-security-rest-basic-auth war @@ -217,7 +217,7 @@ - spring-security-rest-template + spring-security-rest-basic-auth src/main/resources diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index c880ddc854eb..922c4f237373 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -31,7 +31,7 @@ public final void whenSecuredRestApiIsConsumed_then200OK() { final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); - final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-template/api/foos/1", HttpMethod.GET, null, Foo.class); + final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1", HttpMethod.GET, null, Foo.class); System.out.println(responseEntity.getStatusCode()); } diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index f849eda492f3..4c0ca44f4572 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -34,7 +34,7 @@ public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocol configureViaRawApi(timeout, httpParams); // configureViaHighLevelApi(timeout, httpParams); - final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-template/api/bars/1"); + final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1"); final int hardTimeout = 5; // seconds final TimerTask task = new TimerTask() { From 1559d22e2f7340677c085e85dc3f0b722c31e710 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 4 Aug 2013 14:06:29 +0300 Subject: [PATCH 238/796] doc work --- spring-security-rest-basic-auth/README.md | 4 +--- spring-security-rest-digest-auth/README.md | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md index a857ddc778cc..221e6de505dc 100644 --- a/spring-security-rest-basic-auth/README.md +++ b/spring-security-rest-basic-auth/README.md @@ -1,10 +1,8 @@ ========= -## Spring Security with RestTemplate - Example Project +## REST API with Basic Authentication - Example Project ### Relevant Articles: - [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) - [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) - -TODO: rename to: spring-security-rest-basic-auth \ No newline at end of file diff --git a/spring-security-rest-digest-auth/README.md b/spring-security-rest-digest-auth/README.md index 2d44547c77f6..06e847edad89 100644 --- a/spring-security-rest-digest-auth/README.md +++ b/spring-security-rest-digest-auth/README.md @@ -1,6 +1,7 @@ ========= -## Spring Security with RestTemplate - Example Project +## REST API with Digest Authentication - Example Project ### Relevant Articles: +- [RestTemplate with Digest Authentication](http://www.baeldung.com/resttemplate-digest-authentication) From 0693cca566f54abc3587fd85b6e72adcd8e40f60 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 8 Aug 2013 23:13:04 +0300 Subject: [PATCH 239/796] minor maven upgrades --- spring-all/pom.xml | 4 ++-- spring-exceptions/pom.xml | 4 ++-- spring-hibernate3/pom.xml | 4 ++-- spring-hibernate4/pom.xml | 4 ++-- spring-jpa/pom.xml | 4 ++-- spring-mvc-java/pom.xml | 4 ++-- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 4 ++-- spring-security-basic-auth/pom.xml | 4 ++-- spring-security-mvc-custom/pom.xml | 4 ++-- spring-security-mvc-digest-auth/pom.xml | 4 ++-- spring-security-mvc-login/pom.xml | 4 ++-- spring-security-rest-basic-auth/pom.xml | 4 ++-- spring-security-rest-custom/pom.xml | 4 ++-- spring-security-rest-digest-auth/pom.xml | 4 ++-- spring-security-rest-full/pom.xml | 4 ++-- spring-security-rest/pom.xml | 4 ++-- 18 files changed, 34 insertions(+), 34 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index bdb860df18d1..3b04b609e678 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -182,14 +182,14 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 3.18.0-GA 1.2 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 9794ac8ed7d9..ab8272cb02f4 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -182,14 +182,14 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 3.18.0-GA 1.2 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index fe1e3e5f697a..6cd53b23c72d 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -158,13 +158,13 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 3.18.0-GA 3.6.10.Final - 5.1.25 + 5.1.26 7.0.41 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 86e09ee2405f..775abd7bdac1 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -166,13 +166,13 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 3.18.0-GA 4.2.3.Final - 5.1.25 + 5.1.26 7.0.41 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 5509cfc07998..d9109ae593e0 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -160,12 +160,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index a469078e903d..a7fe6a3c5285 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -121,12 +121,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 248fa398d21c..5235eb422e50 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -110,7 +110,7 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 1.7.5 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 26d421ca44cc..4dbe0120ebf7 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -101,7 +101,7 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 1.7.5 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 96a6e57de172..5d55c5ea8a51 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -121,12 +121,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index bd7bc85cb397..616ce4140c22 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -179,12 +179,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 6e0391e1dd0b..7d7588cd1907 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -183,12 +183,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 29e5734130c1..9cb06978f6d3 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -179,12 +179,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index b0310c5e7f50..7504e33c7617 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -175,12 +175,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 30385ecc6a8f..8cf15f656273 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -280,12 +280,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 4.2.4 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 6f046baf7cbe..d0092f861b6d 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -205,12 +205,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 8bd8cd765614..db8a47f86b0f 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -280,12 +280,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 4.2.4 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 206f7a132c2b..1072e76c720a 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -216,12 +216,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.3.2.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 56931f7ba64c..b6962abd24bf 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -192,12 +192,12 @@ - 3.2.3.RELEASE + 3.2.4.RELEASE 3.1.4.RELEASE 4.2.3.Final - 5.1.25 + 5.1.26 1.7.5 From 863f6e4bc85f5c0e68ade40cd5d1f81bb7f4f812 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 9 Aug 2013 11:16:11 +0300 Subject: [PATCH 240/796] new tests for ssl --- .../org/baeldung/client/ClientLiveTest.java | 39 ++++++++++++++ .../baeldung/client/RawClientLiveTest.java | 51 ++++++++++++++++--- 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index 922c4f237373..16a2d6166a61 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -1,7 +1,17 @@ package org.baeldung.client; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.cert.X509Certificate; + import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.DefaultHttpClient; import org.baeldung.client.spring.ClientConfig; import org.baeldung.web.dto.Foo; @@ -14,6 +24,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.RestTemplate; @RunWith(SpringJUnit4ClassRunner.class) @@ -35,4 +46,32 @@ public final void whenSecuredRestApiIsConsumed_then200OK() { System.out.println(responseEntity.getStatusCode()); } + @Test(expected = ResourceAccessException.class) + public final void whenHttpsUrlIsConsumed_thenException() { + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final ResponseEntity response = new RestTemplate().exchange(urlOverHttps, HttpMethod.GET, null, String.class); + assertThat(response.getStatusCode().value(), equalTo(200)); + } + + @Test + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws IOException, GeneralSecurityException { + final RestTemplate newRestTemplate = new RestTemplate(); + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); + + final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { + @Override + public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { + return true; + } + }; + + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); + + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final ResponseEntity response = newRestTemplate.exchange(urlOverHttps, HttpMethod.GET, null, String.class); + assertThat(response.getStatusCode().value(), equalTo(200)); + } + } diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index 4c0ca44f4572..61c782b00a58 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -1,26 +1,32 @@ package org.baeldung.client; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.cert.X509Certificate; import java.util.Timer; import java.util.TimerTask; +import javax.net.ssl.SSLPeerUnverifiedException; + import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.params.ClientPNames; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; -import org.baeldung.client.spring.ClientConfig; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class) public class RawClientLiveTest { // tests @@ -51,6 +57,37 @@ public void run() { System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode()); } + @Test(expected = SSLPeerUnverifiedException.class) + public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolException, IOException { + final DefaultHttpClient httpClient = new DefaultHttpClient(); + + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final HttpGet getMethod = new HttpGet(urlOverHttps); + final HttpResponse response = httpClient.execute(getMethod); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @Test + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws IOException, GeneralSecurityException { + final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { + @Override + public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { + return true; + } + }; + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + final SchemeRegistry registry = new SchemeRegistry(); + registry.register(new Scheme("https", 8443, sf)); + final ClientConnectionManager ccm = new PoolingClientConnectionManager(registry); + + final DefaultHttpClient httpClient = new DefaultHttpClient(ccm); + + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final HttpGet getMethod = new HttpGet(urlOverHttps); + final HttpResponse response = httpClient.execute(getMethod); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + // util final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) { From 211998143ca9bb8afe15bb60c5972d2944983f8e Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 9 Aug 2013 16:08:53 +0300 Subject: [PATCH 241/796] rest template work --- .../test/java/org/baeldung/client/ClientLiveTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index 16a2d6166a61..1218a02045f9 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -32,17 +32,17 @@ public class ClientLiveTest { @Autowired - private RestTemplate restTemplate; + private RestTemplate secureRestTemplate; // tests @Test public final void whenSecuredRestApiIsConsumed_then200OK() { - final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) secureRestTemplate.getRequestFactory(); final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); - final ResponseEntity responseEntity = restTemplate.exchange("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1", HttpMethod.GET, null, Foo.class); + final ResponseEntity responseEntity = secureRestTemplate.exchange("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1", HttpMethod.GET, null, Foo.class); System.out.println(responseEntity.getStatusCode()); } @@ -55,8 +55,8 @@ public final void whenHttpsUrlIsConsumed_thenException() { @Test public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws IOException, GeneralSecurityException { - final RestTemplate newRestTemplate = new RestTemplate(); - final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); + final RestTemplate newRestTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); + final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) newRestTemplate.getRequestFactory(); final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @@ -65,7 +65,6 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String return true; } }; - final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); From 1f5cf7151ee3b9fa7ca680f2ef8dbf8052840320 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 9 Aug 2013 16:37:37 +0300 Subject: [PATCH 242/796] final cleanup for tutorial --- .../test/java/org/baeldung/client/ClientLiveTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index 1218a02045f9..e14fc1403e62 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -1,9 +1,9 @@ package org.baeldung.client; +import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; -import java.io.IOException; import java.security.GeneralSecurityException; import java.security.cert.X509Certificate; @@ -54,9 +54,8 @@ public final void whenHttpsUrlIsConsumed_thenException() { } @Test - public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws IOException, GeneralSecurityException { - final RestTemplate newRestTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); - final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) newRestTemplate.getRequestFactory(); + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { + final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @@ -65,11 +64,11 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String return true; } }; - final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER); httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; - final ResponseEntity response = newRestTemplate.exchange(urlOverHttps, HttpMethod.GET, null, String.class); + final ResponseEntity response = new RestTemplate(requestFactory).exchange(urlOverHttps, HttpMethod.GET, null, String.class); assertThat(response.getStatusCode().value(), equalTo(200)); } From 1157dc6b58d1cb04bf7262b3ab1ded5a6e61ab47 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 01:27:27 +0300 Subject: [PATCH 243/796] doc work, new example for expanding shortened urls --- spring-security-rest-basic-auth/README.md | 1 + spring-security-rest-custom/.classpath | 1 + .../org.eclipse.wst.common.component | 1 + spring-security-rest-custom/pom.xml | 505 +++++++++--------- .../baeldung/live/HttpLiveServiceTemp.java | 102 ++++ spring-security-rest-digest-auth/pom.xml | 12 - 6 files changed, 370 insertions(+), 252 deletions(-) create mode 100644 spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md index 221e6de505dc..723bcebbddbe 100644 --- a/spring-security-rest-basic-auth/README.md +++ b/spring-security-rest-basic-auth/README.md @@ -6,3 +6,4 @@ ### Relevant Articles: - [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) - [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) +- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) diff --git a/spring-security-rest-custom/.classpath b/spring-security-rest-custom/.classpath index 5dea19367768..5b66010de692 100644 --- a/spring-security-rest-custom/.classpath +++ b/spring-security-rest-custom/.classpath @@ -16,6 +16,7 @@ + diff --git a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component index 3b22cb60bb1f..4bf6e222f354 100644 --- a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component @@ -4,6 +4,7 @@ + diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index d0092f861b6d..4e5436523f21 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -1,242 +1,267 @@ - - 4.0.0 - org.baeldung - spring-security-rest-custom - 0.1-SNAPSHOT - - spring-security-rest-custom - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-custom - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.4.RELEASE - 3.1.4.RELEASE - - - 4.2.3.Final - 5.1.26 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.1 - 1.8.9 - - - 1.4.3 - 2.15 - + + 4.0.0 + org.baeldung + spring-security-rest-custom + 0.1-SNAPSHOT + + spring-security-rest-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + com.google.guava + guava + ${guava.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-custom + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + \ No newline at end of file diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java new file mode 100644 index 000000000000..1e1a08088b33 --- /dev/null +++ b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java @@ -0,0 +1,102 @@ +package org.baeldung.live; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.apache.http.util.EntityUtils; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.base.Preconditions; + +public class HttpLiveServiceTemp { + + private DefaultHttpClient client; + + // fixtures + + @Before + public final void before() { + final HttpParams httpParameters = new BasicHttpParams(); + httpParameters.setParameter("http.protocol.handle-redirects", false); + + client = new DefaultHttpClient(httpParameters); + } + + // tests + + @Test + public final void givenShortenedOnce_whenUrlIsUnshortened_thenCorrectResult() throws IOException { + final String expectedResult = "http://www.baeldung.com/rest-versioning"; + final String actualResult = expandSingleLevel("http://bit.ly/13jEoS1"); + assertThat(actualResult, equalTo(expectedResult)); + } + + @Test + public final void givenShortenedMultiple_whenUrlIsUnshortened_thenCorrectResult() throws IOException { + final String expectedResult = "http://www.baeldung.com/rest-versioning"; + final String actualResult = expand("http://t.co/e4rDDbnzmk"); + assertThat(actualResult, equalTo(expectedResult)); + } + + // API + + final String expand(final String urlArg) throws IOException { + String originalUrl = urlArg; + String newUrl = expandSingleLevel(originalUrl); + while (!originalUrl.equals(newUrl)) { + originalUrl = newUrl; + newUrl = expandSingleLevel(originalUrl); + } + + return newUrl; + } + + final String expandSingleLevel(final String url) throws IOException { + HttpGet request = null; + HttpEntity httpEntity = null; + InputStream entityContentStream = null; + + try { + request = new HttpGet(url); + final HttpResponse httpResponse = client.execute(request); + + httpEntity = httpResponse.getEntity(); + entityContentStream = httpEntity.getContent(); + + final int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode != 301 && statusCode != 302) { + return url; + } + final Header[] headers = httpResponse.getHeaders(HttpHeaders.LOCATION); + Preconditions.checkState(headers.length == 1); + final String newUrl = headers[0].getValue(); + + return newUrl; + } catch (final IllegalArgumentException uriEx) { + return url; + } finally { + if (request != null) { + request.releaseConnection(); + } + if (entityContentStream != null) { + entityContentStream.close(); + } + if (httpEntity != null) { + EntityUtils.consume(httpEntity); + } + } + } + +} diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index db8a47f86b0f..5b8cc88dc7ff 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -93,18 +93,6 @@ - - - - - - - - - - - - org.apache.httpcomponents httpcore From cb6ee3684c8e92e0880c96917fb8654e58f21efc Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 01:40:45 +0300 Subject: [PATCH 244/796] testing work --- spring-security-rest-custom/pom.xml | 5 ++ .../baeldung/live/HttpLiveServiceTemp.java | 58 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 4e5436523f21..b3bf977745d6 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -134,6 +134,11 @@ guava ${guava.version} + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java index 1e1a08088b33..03378284b1a9 100644 --- a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java +++ b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java @@ -5,7 +5,10 @@ import java.io.IOException; import java.io.InputStream; +import java.util.List; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; @@ -19,6 +22,7 @@ import org.junit.Test; import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; public class HttpLiveServiceTemp { @@ -63,6 +67,60 @@ final String expand(final String urlArg) throws IOException { return newUrl; } + final String expandSafe(final String urlArg) throws IOException { + String originalUrl = urlArg; + String newUrl = expandSingleLevelSafe(originalUrl).getRight(); + final List alreadyVisited = Lists.newArrayList(originalUrl, newUrl); + while (!originalUrl.equals(newUrl)) { + originalUrl = newUrl; + final Pair statusAndUrl = expandSingleLevelSafe(originalUrl); + newUrl = statusAndUrl.getRight(); + final boolean isRedirect = statusAndUrl.getLeft() == 301 || statusAndUrl.getLeft() == 302; + if (isRedirect && alreadyVisited.contains(newUrl)) { + throw new IllegalStateException("Likely a redirect loop"); + } + alreadyVisited.add(newUrl); + } + + return newUrl; + } + + final Pair expandSingleLevelSafe(final String url) throws IOException { + HttpGet request = null; + HttpEntity httpEntity = null; + InputStream entityContentStream = null; + + try { + request = new HttpGet(url); + final HttpResponse httpResponse = client.execute(request); + + httpEntity = httpResponse.getEntity(); + entityContentStream = httpEntity.getContent(); + + final int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode != 301 && statusCode != 302) { + return new ImmutablePair(statusCode, url); + } + final Header[] headers = httpResponse.getHeaders(HttpHeaders.LOCATION); + Preconditions.checkState(headers.length == 1); + final String newUrl = headers[0].getValue(); + + return new ImmutablePair(statusCode, newUrl); + } catch (final IllegalArgumentException uriEx) { + return new ImmutablePair(500, url); + } finally { + if (request != null) { + request.releaseConnection(); + } + if (entityContentStream != null) { + entityContentStream.close(); + } + if (httpEntity != null) { + EntityUtils.consume(httpEntity); + } + } + } + final String expandSingleLevel(final String url) throws IOException { HttpGet request = null; HttpEntity httpEntity = null; From b575a8debca1f81d6767ccf871655a3a420d761d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 01:43:23 +0300 Subject: [PATCH 245/796] doc work --- spring-security-rest-custom/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index 3ec8cf92c71a..690d80a00980 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) +- [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) From 98890ad2319bfe73a6e2461753a7d65ad5d7b1f2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 13:33:52 +0300 Subject: [PATCH 246/796] separating the session work into it's own example project --- spring-security-mvc-custom/README.md | 5 +- spring-security-mvc-session/.classpath | 31 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + spring-security-mvc-session/.gitignore | 13 ++ spring-security-mvc-session/.project | 42 ++++ .../.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + spring-security-mvc-session/.springBeans | 14 ++ spring-security-mvc-session/README.md | 15 ++ spring-security-mvc-session/pom.xml | 220 ++++++++++++++++++ .../monitoring/MetricRegistrySingleton.java | 25 ++ ...SimpleUrlAuthenticationSuccessHandler.java | 94 ++++++++ .../java/org/baeldung/spring/MvcConfig.java | 43 ++++ .../baeldung/spring/SecSecurityConfig.java | 14 ++ .../web/SessionListenerWithMetrics.java | 43 ++++ .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 33 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../main/webapp/WEB-INF/view/anonymous.jsp | 10 + .../src/main/webapp/WEB-INF/view/console.jsp | 22 ++ .../src/main/webapp/WEB-INF/view/homepage.jsp | 22 ++ .../src/main/webapp/WEB-INF/view/login.jsp | 30 +++ .../src/main/webapp/WEB-INF/web.xml | 57 +++++ .../src/test/resources/.gitignore | 13 ++ 33 files changed, 971 insertions(+), 2 deletions(-) create mode 100644 spring-security-mvc-session/.classpath create mode 100644 spring-security-mvc-session/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 spring-security-mvc-session/.gitignore create mode 100644 spring-security-mvc-session/.project create mode 100644 spring-security-mvc-session/.settings/.jsdtscope create mode 100644 spring-security-mvc-session/.settings/org.eclipse.jdt.core.prefs create mode 100644 spring-security-mvc-session/.settings/org.eclipse.jdt.ui.prefs create mode 100644 spring-security-mvc-session/.settings/org.eclipse.m2e.core.prefs create mode 100644 spring-security-mvc-session/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.common.component create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs create mode 100644 spring-security-mvc-session/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 spring-security-mvc-session/.springBeans create mode 100644 spring-security-mvc-session/README.md create mode 100644 spring-security-mvc-session/pom.xml create mode 100644 spring-security-mvc-session/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java create mode 100644 spring-security-mvc-session/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java create mode 100644 spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-mvc-session/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-mvc-session/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java create mode 100644 spring-security-mvc-session/src/main/resources/logback.xml create mode 100644 spring-security-mvc-session/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/anonymous.jsp create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-mvc-session/src/test/resources/.gitignore diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index ea03f5664efb..53bdac770c6e 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -1,11 +1,12 @@ ========= ## Spring Security Login Example Project -- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) -- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) ### Relevant Articles: +- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) +- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) +- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) ### Build the Project diff --git a/spring-security-mvc-session/.classpath b/spring-security-mvc-session/.classpath new file mode 100644 index 000000000000..5dea19367768 --- /dev/null +++ b/spring-security-mvc-session/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-mvc-session/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-mvc-session/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-mvc-session/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-mvc-session/.gitignore b/spring-security-mvc-session/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-mvc-session/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-mvc-session/.project b/spring-security-mvc-session/.project new file mode 100644 index 000000000000..4670a72a3bff --- /dev/null +++ b/spring-security-mvc-session/.project @@ -0,0 +1,42 @@ + + + spring-security-mvc-session + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/spring-security-mvc-session/.settings/.jsdtscope b/spring-security-mvc-session/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/spring-security-mvc-session/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-mvc-session/.settings/org.eclipse.jdt.core.prefs b/spring-security-mvc-session/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-mvc-session/.settings/org.eclipse.jdt.ui.prefs b/spring-security-mvc-session/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-security-mvc-session/.settings/org.eclipse.m2e.core.prefs b/spring-security-mvc-session/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/spring-security-mvc-session/.settings/org.eclipse.m2e.wtp.prefs b/spring-security-mvc-session/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.common.component b/spring-security-mvc-session/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..0a268a3d82a0 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-mvc-session/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.ws.service.policy.prefs b/spring-security-mvc-session/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/spring-security-mvc-session/.springBeans b/spring-security-mvc-session/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/spring-security-mvc-session/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/spring-security-mvc-session/README.md b/spring-security-mvc-session/README.md new file mode 100644 index 000000000000..53bdac770c6e --- /dev/null +++ b/spring-security-mvc-session/README.md @@ -0,0 +1,15 @@ +========= + +## Spring Security Login Example Project + + +### Relevant Articles: +- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) +- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) +- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) + + +### Build the Project +``` +mvn clean install +``` diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml new file mode 100644 index 000000000000..7d7588cd1907 --- /dev/null +++ b/spring-security-mvc-session/pom.xml @@ -0,0 +1,220 @@ + + 4.0.0 + org.baeldung + spring-security-mvc-custom + 0.1-SNAPSHOT + + spring-security-mvc-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.codahale.metrics + metrics-core + 3.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-custom + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.5 + 4.2.4 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java b/spring-security-mvc-session/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java new file mode 100644 index 000000000000..ed253305edf1 --- /dev/null +++ b/spring-security-mvc-session/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java @@ -0,0 +1,25 @@ +package org.baeldung.monitoring; + +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.Slf4jReporter; + +public final class MetricRegistrySingleton { + + public static final MetricRegistry metrics = new MetricRegistry(); + + static { + Logger logger = LoggerFactory.getLogger("org.baeldung.monitoring"); + final Slf4jReporter reporter = Slf4jReporter.forRegistry(metrics).outputTo(logger).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(); + reporter.start(5, TimeUnit.MINUTES); + } + + private MetricRegistrySingleton() { + throw new AssertionError(); + } + +} diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-session/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..19f1ca76a6ce --- /dev/null +++ b/spring-security-mvc-session/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,94 @@ +package org.baeldung.security; + +import java.io.IOException; +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + protected final Log logger = LogFactory.getLog(this.getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + protected MySimpleUrlAuthenticationSuccessHandler() { + super(); + } + + // API + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + handle(request, response, authentication); + clearAuthenticationAttributes(request); + } + + // IMPL + + protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + final String targetUrl = determineTargetUrl(authentication); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + protected String determineTargetUrl(final Authentication authentication) { + boolean isUser = false; + boolean isAdmin = false; + final Collection authorities = authentication.getAuthorities(); + for (final GrantedAuthority grantedAuthority : authorities) { + if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + isUser = true; + break; + } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + isAdmin = true; + break; + } + } + + if (isUser) { + return "/homepage.html"; + } else if (isAdmin) { + return "/console.html"; + } else { + throw new IllegalStateException(); + } + } + + /** + * Removes temporary authentication-related data which may have been stored in the session + * during the authentication process. + */ + protected final void clearAuthenticationAttributes(final HttpServletRequest request) { + final HttpSession session = request.getSession(false); + + if (session == null) { + return; + } + + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + + public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } + +} diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..2229516633ff --- /dev/null +++ b/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,43 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/anonymous.html"); + + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + registry.addViewController("/console.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-session/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4da114c78b62 --- /dev/null +++ b/spring-security-mvc-session/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java b/spring-security-mvc-session/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java new file mode 100644 index 000000000000..46bf2708f748 --- /dev/null +++ b/spring-security-mvc-session/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java @@ -0,0 +1,43 @@ +package org.baeldung.web; + +import java.util.concurrent.atomic.AtomicInteger; + +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.baeldung.monitoring.MetricRegistrySingleton; + +import com.codahale.metrics.Counter; + +public class SessionListenerWithMetrics implements HttpSessionListener { + + private final AtomicInteger activeSessions; + + private final Counter counterOfActiveSessions; + + public SessionListenerWithMetrics() { + super(); + + activeSessions = new AtomicInteger(); + counterOfActiveSessions = MetricRegistrySingleton.metrics.counter("web.sessions.active.count"); + } + + // API + + public final int getTotalActiveSession() { + return activeSessions.get(); + } + + @Override + public final void sessionCreated(final HttpSessionEvent event) { + activeSessions.incrementAndGet(); + counterOfActiveSessions.inc(); + } + + @Override + public final void sessionDestroyed(final HttpSessionEvent event) { + activeSessions.decrementAndGet(); + counterOfActiveSessions.dec(); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/resources/logback.xml b/spring-security-mvc-session/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-mvc-session/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..186a435cdb99 --- /dev/null +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/anonymous.jsp new file mode 100644 index 000000000000..d4e9c0289b29 --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/anonymous.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Anonymous page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..d18b59a10caf --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..afd2c6da594f --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%> + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..0eb857c62aee --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,30 @@ + + + + +

Login

+ + + +
Password:
Remember Me:
+ + + + + + + + + + + + + + + +
User:
Password:
Remember Me:
+ + + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..bf691dc491f1 --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,57 @@ + + + + Spring MVC Custom Application + + + 1 + + + org.baeldung.web.SessionListenerWithMetrics + + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/test/resources/.gitignore b/spring-security-mvc-session/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-mvc-session/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From dce40f3492d81b64a3d84efde361391531aedf59 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 13:35:11 +0300 Subject: [PATCH 247/796] cleanup work --- .../.settings/org.eclipse.wst.common.component | 6 +++--- spring-security-mvc-session/pom.xml | 6 +++--- spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.common.component b/spring-security-mvc-session/.settings/org.eclipse.wst.common.component index 0a268a3d82a0..db01b7dfe468 100644 --- a/spring-security-mvc-session/.settings/org.eclipse.wst.common.component +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 7d7588cd1907..65df553ddf15 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-security-mvc-custom + spring-security-mvc-session 0.1-SNAPSHOT - spring-security-mvc-custom + spring-security-mvc-session war @@ -132,7 +132,7 @@ - spring-security-mvc-custom + spring-security-mvc-session src/main/resources diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml index bf691dc491f1..2dc303f7aef4 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml @@ -4,7 +4,7 @@ http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Custom Application + Spring MVC Session Application 1 From a72cec5f107a59dfe8ec9a308157289097aa53af Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 13:37:48 +0300 Subject: [PATCH 248/796] cleanup work after metrics no longer needed in custom project --- spring-security-mvc-custom/README.md | 1 - spring-security-mvc-custom/pom.xml | 12 +++--- .../monitoring/MetricRegistrySingleton.java | 25 ----------- .../web/SessionListenerWithMetrics.java | 43 ------------------- .../src/main/webapp/WEB-INF/web.xml | 3 -- spring-security-mvc-session/README.md | 2 - 6 files changed, 6 insertions(+), 80 deletions(-) delete mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java delete mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 53bdac770c6e..17f32e4a2f85 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -6,7 +6,6 @@ ### Relevant Articles: - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) - [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) -- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) ### Build the Project diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 7d7588cd1907..8678b91ec8ef 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -93,12 +93,12 @@
- - - com.codahale.metrics - metrics-core - 3.0.1 - + + + + + + diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java deleted file mode 100644 index ed253305edf1..000000000000 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.baeldung.monitoring; - -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Slf4jReporter; - -public final class MetricRegistrySingleton { - - public static final MetricRegistry metrics = new MetricRegistry(); - - static { - Logger logger = LoggerFactory.getLogger("org.baeldung.monitoring"); - final Slf4jReporter reporter = Slf4jReporter.forRegistry(metrics).outputTo(logger).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(); - reporter.start(5, TimeUnit.MINUTES); - } - - private MetricRegistrySingleton() { - throw new AssertionError(); - } - -} diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java deleted file mode 100644 index 46bf2708f748..000000000000 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.baeldung.web; - -import java.util.concurrent.atomic.AtomicInteger; - -import javax.servlet.http.HttpSessionEvent; -import javax.servlet.http.HttpSessionListener; - -import org.baeldung.monitoring.MetricRegistrySingleton; - -import com.codahale.metrics.Counter; - -public class SessionListenerWithMetrics implements HttpSessionListener { - - private final AtomicInteger activeSessions; - - private final Counter counterOfActiveSessions; - - public SessionListenerWithMetrics() { - super(); - - activeSessions = new AtomicInteger(); - counterOfActiveSessions = MetricRegistrySingleton.metrics.counter("web.sessions.active.count"); - } - - // API - - public final int getTotalActiveSession() { - return activeSessions.get(); - } - - @Override - public final void sessionCreated(final HttpSessionEvent event) { - activeSessions.incrementAndGet(); - counterOfActiveSessions.inc(); - } - - @Override - public final void sessionDestroyed(final HttpSessionEvent event) { - activeSessions.decrementAndGet(); - counterOfActiveSessions.dec(); - } - -} \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml index bf691dc491f1..ff61eb229b0b 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml @@ -9,9 +9,6 @@ 1 - - org.baeldung.web.SessionListenerWithMetrics - diff --git a/spring-security-mvc-session/README.md b/spring-security-mvc-session/README.md index 53bdac770c6e..840a1e0a3b68 100644 --- a/spring-security-mvc-session/README.md +++ b/spring-security-mvc-session/README.md @@ -4,8 +4,6 @@ ### Relevant Articles: -- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) -- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) - [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) From 5b2fd4d01393915ef1fb39ab89f8e65ffe081d5d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:29:10 +0300 Subject: [PATCH 249/796] new session work --- .../src/main/java/org/baeldung/spring/MvcConfig.java | 2 ++ .../src/main/resources/webSecurityConfig.xml | 12 ++++++++---- .../src/main/webapp/WEB-INF/web.xml | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java index 2229516633ff..9e9c24018159 100644 --- a/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java @@ -27,6 +27,8 @@ public void addViewControllers(final ViewControllerRegistry registry) { registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); + registry.addViewController("/sessionExpired.html"); + registry.addViewController("/invalidExpired.html"); registry.addViewController("/console.html"); } diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index 186a435cdb99..38348cb6ffd6 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + @@ -14,9 +14,13 @@ - - - + + + + + + + diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml index 2dc303f7aef4..a807f7dc074d 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml @@ -12,6 +12,9 @@ org.baeldung.web.SessionListenerWithMetrics + + org.springframework.security.ui.session.HttpSessionEventPublisher + From f9e560e1c1efb2d6930e4dbcdf93dfff48a67fc0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:30:47 +0300 Subject: [PATCH 250/796] new jsp pages for session management --- .../src/main/resources/webSecurityConfig.xml | 4 ++-- .../src/main/webapp/WEB-INF/view/invalidSession.jsp | 10 ++++++++++ .../src/main/webapp/WEB-INF/view/sessionExpired.jsp | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/invalidSession.jsp create mode 100644 spring-security-mvc-session/src/main/webapp/WEB-INF/view/sessionExpired.jsp diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index 38348cb6ffd6..cb7e3f06456a 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -17,8 +17,8 @@ - - + + diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/invalidSession.jsp new file mode 100644 index 000000000000..e8455ee11801 --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Invalid Session Page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/sessionExpired.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/sessionExpired.jsp new file mode 100644 index 000000000000..ab0f1c8c633b --- /dev/null +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/sessionExpired.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Session Expired Page

+ + ">To Login + + \ No newline at end of file From 873d76b254e97cb0c0a82d949cf63479c6174b1e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:32:32 +0300 Subject: [PATCH 251/796] minor class fix --- spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml index a807f7dc074d..902cc1ddace9 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml @@ -13,7 +13,7 @@ org.baeldung.web.SessionListenerWithMetrics - org.springframework.security.ui.session.HttpSessionEventPublisher + org.springframework.security.web.session.HttpSessionEventPublisher From 3433af92237309673555e16664d6c5a28d7109b8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:41:26 +0300 Subject: [PATCH 252/796] example for reproducing various exceptions --- .../beancreationexception/cause1/BeanA.java | 12 ++++++++++++ .../beancreationexception/cause1/BeanB.java | 5 +++++ .../beancreationexception/cause2/BeanA.java | 12 ++++++++++++ .../beancreationexception/cause2/BeanB1.java | 8 ++++++++ .../beancreationexception/cause2/BeanB2.java | 8 ++++++++ .../beancreationexception/cause2/IBeanB.java | 5 +++++ .../beancreationexception/cause3/BeanA.java | 12 ++++++++++++ .../spring/Cause1ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause2ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause3ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause4ContextWithJavaConfig.java | 16 ++++++++++++++++ ...1BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...2BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...3BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...4BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ 15 files changed, 202 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java new file mode 100644 index 000000000000..50d07c6d3974 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.beancreationexception.cause1; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private BeanB dependency; + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java new file mode 100644 index 000000000000..8b4b17a0c67a --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause1; + +public class BeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java new file mode 100644 index 000000000000..352dd5f2db1f --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.beancreationexception.cause2; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Autowired + private IBeanB dependency; + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java new file mode 100644 index 000000000000..b9ec961d1eb9 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB1 implements IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java new file mode 100644 index 000000000000..aa7fe8250afb --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause2; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB2 implements IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java new file mode 100644 index 000000000000..60e8a0a429f4 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause2; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java new file mode 100644 index 000000000000..2f2d1b26849f --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.beancreationexception.cause3; + +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + public BeanA() { + super(); + throw new NullPointerException(); + } +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java new file mode 100644 index 000000000000..cb74b96b6788 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause1") +public class Cause1ContextWithJavaConfig { + + public Cause1ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java new file mode 100644 index 000000000000..6b20439059be --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause2") +public class Cause2ContextWithJavaConfig { + + public Cause2ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java new file mode 100644 index 000000000000..437d2c4c205e --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause3") +public class Cause3ContextWithJavaConfig { + + public Cause3ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java new file mode 100644 index 000000000000..456c24f99563 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause4") +public class Cause4ContextWithJavaConfig { + + public Cause4ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..56d916e25d48 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause1ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..968e7312de8c --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause2ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..4730d59334b1 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause3ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..b5108c1ab468 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause4ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause4ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause4BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 429fe667270721593496002962e51ea1dc0baec9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:49:40 +0300 Subject: [PATCH 253/796] exception work --- .../beancreationexception/cause4/BeanA.java | 8 ++++++++ .../beancreationexception/cause4/IBeanA.java | 5 +++++ .../beancreationexception/cause5/BeanA.java | 13 +++++++++++++ .../beancreationexception/cause5/IBeanA.java | 5 +++++ .../spring/Cause4ContextWithJavaConfig.java | 2 ++ .../spring/Cause5ContextWithJavaConfig.java | 16 ++++++++++++++++ .../spring/Cause6ContextWithJavaConfig.java | 16 ++++++++++++++++ .../beancreationexception_cause4.xml | 11 +++++++++++ ...5BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...6BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ 10 files changed, 114 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/resources/beancreationexception_cause4.xml create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java new file mode 100644 index 000000000000..7886f30f227d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause4; + +import org.springframework.stereotype.Component; + +@Component +public abstract class BeanA implements IBeanA { + // +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java new file mode 100644 index 000000000000..2f25c1c36589 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause4; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java new file mode 100644 index 000000000000..b8f88125b2ec --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java @@ -0,0 +1,13 @@ +package org.baeldung.ex.beancreationexception.cause5; + +import org.springframework.stereotype.Component; + +@Component +public class BeanA implements IBeanA { + + public BeanA(final String name) { + super(); + System.out.println(name); + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java new file mode 100644 index 000000000000..5c575e400c43 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause5; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java index 456c24f99563..b661ba465079 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java @@ -2,9 +2,11 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; @Configuration @ComponentScan("org.baeldung.ex.beancreationexception.cause4") +@ImportResource("classpath:beancreationexception_cause4.xml") public class Cause4ContextWithJavaConfig { public Cause4ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java new file mode 100644 index 000000000000..821041cb0cd6 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause5") +public class Cause5ContextWithJavaConfig { + + public Cause5ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java new file mode 100644 index 000000000000..625f34513d72 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause6") +public class Cause6ContextWithJavaConfig { + + public Cause6ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml new file mode 100644 index 000000000000..2899a6e35817 --- /dev/null +++ b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..9a08ec45a1b3 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause5ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause5ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause5BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..423a0a98a95a --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause6ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause6ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause6BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 075dd7be5cc15a6a5014a7a901a979137674527c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:54:26 +0300 Subject: [PATCH 254/796] further exceptions work --- .../beancreationexception/cause6/BeanA.java | 8 ++++++++ .../beancreationexception/cause6/BeanB.java | 8 ++++++++ .../beancreationexception/cause6/IBeanB.java | 5 +++++ .../beancreationexception/cause8/BeanA.java | 16 ++++++++++++++++ .../beancreationexception/cause8/BeanB.java | 15 +++++++++++++++ .../beancreationexception/cause8/IBeanA.java | 5 +++++ .../beancreationexception/cause8/IBeanB.java | 5 +++++ .../spring/Cause6ContextWithJavaConfig.java | 2 ++ .../spring/Cause7ContextWithJavaConfig.java | 18 ++++++++++++++++++ .../spring/Cause8ContextWithJavaConfig.java | 16 ++++++++++++++++ .../beancreationexception_cause6.xml | 13 +++++++++++++ .../beancreationexception_cause7.xml | 11 +++++++++++ ...7BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ ...8BeanCreationExceptionIntegrationTest.java | 19 +++++++++++++++++++ 14 files changed, 160 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/resources/beancreationexception_cause6.xml create mode 100644 spring-exceptions/src/main/resources/beancreationexception_cause7.xml create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java new file mode 100644 index 000000000000..164b006340b4 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause6; + +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + private IBeanB dependency; +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java new file mode 100644 index 000000000000..4a7bdab28046 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause6; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB implements IBeanB { + // +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java new file mode 100644 index 000000000000..36b436ce985a --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause6; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java new file mode 100644 index 000000000000..2a0230fa3fa1 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.cause8; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanA implements IBeanA { + private IBeanB beanB; + + @Autowired + public BeanA(final IBeanB beanB) { + super(); + this.beanB = beanB; + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java new file mode 100644 index 000000000000..2e8a3eed079a --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java @@ -0,0 +1,15 @@ +package org.baeldung.ex.beancreationexception.cause8; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BeanB implements IBeanB { + final IBeanA beanA; + + @Autowired + public BeanB(final IBeanA beanA) { + super(); + this.beanA = beanA; + } +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java new file mode 100644 index 000000000000..3d6c4eef2809 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause8; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java new file mode 100644 index 000000000000..5f6f4389683d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause8; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java index 625f34513d72..c76e34deec0f 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java @@ -2,9 +2,11 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; @Configuration @ComponentScan("org.baeldung.ex.beancreationexception.cause6") +@ImportResource("classpath:beancreationexception_cause6.xml") public class Cause6ContextWithJavaConfig { public Cause6ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java new file mode 100644 index 000000000000..6b56519c1ad5 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause7") +@ImportResource("classpath:beancreationexception_cause7.xml") +public class Cause7ContextWithJavaConfig { + + public Cause7ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java new file mode 100644 index 000000000000..084cf8d3afe5 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause8") +public class Cause8ContextWithJavaConfig { + + public Cause8ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml new file mode 100644 index 000000000000..9f66aafa10fd --- /dev/null +++ b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml new file mode 100644 index 000000000000..f9b95960ec5f --- /dev/null +++ b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..a61e598b4130 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause7ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause7ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause7BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..8550f307d5ae --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause8ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause8ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause8BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 7da1bc0e02ffff97deebce97d45defcd228f9805 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 15:57:03 +0300 Subject: [PATCH 255/796] further exceptions work --- .../beancreationexception/cause9/BeanA.java | 5 ++++ .../beancreationexception/cause9/BeanB.java | 8 +++++ .../beancreationexception/cause9/IBeanA.java | 5 ++++ .../spring/Cause9ContextWithJavaConfig.java | 30 +++++++++++++++++++ .../beancreationexception_cause9.xml | 11 +++++++ ...9BeanCreationExceptionIntegrationTest.java | 19 ++++++++++++ 6 files changed, 78 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/resources/beancreationexception_cause9.xml create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java new file mode 100644 index 000000000000..28c39e2777ff --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause9; + +public abstract class BeanA implements IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java new file mode 100644 index 000000000000..d012dc6a0b1d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.beancreationexception.cause9; + +import org.springframework.stereotype.Component; + +@Component +public class BeanB { + // +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java new file mode 100644 index 000000000000..82114b18da54 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java @@ -0,0 +1,5 @@ +package org.baeldung.ex.beancreationexception.cause9; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java new file mode 100644 index 000000000000..d64ec9ab3d8c --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java @@ -0,0 +1,30 @@ +package org.baeldung.ex.beancreationexception.spring; + +import org.baeldung.ex.beancreationexception.cause9.BeanB; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ComponentScan("org.baeldung.ex.beancreationexception.cause9") +@ImportResource("classpath:beancreationexception_cause9.xml") +public class Cause9ContextWithJavaConfig { + @Autowired + BeanFactory beanFactory; + + public Cause9ContextWithJavaConfig() { + super(); + } + + // beans + + @Bean + public BeanB beanB() { + beanFactory.getBean("beanA"); + return new BeanB(); + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml new file mode 100644 index 000000000000..74878a62da09 --- /dev/null +++ b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionIntegrationTest.java new file mode 100644 index 000000000000..ad1ba5f2f169 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beancreationexception; + +import org.baeldung.ex.beancreationexception.spring.Cause9ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause9ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause9BeanCreationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From 8ec7ccd7d3a08a9d2d436054d6c395109d142227 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 16:36:54 +0300 Subject: [PATCH 256/796] final test of the bean creation exception track --- .../org/baeldung/ex/beancreationexception/cause9/BeanB.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java index d012dc6a0b1d..5e076023f0c4 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java @@ -1,8 +1,5 @@ package org.baeldung.ex.beancreationexception.cause9; -import org.springframework.stereotype.Component; - -@Component public class BeanB { // } \ No newline at end of file From 6c3a03f9298291ade562ab7f11c579c3ec47d90a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:00:24 +0300 Subject: [PATCH 257/796] further exceptions work --- .../cause2/BeanA.java | 12 +++++++++ .../spring/Cause1ContextWithJavaConfig.java | 18 +++++++++++++ .../spring/Cause2ContextWithJavaConfig.java | 27 +++++++++++++++++++ .../spring/Cause3ContextWithJavaConfig.java | 16 +++++++++++ ...finitionStoreExceptionIntegrationTest.java | 19 +++++++++++++ ...finitionStoreExceptionIntegrationTest.java | 19 +++++++++++++ ...finitionStoreExceptionIntegrationTest.java | 19 +++++++++++++ 7 files changed, 130 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java new file mode 100644 index 000000000000..a0aefda1cd2f --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java @@ -0,0 +1,12 @@ +package org.baeldung.ex.beandefinitionstoreexception.cause2; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class BeanA { + + @Value("${some.property2}") + private String someProperty2; + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java new file mode 100644 index 000000000000..3b6b4f2b8d3e --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.ex.beandefinitionstoreexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause1") +@ImportResource("beans.xml") +public class Cause1ContextWithJavaConfig { + + public Cause1ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java new file mode 100644 index 000000000000..d31890e0f39f --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java @@ -0,0 +1,27 @@ +package org.baeldung.ex.beandefinitionstoreexception.spring; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause2") +public class Cause2ContextWithJavaConfig { + + @Value("${some.property}") + private String someProperty; + + public Cause2ContextWithJavaConfig() { + super(); + } + + // beans + + @Bean + public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java new file mode 100644 index 000000000000..11a00b1770a7 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.beandefinitionstoreexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause3") +public class Cause3ContextWithJavaConfig { + + public Cause3ContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionIntegrationTest.java new file mode 100644 index 000000000000..8de51a4bf086 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beandefinitionstoreexception; + +import org.baeldung.ex.beandefinitionstoreexception.spring.Cause1ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1BeanDefinitionStoreExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionIntegrationTest.java new file mode 100644 index 000000000000..8dbc50cda51c --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beandefinitionstoreexception; + +import org.baeldung.ex.beandefinitionstoreexception.spring.Cause2ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2BeanDefinitionStoreExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionIntegrationTest.java new file mode 100644 index 000000000000..370b67e2fa5c --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.beandefinitionstoreexception; + +import org.baeldung.ex.beandefinitionstoreexception.spring.Cause3ContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3BeanDefinitionStoreExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} From f147b8b0e1c3afc7943be51cb89a97f209bfa6a1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:14:48 +0300 Subject: [PATCH 258/796] initial persistence work for the exception project - to reproduce data exceptions --- .../Cause1DataContextWithJavaConfig.java | 23 +++++++ .../Cause2DataContextWithJavaConfig.java | 16 +++++ .../Cause3DataContextWithJavaConfig.java | 16 +++++ ...rityViolationExceptionIntegrationTest.java | 19 ++++++ ...rityViolationExceptionIntegrationTest.java | 19 ++++++ ...rityViolationExceptionIntegrationTest.java | 19 ++++++ ...eanDefinitionExceptionIntegrationTest.java | 26 +++++++- .../baeldung/persistence/dao/IChildDao.java | 8 +++ .../baeldung/persistence/dao/IParentDao.java | 8 +++ .../dao/common/AbstractHibernateDao.java | 65 +++++++++++++++++++ .../persistence/dao/common/IOperations.java | 20 ++++++ .../persistence/dao/impl/ChildDao.java | 24 +++++++ .../persistence/dao/impl/ParentDao.java | 24 +++++++ .../org/baeldung/persistence/model/Child.java | 51 +++++++++++++++ .../baeldung/persistence/model/Parent.java | 60 +++++++++++++++++ .../persistence/service/IChildService.java | 8 +++ .../persistence/service/IParentService.java | 8 +++ 17 files changed, 411 insertions(+), 3 deletions(-) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java new file mode 100644 index 000000000000..b1dabd7ec39d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java @@ -0,0 +1,23 @@ +package org.baeldung.ex.dataIntegrityviolationexception.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; + +@Configuration +@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause1") +public class Cause1DataContextWithJavaConfig { + + public Cause1DataContextWithJavaConfig() { + super(); + } + + // beans + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java new file mode 100644 index 000000000000..e0e54e5abc72 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.dataIntegrityviolationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause2") +public class Cause2DataContextWithJavaConfig { + + public Cause2DataContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java new file mode 100644 index 000000000000..3eb8df39be74 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.ex.dataIntegrityviolationexception.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause3") +public class Cause3DataContextWithJavaConfig { + + public Cause3DataContextWithJavaConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java new file mode 100644 index 000000000000..8b503e989a89 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.dataIntegrityviolationexception; + +import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause1DataContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause1DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1DataIntegrityViolationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java new file mode 100644 index 000000000000..2eec55736da6 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.dataIntegrityviolationexception; + +import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause2DataContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2DataIntegrityViolationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java new file mode 100644 index 000000000000..5f4cf59f3a1d --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java @@ -0,0 +1,19 @@ +package org.baeldung.ex.dataIntegrityviolationexception; + +import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause3DataContextWithJavaConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3DataIntegrityViolationExceptionIntegrationTest { + + @Test + public final void givenContextIsInitialized_thenNoException() { + // + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java index aed37a125a85..6f42b75398fd 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -1,8 +1,14 @@ package org.baeldung.ex.nosuchbeandefinitionexception; import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; +import org.baeldung.persistence.model.Child; +import org.baeldung.persistence.model.Parent; +import org.baeldung.persistence.service.IChildService; +import org.baeldung.persistence.service.IParentService; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +17,23 @@ @ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause1NoSuchBeanDefinitionExceptionIntegrationTest { - @Test - public final void givenContextIsInitialized_thenNoException() { - // + @Autowired + private IParentService service; + + @Autowired + private IChildService childService; + + // tests + + @Test(expected = DataIntegrityViolationException.class) + public void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + childService.delete(childEntity); } } diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java new file mode 100644 index 000000000000..3bc0dc1fc497 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Child; + +public interface IChildDao extends IOperations { + // +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java new file mode 100644 index 000000000000..09158a414399 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Parent; + +public interface IParentDao extends IOperations { + // +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java new file mode 100644 index 000000000000..65e57afcb3e5 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -0,0 +1,65 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao implements IOperations { + private Class clazz; + + @Autowired + private SessionFactory sessionFactory; + + // API + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } + + @Override + public final T findOne(final long id) { + return (T) getCurrentSession().get(clazz, id); + } + + @Override + public final List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + @Override + public final void create(final T entity) { + Preconditions.checkNotNull(entity); + // getCurrentSession().persist(entity); + getCurrentSession().saveOrUpdate(entity); + } + + @Override + public final T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + @Override + public final void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public final void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected final Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java new file mode 100644 index 000000000000..1c84b06c8569 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java @@ -0,0 +1,20 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + void create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java new file mode 100644 index 000000000000..d9c8fdceecdf --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java @@ -0,0 +1,24 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.dao.IChildDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Child; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class ChildDao extends AbstractHibernateDao implements IChildDao { + + @Autowired + private SessionFactory sessionFactory; + + public ChildDao() { + super(); + + setClazz(Child.class); + } + + // API + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java new file mode 100644 index 000000000000..003ec627411a --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java @@ -0,0 +1,24 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.dao.IParentDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Parent; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class ParentDao extends AbstractHibernateDao implements IParentDao { + + @Autowired + private SessionFactory sessionFactory; + + public ParentDao() { + super(); + + setClazz(Parent.class); + } + + // API + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java b/spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java new file mode 100644 index 000000000000..4eec4cf1d3a4 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java @@ -0,0 +1,51 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +@Entity +public class Child implements Serializable { + + @Id + @GeneratedValue + private long id; + + @OneToOne(mappedBy = "child") + private Parent parent; + + public Child() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public Parent getParent() { + return parent; + } + + public void setParent(final Parent parent) { + this.parent = parent; + } + + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Child [id=").append(id).append("]"); + return builder.toString(); + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java b/spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java new file mode 100644 index 000000000000..19e405615dfe --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java @@ -0,0 +1,60 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + +@Entity +public class Parent implements Serializable { + + @Id + @GeneratedValue + private long id; + + @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH }) + @JoinColumn(name = "child_fk") + private Child child; + + public Parent() { + super(); + } + + public Parent(final Child child) { + super(); + + this.child = child; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public Child getChild() { + return child; + } + + public void setChild(final Child child) { + this.child = child; + } + + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Parent [id=").append(id).append("]"); + return builder.toString(); + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java b/spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java new file mode 100644 index 000000000000..c6c5e2cfb177 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Child; + +public interface IChildService extends IOperations { + // +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java b/spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java new file mode 100644 index 000000000000..1782c281d2fe --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Parent; + +public interface IParentService extends IOperations { + // +} From 3bbfdf175b9d8880759a64e3f62550250c84377d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:21:04 +0300 Subject: [PATCH 259/796] further persistence work --- spring-exceptions/pom.xml | 8 +- .../spring/Cause1ContextWithJavaConfig.java | 3 + .../common/AbstractHibernateDao.java | 2 +- .../persistence/common/AbstractService.java | 44 +++++++++++ .../persistence}/common/IOperations.java | 2 +- .../baeldung/persistence/dao/IChildDao.java | 2 +- .../baeldung/persistence/dao/IParentDao.java | 2 +- .../persistence/dao/impl/ChildDao.java | 2 +- .../persistence/dao/impl/ParentDao.java | 2 +- .../org/baeldung/persistence/model/Child.java | 0 .../baeldung/persistence/model/Parent.java | 0 .../persistence/service/IChildService.java | 2 +- .../persistence/service/IParentService.java | 2 +- .../service/impl/ChildService.java | 29 +++++++ .../service/impl/ParentService.java | 28 +++++++ .../resources/persistence-mysql.properties | 10 +++ .../persistence/spring/PersistenceConfig.java | 79 +++++++++++++++++++ spring-hibernate4/pom.xml | 4 +- 18 files changed, 210 insertions(+), 11 deletions(-) rename spring-exceptions/src/{test/java/org/baeldung/persistence/dao => main/java/org/baeldung/persistence}/common/AbstractHibernateDao.java (97%) create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java rename spring-exceptions/src/{test/java/org/baeldung/persistence/dao => main/java/org/baeldung/persistence}/common/IOperations.java (87%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/dao/IChildDao.java (72%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/dao/IParentDao.java (73%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/dao/impl/ChildDao.java (89%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/dao/impl/ParentDao.java (89%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/model/Child.java (100%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/model/Parent.java (100%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/service/IChildService.java (73%) rename spring-exceptions/src/{test => main}/java/org/baeldung/persistence/service/IParentService.java (74%) create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java create mode 100644 spring-exceptions/src/main/resources/persistence-mysql.properties create mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index ab8272cb02f4..7a52560615ac 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -50,6 +50,11 @@ ${mysql-connector-java.version} runtime + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + @@ -188,8 +193,9 @@ 1.2 - 4.2.3.Final + 4.2.4.Final 5.1.26 + 7.0.42 1.7.5 diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java index 5ba971baa9d6..2eedc0d2417b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -1,10 +1,13 @@ package org.baeldung.ex.nosuchbeandefinitionexception.spring; +import org.baeldung.persistence.spring.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration @ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") +@Import(PersistenceConfig.class) public class Cause1ContextWithJavaConfig { public Cause1ContextWithJavaConfig() { diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java similarity index 97% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java index 65e57afcb3e5..cadb2ac06191 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.common; +package org.baeldung.persistence.common; import java.io.Serializable; import java.util.List; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java new file mode 100644 index 000000000000..d2e162ad7b34 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java @@ -0,0 +1,44 @@ +package org.baeldung.persistence.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +public abstract class AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return getDao().findOne(id); + } + + @Override + public List findAll() { + return getDao().findAll(); + } + + @Override + public void create(final T entity) { + getDao().create(entity); + } + + @Override + public T update(final T entity) { + return getDao().update(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(entityId); + } + + protected abstract IOperations getDao(); + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java b/spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java similarity index 87% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java index 1c84b06c8569..dee27950c7e2 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/common/IOperations.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.common; +package org.baeldung.persistence.common; import java.io.Serializable; import java.util.List; diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java similarity index 72% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java index 3bc0dc1fc497..25290554f3b3 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IChildDao.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java @@ -1,6 +1,6 @@ package org.baeldung.persistence.dao; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.common.IOperations; import org.baeldung.persistence.model.Child; public interface IChildDao extends IOperations { diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java similarity index 73% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java index 09158a414399..a047d97ef177 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/IParentDao.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java @@ -1,6 +1,6 @@ package org.baeldung.persistence.dao; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.common.IOperations; import org.baeldung.persistence.model.Parent; public interface IParentDao extends IOperations { diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java similarity index 89% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java index d9c8fdceecdf..e068573c5c2f 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ChildDao.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java @@ -1,7 +1,7 @@ package org.baeldung.persistence.dao.impl; +import org.baeldung.persistence.common.AbstractHibernateDao; import org.baeldung.persistence.dao.IChildDao; -import org.baeldung.persistence.dao.common.AbstractHibernateDao; import org.baeldung.persistence.model.Child; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java similarity index 89% rename from spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java index 003ec627411a..5634137b63dd 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/dao/impl/ParentDao.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java @@ -1,7 +1,7 @@ package org.baeldung.persistence.dao.impl; +import org.baeldung.persistence.common.AbstractHibernateDao; import org.baeldung.persistence.dao.IParentDao; -import org.baeldung.persistence.dao.common.AbstractHibernateDao; import org.baeldung.persistence.model.Parent; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java b/spring-exceptions/src/main/java/org/baeldung/persistence/model/Child.java similarity index 100% rename from spring-exceptions/src/test/java/org/baeldung/persistence/model/Child.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/model/Child.java diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java b/spring-exceptions/src/main/java/org/baeldung/persistence/model/Parent.java similarity index 100% rename from spring-exceptions/src/test/java/org/baeldung/persistence/model/Parent.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/model/Parent.java diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java similarity index 73% rename from spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java index c6c5e2cfb177..e2c2055ca2f5 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IChildService.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java @@ -1,6 +1,6 @@ package org.baeldung.persistence.service; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.common.IOperations; import org.baeldung.persistence.model.Child; public interface IChildService extends IOperations { diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java similarity index 74% rename from spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java rename to spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java index 1782c281d2fe..a05f07658ff7 100644 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/service/IParentService.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java @@ -1,6 +1,6 @@ package org.baeldung.persistence.service; -import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.common.IOperations; import org.baeldung.persistence.model.Parent; public interface IParentService extends IOperations { diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java new file mode 100644 index 000000000000..4b66f3d2bd6b --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java @@ -0,0 +1,29 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.common.AbstractService; +import org.baeldung.persistence.common.IOperations; +import org.baeldung.persistence.dao.IChildDao; +import org.baeldung.persistence.model.Child; +import org.baeldung.persistence.service.IChildService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service +public class ChildService extends AbstractService implements IChildService { + + @Autowired + private IChildDao dao; + + public ChildService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java new file mode 100644 index 000000000000..97c44f4a2f6d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java @@ -0,0 +1,28 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.common.AbstractService; +import org.baeldung.persistence.common.IOperations; +import org.baeldung.persistence.dao.IParentDao; +import org.baeldung.persistence.model.Parent; +import org.baeldung.persistence.service.IParentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ParentService extends AbstractService implements IParentService { + + @Autowired + private IParentDao dao; + + public ParentService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-exceptions/src/main/resources/persistence-mysql.properties b/spring-exceptions/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..04a62f6c6ad7 --- /dev/null +++ b/spring-exceptions/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_exceptions?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java b/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java new file mode 100644 index 000000000000..cace2e1952e7 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.persistence.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 775abd7bdac1..e445098b1c3f 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -171,9 +171,9 @@ 3.18.0-GA - 4.2.3.Final + 4.2.4.Final 5.1.26 - 7.0.41 + 7.0.42 1.7.5 From f6e6b977179e2e0b5179ab71b56f73bd7ae88475 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:22:24 +0300 Subject: [PATCH 260/796] testing work --- .../Cause1DataContextWithJavaConfig.java | 3 + .../spring/Cause1ContextWithJavaConfig.java | 3 - .../spring/config/PersistenceConfig.java | 9 ++- .../persistence/spring/PersistenceConfig.java | 79 ------------------- 4 files changed, 8 insertions(+), 86 deletions(-) delete mode 100644 spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java index b1dabd7ec39d..59feb5dd7152 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java @@ -1,12 +1,15 @@ package org.baeldung.ex.dataIntegrityviolationexception.spring; +import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @Configuration @ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause1") +@Import(PersistenceConfig.class) public class Cause1DataContextWithJavaConfig { public Cause1DataContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java index 2eedc0d2417b..5ba971baa9d6 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -1,13 +1,10 @@ package org.baeldung.ex.nosuchbeandefinitionexception.spring; -import org.baeldung.persistence.spring.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; @Configuration @ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") -@Import(PersistenceConfig.class) public class Cause1ContextWithJavaConfig { public Cause1ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 6a057fc0c741..fdf617904015 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -4,20 +4,21 @@ import javax.sql.DataSource; +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.hibernate4.HibernateTransactionManager; import org.springframework.orm.hibernate4.LocalSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; -// @Configuration +@Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) @@ -34,7 +35,7 @@ public PersistenceConfig() { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; @@ -42,7 +43,7 @@ public LocalSessionFactoryBean sessionFactory() { @Bean public DataSource restDataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); diff --git a/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java b/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java deleted file mode 100644 index cace2e1952e7..000000000000 --- a/spring-exceptions/src/test/java/org/baeldung/persistence/spring/PersistenceConfig.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.baeldung.persistence.spring; - -import java.util.Properties; - -import javax.sql.DataSource; - -import org.apache.tomcat.dbcp.dbcp.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import com.google.common.base.Preconditions; - -@Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) -public class PersistenceConfig { - - @Autowired - private Environment env; - - public PersistenceConfig() { - super(); - } - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public DataSource restDataSource() { - final BasicDataSource dataSource = new BasicDataSource(); - dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); - dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); - dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); - dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); - - return dataSource; - } - - @Bean - public HibernateTransactionManager transactionManager() { - final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); - - return txManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; - } -} \ No newline at end of file From cc7775d6d8041fb5caa4dedfdec690753d3b6539 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:35:21 +0300 Subject: [PATCH 261/796] further persistence work --- .../org/baeldung/persistence/dao/IFooDao.java | 8 ++ .../baeldung/persistence/dao/impl/FooDao.java | 24 ++++++ .../org/baeldung/persistence/model/Foo.java | 83 +++++++++++++++++++ .../persistence/service/IFooService.java | 8 ++ .../persistence/service/impl/FooService.java | 28 +++++++ ...rityViolationExceptionIntegrationTest.java | 26 +++++- ...eanDefinitionExceptionIntegrationTest.java | 20 +---- 7 files changed, 177 insertions(+), 20 deletions(-) create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..b41cd9eddecd --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java new file mode 100644 index 000000000000..baf29c9ecdb7 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java @@ -0,0 +1,24 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.common.AbstractHibernateDao; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractHibernateDao implements IFooDao { + + @Autowired + private SessionFactory sessionFactory; + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java new file mode 100644 index 000000000000..8e1dee33e845 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java new file mode 100644 index 000000000000..64b826db0212 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.common.IOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java new file mode 100644 index 000000000000..f0a4d7a6490c --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -0,0 +1,28 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.common.AbstractService; +import org.baeldung.persistence.common.IOperations; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService extends AbstractService implements IFooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java index 8b503e989a89..ea94d5612c2e 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java @@ -1,8 +1,14 @@ package org.baeldung.ex.dataIntegrityviolationexception; import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause1DataContextWithJavaConfig; +import org.baeldung.persistence.model.Child; +import org.baeldung.persistence.model.Parent; +import org.baeldung.persistence.service.IChildService; +import org.baeldung.persistence.service.IParentService; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +17,23 @@ @ContextConfiguration(classes = { Cause1DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause1DataIntegrityViolationExceptionIntegrationTest { - @Test - public final void givenContextIsInitialized_thenNoException() { - // + @Autowired + private IParentService service; + + @Autowired + private IChildService childService; + + // tests + + @Test(expected = DataIntegrityViolationException.class) + public void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + childService.delete(childEntity); } } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java index 6f42b75398fd..1a9711b2d62b 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionIntegrationTest.java @@ -17,23 +17,9 @@ @ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause1NoSuchBeanDefinitionExceptionIntegrationTest { - @Autowired - private IParentService service; - - @Autowired - private IChildService childService; - - // tests - - @Test(expected = DataIntegrityViolationException.class) - public void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { - final Child childEntity = new Child(); - childService.create(childEntity); - - final Parent parentEntity = new Parent(childEntity); - service.create(parentEntity); - - childService.delete(childEntity); + @Test + public final void givenContextIsInitialized_thenNoException() { + // } } From b85141738d8e281d179f7e99f33fc5305cbba1d2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:38:41 +0300 Subject: [PATCH 262/796] further persistence tests --- spring-exceptions/pom.xml | 6 ++++++ .../spring/Cause2DataContextWithJavaConfig.java | 3 +++ .../spring/Cause3DataContextWithJavaConfig.java | 3 +++ ...egrityViolationExceptionIntegrationTest.java | 12 ++++++++++++ ...egrityViolationExceptionIntegrationTest.java | 16 ++++++++++++---- ...egrityViolationExceptionIntegrationTest.java | 17 ++++++++++++++--- 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 7a52560615ac..002ee4c25816 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -87,6 +87,12 @@ guava ${guava.version} + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java index e0e54e5abc72..d38898d9cfd4 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java @@ -1,10 +1,13 @@ package org.baeldung.ex.dataIntegrityviolationexception.spring; +import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration @ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause2") +@Import(PersistenceConfig.class) public class Cause2DataContextWithJavaConfig { public Cause2DataContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java index 3eb8df39be74..232435377a46 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java @@ -1,10 +1,13 @@ package org.baeldung.ex.dataIntegrityviolationexception.spring; +import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration @ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause3") +@Import(PersistenceConfig.class) public class Cause3DataContextWithJavaConfig { public Cause3DataContextWithJavaConfig() { diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java index ea94d5612c2e..e6cf53b68c41 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java @@ -36,4 +36,16 @@ public void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataExceptio childService.delete(childEntity); } + @Test + public void whenChildIsDeletedAfterTheParent_thenNoExceptions() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + service.delete(parentEntity); + childService.delete(childEntity); + } + } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java index 2eec55736da6..909e7f95c809 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java @@ -1,8 +1,12 @@ package org.baeldung.ex.dataIntegrityviolationexception; import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause2DataContextWithJavaConfig; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +15,13 @@ @ContextConfiguration(classes = { Cause2DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause2DataIntegrityViolationExceptionIntegrationTest { - @Test - public final void givenContextIsInitialized_thenNoException() { - // - } + @Autowired + private IFooService fooService; + + // tests + @Test(expected = DataIntegrityViolationException.class) + public void whenInvalidEntityIsCreated_thenDataException() { + fooService.create(new Foo()); + } } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java index 5f4cf59f3a1d..6605a1cd28fd 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java @@ -1,8 +1,14 @@ package org.baeldung.ex.dataIntegrityviolationexception; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause3DataContextWithJavaConfig; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -11,9 +17,14 @@ @ContextConfiguration(classes = { Cause3DataContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause3DataIntegrityViolationExceptionIntegrationTest { - @Test - public final void givenContextIsInitialized_thenNoException() { - // + @Autowired + private IFooService fooService; + + // tests + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + fooService.create(new Foo(randomAlphabetic(2048))); } } From e07fbcf6a409ff5d6e9007825a5c1be860d8ed1c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 17:40:29 +0300 Subject: [PATCH 263/796] general cleanup --- .../spring/Cause1DataContextWithJavaConfig.java | 2 +- .../spring/Cause2DataContextWithJavaConfig.java | 2 +- .../spring/Cause3DataContextWithJavaConfig.java | 2 +- .../Cause1DataIntegrityViolationExceptionIntegrationTest.java | 4 ++-- .../Cause2DataIntegrityViolationExceptionIntegrationTest.java | 4 ++-- .../Cause3DataIntegrityViolationExceptionIntegrationTest.java | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) rename spring-exceptions/src/main/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/spring/Cause1DataContextWithJavaConfig.java (92%) rename spring-exceptions/src/main/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/spring/Cause2DataContextWithJavaConfig.java (88%) rename spring-exceptions/src/main/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/spring/Cause3DataContextWithJavaConfig.java (88%) rename spring-exceptions/src/test/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/Cause1DataIntegrityViolationExceptionIntegrationTest.java (93%) rename spring-exceptions/src/test/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/Cause2DataIntegrityViolationExceptionIntegrationTest.java (89%) rename spring-exceptions/src/test/java/org/baeldung/ex/{dataIntegrityviolationexception => dataintegrityviolationexception}/Cause3DataIntegrityViolationExceptionIntegrationTest.java (90%) diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java similarity index 92% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java index 59feb5dd7152..c4d98176c5ec 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.dataIntegrityviolationexception.spring; +package org.baeldung.ex.dataintegrityviolationexception.spring; import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.Bean; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java index d38898d9cfd4..4dcae6282c0b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.dataIntegrityviolationexception.spring; +package org.baeldung.ex.dataintegrityviolationexception.spring; import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java index 232435377a46..bb9b90585431 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataIntegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.dataIntegrityviolationexception.spring; +package org.baeldung.ex.dataintegrityviolationexception.spring; import org.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java similarity index 93% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java index e6cf53b68c41..0f4648111634 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.dataIntegrityviolationexception; +package org.baeldung.ex.dataintegrityviolationexception; -import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause1DataContextWithJavaConfig; +import org.baeldung.ex.dataintegrityviolationexception.spring.Cause1DataContextWithJavaConfig; import org.baeldung.persistence.model.Child; import org.baeldung.persistence.model.Parent; import org.baeldung.persistence.service.IChildService; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java similarity index 89% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java index 909e7f95c809..0ea0dd2f288d 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.dataIntegrityviolationexception; +package org.baeldung.ex.dataintegrityviolationexception; -import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause2DataContextWithJavaConfig; +import org.baeldung.ex.dataintegrityviolationexception.spring.Cause2DataContextWithJavaConfig; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.junit.Test; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java similarity index 90% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java index 6605a1cd28fd..75d579391039 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataIntegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionIntegrationTest.java @@ -1,8 +1,8 @@ -package org.baeldung.ex.dataIntegrityviolationexception; +package org.baeldung.ex.dataintegrityviolationexception; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.ex.dataIntegrityviolationexception.spring.Cause3DataContextWithJavaConfig; +import org.baeldung.ex.dataintegrityviolationexception.spring.Cause3DataContextWithJavaConfig; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.junit.Test; From c7a1377cf6a4bd3cbc47ff7122e495bbf3771455 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 22:21:14 +0300 Subject: [PATCH 264/796] hibernate work --- .../spring/PersistenceConfig.java | 79 +++++++++++++++++++ .../resources/persistence-mysql.properties | 2 +- .../MappingExceptionIntegrationTest.java | 29 +++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java new file mode 100644 index 000000000000..0d6fa738f401 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.ex.mappingexception.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model2" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/persistence-mysql.properties b/spring-exceptions/src/main/resources/persistence-mysql.properties index 04a62f6c6ad7..af56ce1bf861 100644 --- a/spring-exceptions/src/main/resources/persistence-mysql.properties +++ b/spring-exceptions/src/main/resources/persistence-mysql.properties @@ -7,4 +7,4 @@ jdbc.pass=tutorialmy5ql # hibernate.X hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop +hibernate.hbm2ddl.auto=create diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java new file mode 100644 index 000000000000..47f519e211b9 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java @@ -0,0 +1,29 @@ +package org.baeldung.ex.mappingexception; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.ex.mappingexception.spring.PersistenceConfig; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class MappingExceptionIntegrationTest { + + @Autowired + private IFooService fooService; + + // tests + + @Test + public final void givenEntityIsPersisted_thenException() { + fooService.create(new Foo(randomAlphabetic(6))); + } + +} From c82d342eae7955fdd0de9d7d69dd7d916f7bcf80 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 22:34:31 +0300 Subject: [PATCH 265/796] persistence wortk --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../cause1/persistence/dao/FooDao.java | 23 ++++++ .../cause1/persistence/dao/IFooDao.java | 8 ++ .../cause1/persistence/model/Foo.java | 81 +++++++++++++++++++ .../persistence/service/FooService.java | 27 +++++++ .../persistence/service/IFooService.java | 8 ++ ...nfig.java => Cause1PersistenceConfig.java} | 8 +- ...ause1MappingExceptionIntegrationTest.java} | 14 ++-- 8 files changed, 159 insertions(+), 12 deletions(-) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java rename spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/{PersistenceConfig.java => Cause1PersistenceConfig.java} (93%) rename spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/{MappingExceptionIntegrationTest.java => Cause1MappingExceptionIntegrationTest.java} (56%) diff --git a/spring-exceptions/.settings/org.eclipse.jdt.core.prefs b/spring-exceptions/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..df8135651462 100644 --- a/spring-exceptions/.settings/org.eclipse.jdt.core.prefs +++ b/spring-exceptions/.settings/org.eclipse.jdt.core.prefs @@ -42,7 +42,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java new file mode 100644 index 000000000000..2755be8445c9 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java @@ -0,0 +1,23 @@ +package org.baeldung.ex.mappingexception.cause1.persistence.dao; + +import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import org.baeldung.persistence.common.AbstractHibernateDao; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractHibernateDao implements IFooDao { + + @Autowired + private SessionFactory sessionFactory; + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..8519858eca6d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.mappingexception.cause1.persistence.dao; + +import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import org.baeldung.persistence.common.IOperations; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java new file mode 100644 index 000000000000..dd094076027e --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java @@ -0,0 +1,81 @@ +package org.baeldung.ex.mappingexception.cause1.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java new file mode 100644 index 000000000000..7054b721cfec --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java @@ -0,0 +1,27 @@ +package org.baeldung.ex.mappingexception.cause1.persistence.service; + +import org.baeldung.ex.mappingexception.cause1.persistence.dao.IFooDao; +import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import org.baeldung.persistence.common.AbstractService; +import org.baeldung.persistence.common.IOperations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService extends AbstractService implements IFooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java new file mode 100644 index 000000000000..5d7015cbc2b7 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.mappingexception.cause1.persistence.service; + +import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import org.baeldung.persistence.common.IOperations; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java similarity index 93% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java rename to spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java index 0d6fa738f401..98d2941db569 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java @@ -21,13 +21,13 @@ @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) -public class PersistenceConfig { +@ComponentScan({ "org.baeldung.ex.mappingexception.cause1.persistence" }) +public class Cause1PersistenceConfig { @Autowired private Environment env; - public PersistenceConfig() { + public Cause1PersistenceConfig() { super(); } @@ -35,7 +35,7 @@ public PersistenceConfig() { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model2" }); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause1.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java similarity index 56% rename from spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java rename to spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java index 47f519e211b9..46f551c65259 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java @@ -2,9 +2,9 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.ex.mappingexception.spring.PersistenceConfig; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import org.baeldung.ex.mappingexception.cause1.persistence.service.IFooService; +import org.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -13,17 +13,17 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class MappingExceptionIntegrationTest { +@ContextConfiguration(classes = { Cause1PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause1MappingExceptionIntegrationTest { @Autowired - private IFooService fooService; + private IFooService fooApi; // tests @Test public final void givenEntityIsPersisted_thenException() { - fooService.create(new Foo(randomAlphabetic(6))); + fooApi.create(new Foo(randomAlphabetic(6))); } } From 5a1c890c10b3c3eaec8b42a7991a386a8e2f56b9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 23:18:22 +0300 Subject: [PATCH 266/796] persistence work --- .../cause2/persistence/dao/FooDao.java | 23 +++++ .../cause2/persistence/dao/IFooDao.java | 8 ++ .../cause2/persistence/model/Foo.java | 83 +++++++++++++++++++ .../persistence/service/FooService.java | 27 ++++++ .../persistence/service/IFooService.java | 8 ++ .../spring/Cause2PersistenceConfig.java | 79 ++++++++++++++++++ ...Cause2MappingExceptionIntegrationTest.java | 29 +++++++ 7 files changed, 257 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java new file mode 100644 index 000000000000..4454c3f06386 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java @@ -0,0 +1,23 @@ +package org.baeldung.ex.mappingexception.cause2.persistence.dao; + +import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import org.baeldung.persistence.common.AbstractHibernateDao; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractHibernateDao implements IFooDao { + + @Autowired + private SessionFactory sessionFactory; + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..17e0822ed60c --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.mappingexception.cause2.persistence.dao; + +import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import org.baeldung.persistence.common.IOperations; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java new file mode 100644 index 000000000000..14f2b2af221b --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package org.baeldung.ex.mappingexception.cause2.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java new file mode 100644 index 000000000000..609b50308032 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java @@ -0,0 +1,27 @@ +package org.baeldung.ex.mappingexception.cause2.persistence.service; + +import org.baeldung.ex.mappingexception.cause2.persistence.dao.IFooDao; +import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import org.baeldung.persistence.common.AbstractService; +import org.baeldung.persistence.common.IOperations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService extends AbstractService implements IFooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java new file mode 100644 index 000000000000..b569dd2aa4fe --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package org.baeldung.ex.mappingexception.cause2.persistence.service; + +import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import org.baeldung.persistence.common.IOperations; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java new file mode 100644 index 000000000000..91226ea615e8 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java @@ -0,0 +1,79 @@ +package org.baeldung.ex.mappingexception.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.ex.mappingexception.cause2.persistence" }) +public class Cause2PersistenceConfig { + + @Autowired + private Environment env; + + public Cause2PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model2" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java new file mode 100644 index 000000000000..c040686fba54 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java @@ -0,0 +1,29 @@ +package org.baeldung.ex.mappingexception; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import org.baeldung.ex.mappingexception.cause2.persistence.service.IFooService; +import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause2PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause2MappingExceptionIntegrationTest { + + @Autowired + private IFooService fooApi; + + // tests + + @Test + public final void givenEntityIsPersisted_thenException() { + fooApi.create(new Foo(randomAlphabetic(6))); + } + +} From 14c76d379adce6ed0bc9d6d55584500b33b4d0bc Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 23:21:38 +0300 Subject: [PATCH 267/796] cleanup of examples --- .../cause1/persistence/dao/FooDao.java | 23 ---------------- .../cause1/persistence/dao/IFooDao.java | 8 ------ .../persistence/service/FooService.java | 27 ------------------- .../persistence/service/IFooService.java | 8 ------ .../cause2/persistence/dao/FooDao.java | 23 ---------------- .../cause2/persistence/dao/IFooDao.java | 8 ------ .../persistence/service/FooService.java | 27 ------------------- .../persistence/service/IFooService.java | 8 ------ ...Cause1MappingExceptionIntegrationTest.java | 8 +++--- ...Cause2MappingExceptionIntegrationTest.java | 8 +++--- 10 files changed, 10 insertions(+), 138 deletions(-) delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java delete mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java deleted file mode 100644 index 2755be8445c9..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.ex.mappingexception.cause1.persistence.dao; - -import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.persistence.common.AbstractHibernateDao; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao extends AbstractHibernateDao implements IFooDao { - - @Autowired - private SessionFactory sessionFactory; - - public FooDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java deleted file mode 100644 index 8519858eca6d..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.mappingexception.cause1.persistence.dao; - -import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.persistence.common.IOperations; - -public interface IFooDao extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java deleted file mode 100644 index 7054b721cfec..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.baeldung.ex.mappingexception.cause1.persistence.service; - -import org.baeldung.ex.mappingexception.cause1.persistence.dao.IFooDao; -import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.persistence.common.AbstractService; -import org.baeldung.persistence.common.IOperations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class FooService extends AbstractService implements IFooService { - - @Autowired - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java deleted file mode 100644 index 5d7015cbc2b7..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.mappingexception.cause1.persistence.service; - -import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.persistence.common.IOperations; - -public interface IFooService extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java deleted file mode 100644 index 4454c3f06386..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/FooDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.ex.mappingexception.cause2.persistence.dao; - -import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.persistence.common.AbstractHibernateDao; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao extends AbstractHibernateDao implements IFooDao { - - @Autowired - private SessionFactory sessionFactory; - - public FooDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java deleted file mode 100644 index 17e0822ed60c..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/dao/IFooDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.mappingexception.cause2.persistence.dao; - -import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.persistence.common.IOperations; - -public interface IFooDao extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java deleted file mode 100644 index 609b50308032..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/FooService.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.baeldung.ex.mappingexception.cause2.persistence.service; - -import org.baeldung.ex.mappingexception.cause2.persistence.dao.IFooDao; -import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.persistence.common.AbstractService; -import org.baeldung.persistence.common.IOperations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class FooService extends AbstractService implements IFooService { - - @Autowired - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java deleted file mode 100644 index b569dd2aa4fe..000000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/service/IFooService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.ex.mappingexception.cause2.persistence.service; - -import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.persistence.common.IOperations; - -public interface IFooService extends IOperations { - // -} diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java index 46f551c65259..98c52914b24b 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java @@ -3,27 +3,29 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.ex.mappingexception.cause1.persistence.service.IFooService; import org.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; +import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { Cause1PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause1MappingExceptionIntegrationTest { @Autowired - private IFooService fooApi; + private SessionFactory sessionFactory; // tests @Test + @Transactional public final void givenEntityIsPersisted_thenException() { - fooApi.create(new Foo(randomAlphabetic(6))); + sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6))); } } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java index c040686fba54..4bb224dfa78f 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java @@ -3,27 +3,29 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.ex.mappingexception.cause2.persistence.service.IFooService; import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; +import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { Cause2PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause2MappingExceptionIntegrationTest { @Autowired - private IFooService fooApi; + private SessionFactory sessionFactory; // tests @Test + @Transactional public final void givenEntityIsPersisted_thenException() { - fooApi.create(new Foo(randomAlphabetic(6))); + sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6))); } } From 62292a5e5a2bb1336dfb2bf1758ae25695a75dd0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 23:23:33 +0300 Subject: [PATCH 268/796] general example cleanup --- .../cause1/persistence/model/Foo.java | 52 ------------------- .../cause2/persistence/model/Foo.java | 52 ------------------- ...Cause1MappingExceptionIntegrationTest.java | 7 ++- ...Cause2MappingExceptionIntegrationTest.java | 7 ++- 4 files changed, 6 insertions(+), 112 deletions(-) diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java index dd094076027e..001c14d6d6e8 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java @@ -2,7 +2,6 @@ import java.io.Serializable; -import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -13,19 +12,10 @@ public class Foo implements Serializable { @GeneratedValue(strategy = GenerationType.AUTO) private long id; - @Column(nullable = false) - private String name; - public Foo() { super(); } - public Foo(final String name) { - super(); - - this.name = name; - } - // API public long getId() { @@ -36,46 +26,4 @@ public void setId(final long id) { this.id = id; } - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Foo other = (Foo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Foo [name=").append(name).append("]"); - return builder.toString(); - } - } diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java index 14f2b2af221b..fa1200f71030 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java @@ -2,7 +2,6 @@ import java.io.Serializable; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -15,19 +14,10 @@ public class Foo implements Serializable { @GeneratedValue(strategy = GenerationType.AUTO) private long id; - @Column(nullable = false) - private String name; - public Foo() { super(); } - public Foo(final String name) { - super(); - - this.name = name; - } - // API public long getId() { @@ -38,46 +28,4 @@ public void setId(final long id) { this.id = id; } - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Foo other = (Foo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Foo [name=").append(name).append("]"); - return builder.toString(); - } - } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java index 98c52914b24b..671b0a473ed4 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionIntegrationTest.java @@ -1,9 +1,8 @@ package org.baeldung.ex.mappingexception; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; import org.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; +import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,10 +21,10 @@ public class Cause1MappingExceptionIntegrationTest { // tests - @Test + @Test(expected = MappingException.class) @Transactional public final void givenEntityIsPersisted_thenException() { - sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6))); + sessionFactory.getCurrentSession().saveOrUpdate(new Foo()); } } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java index 4bb224dfa78f..c473dfeb1511 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java @@ -1,9 +1,8 @@ package org.baeldung.ex.mappingexception; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; +import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,10 +21,10 @@ public class Cause2MappingExceptionIntegrationTest { // tests - @Test + @Test(expected = MappingException.class) @Transactional public final void givenEntityIsPersisted_thenException() { - sessionFactory.getCurrentSession().saveOrUpdate(new Foo(randomAlphabetic(6))); + sessionFactory.getCurrentSession().saveOrUpdate(new Foo()); } } From 380e14bff01bf55d1f7197ff8f0c233dcdfe339f Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 Aug 2013 23:39:29 +0300 Subject: [PATCH 269/796] further persistence work --- .../cause1/persistence/model/Foo.java | 2 + .../cause3/persistence/model/Foo.java | 31 +++++++ .../spring/Cause3PersistenceConfig.java | 80 +++++++++++++++++++ ...Cause3MappingExceptionIntegrationTest.java | 30 +++++++ 4 files changed, 143 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java index 001c14d6d6e8..e7db6747bc91 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java @@ -2,10 +2,12 @@ import java.io.Serializable; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +@Entity public class Foo implements Serializable { @Id diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java new file mode 100644 index 000000000000..243196786cdf --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java @@ -0,0 +1,31 @@ +package org.baeldung.ex.mappingexception.cause3.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + public Foo() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java new file mode 100644 index 000000000000..91755f9d6b6d --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java @@ -0,0 +1,80 @@ +package org.baeldung.ex.mappingexception.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.baeldung.ex.mappingexception.cause3.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.orm.hibernate4.HibernateTransactionManager; +import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.ex.mappingexception.cause2.persistence" }) +public class Cause3PersistenceConfig { + + @Autowired + private Environment env; + + public Cause3PersistenceConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public HibernateTransactionManager transactionManager() { + final HibernateTransactionManager txManager = new HibernateTransactionManager(); + txManager.setSessionFactory(sessionFactory().getObject()); + + return txManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties hibernateProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } +} \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionIntegrationTest.java new file mode 100644 index 000000000000..d6abe7db4fdc --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionIntegrationTest.java @@ -0,0 +1,30 @@ +package org.baeldung.ex.mappingexception; + +import org.baeldung.ex.mappingexception.cause3.persistence.model.Foo; +import org.baeldung.ex.mappingexception.spring.Cause3PersistenceConfig; +import org.hibernate.MappingException; +import org.hibernate.SessionFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.transaction.annotation.Transactional; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Cause3PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class Cause3MappingExceptionIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + // tests + + @Test(expected = MappingException.class) + @Transactional + public final void givenEntityIsPersisted_thenException() { + sessionFactory.getCurrentSession().saveOrUpdate(new Foo()); + } + +} From f9712c2db4c2e1b7ddfd91dc44a753c210e1e9a1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 13 Aug 2013 01:11:55 +0300 Subject: [PATCH 270/796] persistence work --- .../ex/mappingexception/cause1/persistence/model/Foo.java | 2 -- .../ex/mappingexception/spring/Cause2PersistenceConfig.java | 4 +++- .../ex/mappingexception/spring/Cause3PersistenceConfig.java | 4 +++- .../Cause2MappingExceptionIntegrationTest.java | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java index e7db6747bc91..001c14d6d6e8 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java @@ -2,12 +2,10 @@ import java.io.Serializable; -import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -@Entity public class Foo implements Serializable { @Id diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java index 91226ea615e8..92d5f906a8e9 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java @@ -35,9 +35,11 @@ public Cause2PersistenceConfig() { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model2" }); sessionFactory.setHibernateProperties(hibernateProperties()); + // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" }); + // sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); + return sessionFactory; } diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java index 91755f9d6b6d..241c6c315ded 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java @@ -36,9 +36,11 @@ public Cause3PersistenceConfig() { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); sessionFactory.setHibernateProperties(hibernateProperties()); + // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" }); + sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); + return sessionFactory; } diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java index c473dfeb1511..eae5ebd9a273 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionIntegrationTest.java @@ -2,7 +2,6 @@ import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; -import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,7 +20,8 @@ public class Cause2MappingExceptionIntegrationTest { // tests - @Test(expected = MappingException.class) + // @Test(expected = MappingException.class) + @Test @Transactional public final void givenEntityIsPersisted_thenException() { sessionFactory.getCurrentSession().saveOrUpdate(new Foo()); From 2fcc1187e24edc7c315421e141cd3925ed0444c6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 13 Aug 2013 02:13:47 +0300 Subject: [PATCH 271/796] scrape test --- spring-security-rest-custom/pom.xml | 24 ++++ .../java/org/baeldung/live/CrawlTest.java | 131 ++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index b3bf977745d6..8305065793d7 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -9,6 +9,30 @@ + + xml-apis + xml-apis + 1.4.01 + + + + xalan + xalan + 2.7.1 + + + + net.sourceforge.nekohtml + nekohtml + 1.9.18 + + + + net.sourceforge.htmlcleaner + htmlcleaner + 2.6 + + diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java b/spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java new file mode 100644 index 000000000000..ba7e92db5c85 --- /dev/null +++ b/spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java @@ -0,0 +1,131 @@ +package org.baeldung.live; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.apache.http.util.EntityUtils; +import org.cyberneko.html.parsers.DOMParser; +import org.htmlcleaner.CleanerProperties; +import org.htmlcleaner.HtmlCleaner; +import org.htmlcleaner.TagNode; +import org.htmlcleaner.XPatherException; +import org.junit.Before; +import org.junit.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +public class CrawlTest { + + private DefaultHttpClient client; + + // fixtures + + @Before + public final void before() { + final HttpParams httpParameters = new BasicHttpParams(); + client = new DefaultHttpClient(httpParameters); + } + + // tests + + @Test + public final void when_then() throws ClientProtocolException, IOException, XPathExpressionException, SAXException, ParserConfigurationException { + final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; + final String xpathEx = ".//*[@id='search_results_table']/tbody/tr/td[1]"; + + HttpGet request = null; + HttpEntity httpEntity = null; + InputStream entityContentStream = null; + + try { + request = new HttpGet(url); + final HttpResponse httpResponse = client.execute(request); + + httpEntity = httpResponse.getEntity(); + entityContentStream = httpEntity.getContent(); + + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder builder = factory.newDocumentBuilder(); + final Document doc = builder.parse(entityContentStream); + + final XPathFactory xPathfactory = XPathFactory.newInstance(); + final XPath xpath = xPathfactory.newXPath(); + final XPathExpression expr = xpath.compile(xpathEx); + final Object evaluated = expr.evaluate(doc, XPathConstants.STRING); + System.out.println(evaluated); + } catch (final RuntimeException runEx) { + runEx.printStackTrace(); + } finally { + if (request != null) { + request.releaseConnection(); + } + if (entityContentStream != null) { + entityContentStream.close(); + } + if (httpEntity != null) { + EntityUtils.consume(httpEntity); + } + } + } + + // http://htmlcleaner.sourceforge.net/parameters.php + @SuppressWarnings("unused") + @Test + public final void givenCleaningWithHtmlCleaner_whenPageIsRetrieved_thenContentCanBeExtracted() throws XPatherException, MalformedURLException, IOException { + final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; + final String xpathEx1 = ".//*[@id='search_results_table']/tbody/tr/td[1]/b/a/text()"; + final String xpathEx2 = ".//*[@id='search_results_table']/tbody/tr"; + + final CleanerProperties props = new CleanerProperties(); + // set some properties to non-default values + props.setAdvancedXmlEscape(true); + // props.setOmitComments(true); + + // do parsing + final TagNode tagNode = new HtmlCleaner(props).clean(new URL(url)); + final Object[] evaluateXPath = tagNode.evaluateXPath(xpathEx2); + final Object ex = evaluateXPath[7]; + + System.out.println(ex); + // System.out.println(Arrays.toString(evaluateXPath)); + // new PrettyXmlSerializer(props).writeToStream(tagNode, System.out); + } + + @SuppressWarnings("unused") + @Test + public final void givenCleaningWithNeko_whenPageIsRetrieved_thenContentCanBeExtracted() throws XPatherException, MalformedURLException, IOException, XPathExpressionException, SAXException { + final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; + final String xpathEx1 = ".//*[@id='search_results_table']/tbody/tr/td[1]/b/a/text()"; + final String xpathEx2 = ".//*[@id='search_results_table']/tbody/tr"; + + final DOMParser parser = new DOMParser(); + parser.setFeature("http://xml.org/sax/features/namespaces", false); + parser.parse(url); + final Document document = parser.getDocument(); + + final XPathFactory xpf = XPathFactory.newInstance(); + final XPath xpath = xpf.newXPath(); + final Object evaluate = xpath.evaluate(xpathEx2, document); + + System.out.println(evaluate); + } + +} From ec9b16694e69791e09453bcec4f4785f3d2e05bf Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 13 Aug 2013 13:01:06 +0300 Subject: [PATCH 272/796] new persistence work --- .../cause4/persistence/model/Foo.java | 31 +++++++++++++++ .../main/resources/hibernate-mysql.properties | 8 ++++ ...Cause4MappingExceptionIntegrationTest.java | 39 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java create mode 100644 spring-exceptions/src/main/resources/hibernate-mysql.properties create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java new file mode 100644 index 000000000000..11e71edf01d9 --- /dev/null +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java @@ -0,0 +1,31 @@ +package org.baeldung.ex.mappingexception.cause4.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + public Foo() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + +} diff --git a/spring-exceptions/src/main/resources/hibernate-mysql.properties b/spring-exceptions/src/main/resources/hibernate-mysql.properties new file mode 100644 index 000000000000..5e8c7be1411e --- /dev/null +++ b/spring-exceptions/src/main/resources/hibernate-mysql.properties @@ -0,0 +1,8 @@ +hibernate.connection.username=tutorialuser +hibernate.connection.password=tutorialmy5ql +hibernate.connection.driver_class=com.mysql.jdbc.Driver +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +#hibernate.connection.datasource=jdbc:mysql://localhost:3306/spring_hibernate4_exceptions?createDatabaseIfNotExist=true +hibernate.connection.url=jdbc:mysql://localhost:3306/spring_hibernate4_exceptions?createDatabaseIfNotExist=true +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java new file mode 100644 index 000000000000..37e624b16c42 --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java @@ -0,0 +1,39 @@ +package org.baeldung.ex.mappingexception; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.baeldung.ex.mappingexception.cause4.persistence.model.Foo; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; +import org.junit.Test; + +public class Cause4MappingExceptionIntegrationTest { + + // tests + + @Test + public final void givenEntityIsPersisted_thenException() throws IOException { + final Configuration configuration = new Configuration(); + + final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("hibernate-mysql.properties"); + final Properties hibernateProperties = new Properties(); + hibernateProperties.load(inputStream); + configuration.setProperties(hibernateProperties); + + configuration.addAnnotatedClass(Foo.class); + + final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); + final SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); + + final Session session = sessionFactory.openSession(); + session.beginTransaction(); + session.saveOrUpdate(new Foo()); + session.getTransaction().commit(); + } + +} From 2c1e9789a08b8a7fe1de10e77197b71081133eb3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 13 Aug 2013 13:34:58 +0300 Subject: [PATCH 273/796] persistence workg --- .../main/resources/hibernate-mysql.properties | 3 +-- .../Cause4MappingExceptionIntegrationTest.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spring-exceptions/src/main/resources/hibernate-mysql.properties b/spring-exceptions/src/main/resources/hibernate-mysql.properties index 5e8c7be1411e..49ca7fb3d1f6 100644 --- a/spring-exceptions/src/main/resources/hibernate-mysql.properties +++ b/spring-exceptions/src/main/resources/hibernate-mysql.properties @@ -2,7 +2,6 @@ hibernate.connection.username=tutorialuser hibernate.connection.password=tutorialmy5ql hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -#hibernate.connection.datasource=jdbc:mysql://localhost:3306/spring_hibernate4_exceptions?createDatabaseIfNotExist=true hibernate.connection.url=jdbc:mysql://localhost:3306/spring_hibernate4_exceptions?createDatabaseIfNotExist=true hibernate.show_sql=false -hibernate.hbm2ddl.auto=create +hibernate.hbm2ddl.auto=create \ No newline at end of file diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java index 37e624b16c42..ea24a1342e36 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java @@ -18,8 +18,16 @@ public class Cause4MappingExceptionIntegrationTest { @Test public final void givenEntityIsPersisted_thenException() throws IOException { - final Configuration configuration = new Configuration(); + final SessionFactory sessionFactory = configureSessionFactory(); + + final Session session = sessionFactory.openSession(); + session.beginTransaction(); + session.saveOrUpdate(new Foo()); + session.getTransaction().commit(); + } + private final SessionFactory configureSessionFactory() throws IOException { + final Configuration configuration = new Configuration(); final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("hibernate-mysql.properties"); final Properties hibernateProperties = new Properties(); hibernateProperties.load(inputStream); @@ -29,11 +37,7 @@ public final void givenEntityIsPersisted_thenException() throws IOException { final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); final SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); - - final Session session = sessionFactory.openSession(); - session.beginTransaction(); - session.saveOrUpdate(new Foo()); - session.getTransaction().commit(); + return sessionFactory; } } From 63332746b4a4ee6f5d86bad15ef0ea2623754eaf Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 15 Aug 2013 11:26:45 +0300 Subject: [PATCH 274/796] initial experiments project --- experiments/.classpath | 32 ++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + experiments/.gitignore | 13 + experiments/.project | 42 +++ experiments/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 11 + ....eclipse.wst.common.project.facet.core.xml | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 + .../org.eclipse.wst.ws.service.policy.prefs | 2 + experiments/.springBeans | 14 + experiments/README.md | 7 + experiments/pom.xml | 282 ++++++++++++++++++ experiments/src/main/resources/logback.xml | 20 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + experiments/src/main/webapp/WEB-INF/web.xml | 50 ++++ .../java/org/baeldung/live/CrawlTest.java | 0 experiments/src/test/resources/.gitignore | 13 + spring-security-rest-custom/pom.xml | 24 -- 24 files changed, 681 insertions(+), 24 deletions(-) create mode 100644 experiments/.classpath create mode 100644 experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 experiments/.gitignore create mode 100644 experiments/.project create mode 100644 experiments/.settings/.jsdtscope create mode 100644 experiments/.settings/org.eclipse.jdt.core.prefs create mode 100644 experiments/.settings/org.eclipse.jdt.ui.prefs create mode 100644 experiments/.settings/org.eclipse.m2e.core.prefs create mode 100644 experiments/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 experiments/.settings/org.eclipse.wst.common.component create mode 100644 experiments/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 experiments/.settings/org.eclipse.wst.validation.prefs create mode 100644 experiments/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 experiments/.springBeans create mode 100644 experiments/README.md create mode 100644 experiments/pom.xml create mode 100644 experiments/src/main/resources/logback.xml create mode 100644 experiments/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 experiments/src/main/webapp/WEB-INF/web.xml rename {spring-security-rest-custom => experiments}/src/test/java/org/baeldung/live/CrawlTest.java (100%) create mode 100644 experiments/src/test/resources/.gitignore diff --git a/experiments/.classpath b/experiments/.classpath new file mode 100644 index 000000000000..5b66010de692 --- /dev/null +++ b/experiments/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/experiments/.gitignore b/experiments/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/experiments/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/experiments/.project b/experiments/.project new file mode 100644 index 000000000000..13c876f10671 --- /dev/null +++ b/experiments/.project @@ -0,0 +1,42 @@ + + + experiments + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/experiments/.settings/.jsdtscope b/experiments/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/experiments/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/experiments/.settings/org.eclipse.jdt.core.prefs b/experiments/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..df8135651462 --- /dev/null +++ b/experiments/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/experiments/.settings/org.eclipse.jdt.ui.prefs b/experiments/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/experiments/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/experiments/.settings/org.eclipse.m2e.core.prefs b/experiments/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/experiments/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/experiments/.settings/org.eclipse.m2e.wtp.prefs b/experiments/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/experiments/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/experiments/.settings/org.eclipse.wst.common.component b/experiments/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..4a077146f273 --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml b/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..b46bc511b943 --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/experiments/.settings/org.eclipse.wst.validation.prefs b/experiments/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs b/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/experiments/.springBeans b/experiments/.springBeans new file mode 100644 index 000000000000..d11fb034bdc0 --- /dev/null +++ b/experiments/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/experiments/README.md b/experiments/README.md new file mode 100644 index 000000000000..11522e362f47 --- /dev/null +++ b/experiments/README.md @@ -0,0 +1,7 @@ +========= + +## Spring Security for REST Example Project + + +### Relevant Articles: +- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file diff --git a/experiments/pom.xml b/experiments/pom.xml new file mode 100644 index 000000000000..fa978f6a63a5 --- /dev/null +++ b/experiments/pom.xml @@ -0,0 +1,282 @@ + + 4.0.0 + org.baeldung + spring-security-rest + 0.1-SNAPSHOT + + spring-security-rest + war + + + + + + + xml-apis + xml-apis + 1.4.01 + + + + xalan + xalan + 2.7.1 + + + + net.sourceforge.nekohtml + nekohtml + 1.9.18 + + + + net.sourceforge.htmlcleaner + htmlcleaner + 2.6 + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.3.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.15 + + + \ No newline at end of file diff --git a/experiments/src/main/resources/logback.xml b/experiments/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/experiments/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/src/main/webapp/WEB-INF/api-servlet.xml b/experiments/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/experiments/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/experiments/src/main/webapp/WEB-INF/web.xml b/experiments/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..fe62026bc7d6 --- /dev/null +++ b/experiments/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + + + + \ No newline at end of file diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java b/experiments/src/test/java/org/baeldung/live/CrawlTest.java similarity index 100% rename from spring-security-rest-custom/src/test/java/org/baeldung/live/CrawlTest.java rename to experiments/src/test/java/org/baeldung/live/CrawlTest.java diff --git a/experiments/src/test/resources/.gitignore b/experiments/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/experiments/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 8305065793d7..b3bf977745d6 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -9,30 +9,6 @@ - - xml-apis - xml-apis - 1.4.01 - - - - xalan - xalan - 2.7.1 - - - - net.sourceforge.nekohtml - nekohtml - 1.9.18 - - - - net.sourceforge.htmlcleaner - htmlcleaner - 2.6 - - From 8b6a612e6c716a997e56d4c14f84f7a47e60712c Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 15 Aug 2013 11:27:44 +0300 Subject: [PATCH 275/796] cleanup work --- experiments/.settings/org.eclipse.wst.common.component | 6 +++--- experiments/pom.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/experiments/.settings/org.eclipse.wst.common.component b/experiments/.settings/org.eclipse.wst.common.component index 4a077146f273..f03553e4f51d 100644 --- a/experiments/.settings/org.eclipse.wst.common.component +++ b/experiments/.settings/org.eclipse.wst.common.component @@ -1,11 +1,11 @@ - + - - + + diff --git a/experiments/pom.xml b/experiments/pom.xml index fa978f6a63a5..e4a9ba6779ab 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-rest + experiments 0.1-SNAPSHOT - spring-security-rest + experiments war @@ -194,7 +194,7 @@ - spring-security-rest + experiments src/main/resources From e412b13818ba6aea0188b9622d3db78e069b94d9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 19 Aug 2013 21:34:24 +0300 Subject: [PATCH 276/796] hibernate and other maven upgrades --- experiments/pom.xml | 4 ++-- spring-all/pom.xml | 4 ++-- spring-exceptions/pom.xml | 2 +- spring-hibernate3/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- .../java/org/baeldung/persistence/dao/impl/ChildDao.java | 5 ----- .../main/java/org/baeldung/persistence/dao/impl/FooDao.java | 5 ----- .../java/org/baeldung/persistence/dao/impl/ParentDao.java | 5 ----- spring-jpa/pom.xml | 6 +++--- spring-mvc-java/pom.xml | 4 ++-- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 4 ++-- spring-security-basic-auth/pom.xml | 4 ++-- spring-security-mvc-custom/pom.xml | 4 ++-- spring-security-mvc-digest-auth/pom.xml | 4 ++-- spring-security-mvc-login/pom.xml | 4 ++-- spring-security-mvc-session/pom.xml | 4 ++-- spring-security-rest-basic-auth/pom.xml | 4 ++-- spring-security-rest-custom/pom.xml | 4 ++-- spring-security-rest-digest-auth/pom.xml | 4 ++-- spring-security-rest-full/pom.xml | 6 +++--- spring-security-rest/pom.xml | 4 ++-- 23 files changed, 37 insertions(+), 52 deletions(-) diff --git a/experiments/pom.xml b/experiments/pom.xml index e4a9ba6779ab..f92ef16c8d52 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -249,7 +249,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -276,7 +276,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 3b04b609e678..12ac684ffdd1 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -188,7 +188,7 @@ 1.2 - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -215,7 +215,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 002ee4c25816..3e4f4f1241fb 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -227,7 +227,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 6cd53b23c72d..9cb4b4d01a38 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -191,7 +191,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index e445098b1c3f..6c9d64c5191e 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -199,7 +199,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java index d9c8fdceecdf..017362bd1411 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java @@ -3,16 +3,11 @@ import org.baeldung.persistence.dao.IChildDao; import org.baeldung.persistence.dao.common.AbstractHibernateDao; import org.baeldung.persistence.model.Child; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @Repository public class ChildDao extends AbstractHibernateDao implements IChildDao { - @Autowired - private SessionFactory sessionFactory; - public ChildDao() { super(); diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java index 4441215a94d0..b8360160dac4 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java @@ -3,16 +3,11 @@ import org.baeldung.persistence.dao.IFooDao; import org.baeldung.persistence.dao.common.AbstractHibernateDao; import org.baeldung.persistence.model.Foo; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @Repository public class FooDao extends AbstractHibernateDao implements IFooDao { - @Autowired - private SessionFactory sessionFactory; - public FooDao() { super(); diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java index 003ec627411a..a93f1c39d591 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java @@ -3,16 +3,11 @@ import org.baeldung.persistence.dao.IParentDao; import org.baeldung.persistence.dao.common.AbstractHibernateDao; import org.baeldung.persistence.model.Parent; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @Repository public class ParentDao extends AbstractHibernateDao implements IParentDao { - @Autowired - private SessionFactory sessionFactory; - public ParentDao() { super(); diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index d9109ae593e0..65c6bace8779 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -38,7 +38,7 @@ org.javassist javassist - 3.17.1-GA + 3.18.0-GA mysql @@ -164,7 +164,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -191,7 +191,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index a7fe6a3c5285..038e70b84590 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -125,7 +125,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -152,7 +152,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 5235eb422e50..ea0f92cdfd1c 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -129,7 +129,7 @@ 1.4.3 - 2.15 + 2.16 2.4 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 4dbe0120ebf7..eb390e738a15 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -120,7 +120,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 5d55c5ea8a51..d4c58cd7bbe0 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -125,7 +125,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -152,7 +152,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 616ce4140c22..e389553aad5f 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -183,7 +183,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -210,7 +210,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 8678b91ec8ef..73e3ea9cee1a 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -187,7 +187,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -214,7 +214,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 9cb06978f6d3..300825ca4428 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -183,7 +183,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -210,7 +210,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 7504e33c7617..1b788afa414d 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -179,7 +179,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -206,7 +206,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 65df553ddf15..a04a7f0da4b2 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -187,7 +187,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -214,7 +214,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 8cf15f656273..0ee8056b0577 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -284,7 +284,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -312,7 +312,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index b3bf977745d6..880fb314e7b1 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -239,7 +239,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -266,7 +266,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 5b8cc88dc7ff..1c472b6016c1 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -272,7 +272,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -300,7 +300,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 1072e76c720a..1d3368c456ed 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -92,7 +92,7 @@ org.javassist javassist - 3.17.1-GA + 3.18.0-GA mysql @@ -220,7 +220,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 1.3.2.RELEASE @@ -252,7 +252,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index b6962abd24bf..3a2b884cb77f 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -196,7 +196,7 @@ 3.1.4.RELEASE - 4.2.3.Final + 4.2.4.Final 5.1.26 @@ -223,7 +223,7 @@ 1.4.3 - 2.15 + 2.16 \ No newline at end of file From 77b825e2fb80a6814784d371cae18024a19aac12 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 19 Aug 2013 21:39:35 +0300 Subject: [PATCH 277/796] minor eclipse cleanup --- spring-hibernate3/.classpath | 10 +++++++--- spring-hibernate3/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-hibernate4/.classpath | 3 +-- spring-hibernate4/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-mvc-java/.classpath | 3 +-- spring-mvc-java/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-security-basic-auth/.classpath | 9 +++++++-- .../.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-security-rest/.classpath | 9 +++++++-- .../.settings/org.eclipse.jdt.core.prefs | 6 +++--- .../.settings/org.eclipse.wst.common.component | 1 + 11 files changed, 39 insertions(+), 26 deletions(-) diff --git a/spring-hibernate3/.classpath b/spring-hibernate3/.classpath index 7e214d86c6e2..75e85b7b7568 100644 --- a/spring-hibernate3/.classpath +++ b/spring-hibernate3/.classpath @@ -6,7 +6,12 @@ - + + + + + + @@ -17,7 +22,7 @@ - + @@ -25,7 +30,6 @@ - diff --git a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs index 33f3a5c234c0..ff974c8bc17f 100644 --- a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index ca257cf1f962..f53973c735da 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -22,7 +22,7 @@ - + @@ -30,7 +30,6 @@ - diff --git a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs index c201ee1f7a18..1bc227613ede 100644 --- a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-mvc-java/.classpath b/spring-mvc-java/.classpath index eed10d8a8b04..75e85b7b7568 100644 --- a/spring-mvc-java/.classpath +++ b/spring-mvc-java/.classpath @@ -22,7 +22,7 @@ - + @@ -30,7 +30,6 @@ - diff --git a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..65c5cef5582b 100644 --- a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs @@ -5,8 +5,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -88,4 +88,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-security-basic-auth/.classpath b/spring-security-basic-auth/.classpath index 5dea19367768..f53973c735da 100644 --- a/spring-security-basic-auth/.classpath +++ b/spring-security-basic-auth/.classpath @@ -16,7 +16,13 @@ - + + + + + + + @@ -24,7 +30,6 @@ - diff --git a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs index df8135651462..ed5f6c50ecbb 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-security-rest/.classpath b/spring-security-rest/.classpath index 5dea19367768..f53973c735da 100644 --- a/spring-security-rest/.classpath +++ b/spring-security-rest/.classpath @@ -16,7 +16,13 @@ - + + + + + + + @@ -24,7 +30,6 @@ - diff --git a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs index df8135651462..ed5f6c50ecbb 100644 --- a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-security-rest/.settings/org.eclipse.wst.common.component b/spring-security-rest/.settings/org.eclipse.wst.common.component index 6782a0c5c740..4a077146f273 100644 --- a/spring-security-rest/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest/.settings/org.eclipse.wst.common.component @@ -4,6 +4,7 @@ + From 97fb2da70b84806a83c85eacd985f30b97142953 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 19 Aug 2013 22:33:24 +0300 Subject: [PATCH 278/796] eclipse cleanup --- spring-hibernate3/.classpath | 2 +- spring-hibernate3/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-hibernate4/.classpath | 2 +- spring-hibernate4/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-mvc-java/.classpath | 2 +- spring-mvc-java/.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-security-basic-auth/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +++--- spring-security-rest/.classpath | 6 +++--- spring-security-rest/.project | 6 ++++++ spring-security-rest/.settings/.jsdtscope | 7 +++++++ spring-security-rest/.settings/org.eclipse.jdt.core.prefs | 6 +++--- .../.settings/org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.common.project.facet.core.xml | 3 ++- 14 files changed, 37 insertions(+), 24 deletions(-) diff --git a/spring-hibernate3/.classpath b/spring-hibernate3/.classpath index 75e85b7b7568..efc51b414b0b 100644 --- a/spring-hibernate3/.classpath +++ b/spring-hibernate3/.classpath @@ -22,7 +22,7 @@ - + diff --git a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs index ff974c8bc17f..33f3a5c234c0 100644 --- a/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate3/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index f53973c735da..15b58ba46e03 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -22,7 +22,7 @@ - + diff --git a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs index 1bc227613ede..c201ee1f7a18 100644 --- a/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs +++ b/spring-hibernate4/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc-java/.classpath b/spring-mvc-java/.classpath index 75e85b7b7568..efc51b414b0b 100644 --- a/spring-mvc-java/.classpath +++ b/spring-mvc-java/.classpath @@ -22,7 +22,7 @@ - + diff --git a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs index 65c5cef5582b..0924ed68cff2 100644 --- a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs @@ -5,8 +5,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -88,4 +88,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-basic-auth/.classpath b/spring-security-basic-auth/.classpath index f53973c735da..15b58ba46e03 100644 --- a/spring-security-basic-auth/.classpath +++ b/spring-security-basic-auth/.classpath @@ -22,7 +22,7 @@ - + diff --git a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs index ed5f6c50ecbb..df8135651462 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-basic-auth/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest/.classpath b/spring-security-rest/.classpath index f53973c735da..ee67eca8cf5b 100644 --- a/spring-security-rest/.classpath +++ b/spring-security-rest/.classpath @@ -22,14 +22,14 @@ - + - + - + diff --git a/spring-security-rest/.project b/spring-security-rest/.project index f07f8b2e06b0..9ce15c3fa89a 100644 --- a/spring-security-rest/.project +++ b/spring-security-rest/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.jsdt.core.javascriptValidator + + + org.eclipse.jdt.core.javabuilder @@ -38,5 +43,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature diff --git a/spring-security-rest/.settings/.jsdtscope b/spring-security-rest/.settings/.jsdtscope index 7b3f0c8b9fae..facca273ec49 100644 --- a/spring-security-rest/.settings/.jsdtscope +++ b/spring-security-rest/.settings/.jsdtscope @@ -1,5 +1,12 @@ + + + + + + + diff --git a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs index ed5f6c50ecbb..df8135651462 100644 --- a/spring-security-rest/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-rest/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-security-rest/.settings/org.eclipse.wst.common.component b/spring-security-rest/.settings/org.eclipse.wst.common.component index 4a077146f273..6782a0c5c740 100644 --- a/spring-security-rest/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml index b46bc511b943..38ed74d0399a 100644 --- a/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-security-rest/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,6 @@ - + + From 0d8ef1f4963d8bff2c297254876d94476b4cdf77 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 20 Aug 2013 01:24:25 +0300 Subject: [PATCH 279/796] doc work --- spring-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index b1a4dfcd85fb..c62c4eabed74 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -5,4 +5,4 @@ ### Relevant Articles: - [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) - +- [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) From 4686bf0a0688025d38a6ce124a7a1db0ad2909bd Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 27 Aug 2013 00:01:20 +0300 Subject: [PATCH 280/796] fixing the redirect strategy possible call --- .../MySavedRequestAwareAuthenticationSuccessHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java index 698052fa2b00..f4b8e7f5ac32 100644 --- a/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java +++ b/spring-security-rest/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -22,15 +22,13 @@ public void onAuthenticationSuccess(final HttpServletRequest request, final Http final SavedRequest savedRequest = requestCache.getRequest(request, response); if (savedRequest == null) { - super.onAuthenticationSuccess(request, response, authentication); - + clearAuthenticationAttributes(request); return; } final String targetUrlParameter = getTargetUrlParameter(); if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { requestCache.removeRequest(request, response); - super.onAuthenticationSuccess(request, response, authentication); - + clearAuthenticationAttributes(request); return; } From d003094f89def8d5d81eb0c154901d2084b729a3 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 10 Sep 2013 16:31:41 +0300 Subject: [PATCH 281/796] change in project structure --- spring-security-basic-auth/.project | 2 +- .../org.eclipse.wst.common.component | 6 +- .../src/main/webapp/WEB-INF/web.xml | 81 ++++++++----------- .../src/main/webapp/WEB-INF/web.xml | 72 ++++++++++------- 4 files changed, 79 insertions(+), 82 deletions(-) diff --git a/spring-security-basic-auth/.project b/spring-security-basic-auth/.project index 74e667d477a1..91261032076a 100644 --- a/spring-security-basic-auth/.project +++ b/spring-security-basic-auth/.project @@ -1,6 +1,6 @@ - spring-security-basic-auth + spring-security-mvc-basic-auth diff --git a/spring-security-basic-auth/.settings/org.eclipse.wst.common.component b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component index 83a7bf94e7a2..9a8276c85bce 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.wst.common.component +++ b/spring-security-basic-auth/.settings/org.eclipse.wst.common.component @@ -1,10 +1,10 @@ - + - - + + diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index 461f32bde524..0d08bdb9b9a9 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -1,52 +1,37 @@ - - - Spring Security Basic Auth Application - - - - contextClass - + + Spring Security Basic Auth Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - index.html - - + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + index.html + \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml index 712c84acdfd5..1ab8806632b2 100644 --- a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -1,34 +1,46 @@ - - Spring Security Custom Application - - contextClass - + + + Spring Security Custom Application + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + \ No newline at end of file From 877c49a3d213a46cf83ddf81ec36b6376024e345 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 10 Sep 2013 16:34:32 +0300 Subject: [PATCH 282/796] maven work --- spring-security-basic-auth/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index e389553aad5f..2fc3dc000764 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-basic-auth + spring-security-mvc-basic-auth 0.1-SNAPSHOT - spring-security-basic-auth + spring-security-mvc-basic-auth war @@ -128,7 +128,7 @@ - spring-security-basic-auth + spring-security-mvc-basic-auth src/main/resources From 359b9252fdad2c6867f8f4f100c13d1dd0cfaf48 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 17:34:51 +0300 Subject: [PATCH 283/796] guava exampes --- guava/.classpath | 37 ++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + guava/.gitignore | 13 ++ guava/.project | 43 +++++ guava/.settings/.jsdtscope | 12 ++ guava/.settings/org.eclipse.jdt.core.prefs | 95 +++++++++++ guava/.settings/org.eclipse.jdt.ui.prefs | 55 ++++++ guava/.settings/org.eclipse.m2e.core.prefs | 4 + guava/.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 ++ ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + guava/.springBeans | 14 ++ guava/README.md | 9 + guava/pom.xml | 158 ++++++++++++++++++ .../java/org/baeldung/config/MvcConfig.java | 16 ++ .../baeldung/controller/BarController.java | 46 +++++ .../baeldung/controller/FooController.java | 94 +++++++++++ guava/src/main/resources/logback.xml | 20 +++ guava/src/main/webapp/WEB-INF/api-servlet.xml | 6 + guava/src/main/webapp/WEB-INF/web.xml | 42 +++++ guava/src/test/resources/.gitignore | 13 ++ .../org.eclipse.wst.common.component | 1 - 26 files changed, 720 insertions(+), 1 deletion(-) create mode 100644 guava/.classpath create mode 100644 guava/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 guava/.gitignore create mode 100644 guava/.project create mode 100644 guava/.settings/.jsdtscope create mode 100644 guava/.settings/org.eclipse.jdt.core.prefs create mode 100644 guava/.settings/org.eclipse.jdt.ui.prefs create mode 100644 guava/.settings/org.eclipse.m2e.core.prefs create mode 100644 guava/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 guava/.settings/org.eclipse.wst.common.component create mode 100644 guava/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 guava/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 guava/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 guava/.settings/org.eclipse.wst.validation.prefs create mode 100644 guava/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 guava/.springBeans create mode 100644 guava/README.md create mode 100644 guava/pom.xml create mode 100644 guava/src/main/java/org/baeldung/config/MvcConfig.java create mode 100644 guava/src/main/java/org/baeldung/controller/BarController.java create mode 100644 guava/src/main/java/org/baeldung/controller/FooController.java create mode 100644 guava/src/main/resources/logback.xml create mode 100644 guava/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 guava/src/main/webapp/WEB-INF/web.xml create mode 100644 guava/src/test/resources/.gitignore diff --git a/guava/.classpath b/guava/.classpath new file mode 100644 index 000000000000..eed10d8a8b04 --- /dev/null +++ b/guava/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/guava/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/guava/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/guava/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/guava/.gitignore b/guava/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/guava/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/guava/.project b/guava/.project new file mode 100644 index 000000000000..1d5b25f53ac8 --- /dev/null +++ b/guava/.project @@ -0,0 +1,43 @@ + + + guava + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/guava/.settings/.jsdtscope b/guava/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/guava/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/guava/.settings/org.eclipse.jdt.core.prefs b/guava/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/guava/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/guava/.settings/org.eclipse.jdt.ui.prefs b/guava/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/guava/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/guava/.settings/org.eclipse.m2e.core.prefs b/guava/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/guava/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/guava/.settings/org.eclipse.m2e.wtp.prefs b/guava/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/guava/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/guava/.settings/org.eclipse.wst.common.component b/guava/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..8bb4ef127aa6 --- /dev/null +++ b/guava/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/guava/.settings/org.eclipse.wst.common.project.facet.core.xml b/guava/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/guava/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/guava/.settings/org.eclipse.wst.jsdt.ui.superType.container b/guava/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/guava/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/guava/.settings/org.eclipse.wst.jsdt.ui.superType.name b/guava/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/guava/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/guava/.settings/org.eclipse.wst.validation.prefs b/guava/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/guava/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/guava/.settings/org.eclipse.wst.ws.service.policy.prefs b/guava/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/guava/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/guava/.springBeans b/guava/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/guava/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/guava/README.md b/guava/README.md new file mode 100644 index 000000000000..b979f263ed51 --- /dev/null +++ b/guava/README.md @@ -0,0 +1,9 @@ +========= + +## Spring REST Example Project + + +### Relevant Articles: +- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) + + diff --git a/guava/pom.xml b/guava/pom.xml new file mode 100644 index 000000000000..d4c58cd7bbe0 --- /dev/null +++ b/guava/pom.xml @@ -0,0 +1,158 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.4.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 14.0.1 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.16 + + + \ No newline at end of file diff --git a/guava/src/main/java/org/baeldung/config/MvcConfig.java b/guava/src/main/java/org/baeldung/config/MvcConfig.java new file mode 100644 index 000000000000..18924ad855b1 --- /dev/null +++ b/guava/src/main/java/org/baeldung/config/MvcConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +@EnableWebMvc +@Configuration +@ComponentScan({ "org.baeldung.controller" }) +public class MvcConfig { + + public MvcConfig() { + super(); + } + +} \ No newline at end of file diff --git a/guava/src/main/java/org/baeldung/controller/BarController.java b/guava/src/main/java/org/baeldung/controller/BarController.java new file mode 100644 index 000000000000..d85c41086298 --- /dev/null +++ b/guava/src/main/java/org/baeldung/controller/BarController.java @@ -0,0 +1,46 @@ +package org.baeldung.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class BarController { + + public BarController() { + super(); + } + + // API + + // with @RequestParam + + @RequestMapping(value = "/bars") + @ResponseBody + public String getBarBySimplePathWithRequestParam(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + + @RequestMapping(value = "/bars", params = "id") + @ResponseBody + public String getBarBySimplePathWithExplicitRequestParam(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + + @RequestMapping(value = "/bars", params = { "id", "second" }) + @ResponseBody + public String getBarBySimplePathWithExplicitRequestParams(@RequestParam("id") final long id) { + return "Get a specific Bar with id=" + id; + } + + // with @PathVariable + + @RequestMapping(value = "/bars/{numericId:[\\d]+}") + @ResponseBody + public String getBarsBySimplePathWithPathVariable(@PathVariable final long numericId) { + return "Get a specific Bar with id=" + numericId; + } + +} diff --git a/guava/src/main/java/org/baeldung/controller/FooController.java b/guava/src/main/java/org/baeldung/controller/FooController.java new file mode 100644 index 000000000000..292f46729abf --- /dev/null +++ b/guava/src/main/java/org/baeldung/controller/FooController.java @@ -0,0 +1,94 @@ +package org.baeldung.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class FooController { + + public FooController() { + super(); + } + + // API + + // by paths + + @RequestMapping(value = "/foos") + @ResponseBody + public String getFoosBySimplePath() { + return "Simple Get some Foos"; + } + + // with @PathVariable + + @RequestMapping(value = "/foos/{id}") + @ResponseBody + public String getFoosBySimplePathWithPathVariable(@PathVariable final long id) { + return "Get a specific Foo with id=" + id; + } + + @RequestMapping(value = "/foos/{fooid}/bar/{barid}") + @ResponseBody + public String getFoosBySimplePathWithPathVariables(@PathVariable final long fooid, @PathVariable final long barid) { + return "Get a specific Bar with id=" + barid + " from a Foo with id=" + fooid; + } + + // other HTTP verbs + + @RequestMapping(value = "/foos", method = RequestMethod.POST) + @ResponseBody + public String postFoos() { + return "Post some Foos"; + } + + // with headers + + @RequestMapping(value = "/foos", headers = "key=val") + @ResponseBody + public String getFoosWithHeader() { + return "Get some Foos with Header"; + } + + @RequestMapping(value = "/foos", headers = { "key1=val1", "key2=val2" }) + @ResponseBody + public String getFoosWithHeaders() { + return "Get some Foos with Header"; + } + + @RequestMapping(value = "/foos", produces = { "application/json", "application/xml" }) + @ResponseBody + public String getFoosAsJsonFromREST() { + return "Get some Foos with Header Exact"; + } + + // advanced - multiple mappings + + @RequestMapping(value = { "/advanced/bars", "/advanced/foos" }) + @ResponseBody + public String getFoosOrBarsByPath() { + return "Advanced - Get some Foos or Bars"; + } + + @RequestMapping(value = "*") + @ResponseBody + public String getFallback() { + return "Fallback for GET Requests"; + } + + @RequestMapping(value = "*", method = { RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public String allFallback() { + return "Fallback for All Requests"; + } + + @RequestMapping(value = "/foos/multiple", method = { RequestMethod.PUT, RequestMethod.POST }) + @ResponseBody + public String putAndPostFoos() { + return "Advanced - PUT and POST within single method"; + } + +} diff --git a/guava/src/main/resources/logback.xml b/guava/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/guava/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/guava/src/main/webapp/WEB-INF/api-servlet.xml b/guava/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/guava/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/guava/src/main/webapp/WEB-INF/web.xml b/guava/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/guava/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/guava/src/test/resources/.gitignore b/guava/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/guava/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component index d7495fe4b086..d852102ca2c5 100644 --- a/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - From 49594e49e3508416f87f08010ff388e98e5ce551 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 17:37:41 +0300 Subject: [PATCH 284/796] initial cleanup --- guava/.classpath | 5 +- guava/.project | 6 - guava/.settings/org.eclipse.jdt.core.prefs | 6 +- guava/pom.xml | 293 ++++++++---------- .../java/org/baeldung/config/MvcConfig.java | 16 - .../baeldung/controller/BarController.java | 46 --- .../baeldung/controller/FooController.java | 94 ------ 7 files changed, 142 insertions(+), 324 deletions(-) delete mode 100644 guava/src/main/java/org/baeldung/config/MvcConfig.java delete mode 100644 guava/src/main/java/org/baeldung/controller/BarController.java delete mode 100644 guava/src/main/java/org/baeldung/controller/FooController.java diff --git a/guava/.classpath b/guava/.classpath index eed10d8a8b04..506df5d23a7c 100644 --- a/guava/.classpath +++ b/guava/.classpath @@ -22,15 +22,14 @@ - + - + - diff --git a/guava/.project b/guava/.project index 1d5b25f53ac8..48be966b70b1 100644 --- a/guava/.project +++ b/guava/.project @@ -20,11 +20,6 @@ - - org.springframework.ide.eclipse.core.springbuilder - - - org.eclipse.m2e.core.maven2Builder @@ -32,7 +27,6 @@ - org.springframework.ide.eclipse.core.springnature org.eclipse.jem.workbench.JavaEMFNature org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jdt.core.javanature diff --git a/guava/.settings/org.eclipse.jdt.core.prefs b/guava/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..13a747365774 100644 --- a/guava/.settings/org.eclipse.jdt.core.prefs +++ b/guava/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/guava/pom.xml b/guava/pom.xml index d4c58cd7bbe0..cea354039456 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -1,158 +1,139 @@ - - 4.0.0 - org.baeldung - spring-rest - 0.1-SNAPSHOT - - spring-rest - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-rest - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.4.RELEASE - 3.1.4.RELEASE - - - 4.2.4.Final - 5.1.26 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.1 - 1.8.9 - - - 1.4.3 - 2.16 - + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.4.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.16 + \ No newline at end of file diff --git a/guava/src/main/java/org/baeldung/config/MvcConfig.java b/guava/src/main/java/org/baeldung/config/MvcConfig.java deleted file mode 100644 index 18924ad855b1..000000000000 --- a/guava/src/main/java/org/baeldung/config/MvcConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; - -@EnableWebMvc -@Configuration -@ComponentScan({ "org.baeldung.controller" }) -public class MvcConfig { - - public MvcConfig() { - super(); - } - -} \ No newline at end of file diff --git a/guava/src/main/java/org/baeldung/controller/BarController.java b/guava/src/main/java/org/baeldung/controller/BarController.java deleted file mode 100644 index d85c41086298..000000000000 --- a/guava/src/main/java/org/baeldung/controller/BarController.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.baeldung.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class BarController { - - public BarController() { - super(); - } - - // API - - // with @RequestParam - - @RequestMapping(value = "/bars") - @ResponseBody - public String getBarBySimplePathWithRequestParam(@RequestParam("id") final long id) { - return "Get a specific Bar with id=" + id; - } - - @RequestMapping(value = "/bars", params = "id") - @ResponseBody - public String getBarBySimplePathWithExplicitRequestParam(@RequestParam("id") final long id) { - return "Get a specific Bar with id=" + id; - } - - @RequestMapping(value = "/bars", params = { "id", "second" }) - @ResponseBody - public String getBarBySimplePathWithExplicitRequestParams(@RequestParam("id") final long id) { - return "Get a specific Bar with id=" + id; - } - - // with @PathVariable - - @RequestMapping(value = "/bars/{numericId:[\\d]+}") - @ResponseBody - public String getBarsBySimplePathWithPathVariable(@PathVariable final long numericId) { - return "Get a specific Bar with id=" + numericId; - } - -} diff --git a/guava/src/main/java/org/baeldung/controller/FooController.java b/guava/src/main/java/org/baeldung/controller/FooController.java deleted file mode 100644 index 292f46729abf..000000000000 --- a/guava/src/main/java/org/baeldung/controller/FooController.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.baeldung.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class FooController { - - public FooController() { - super(); - } - - // API - - // by paths - - @RequestMapping(value = "/foos") - @ResponseBody - public String getFoosBySimplePath() { - return "Simple Get some Foos"; - } - - // with @PathVariable - - @RequestMapping(value = "/foos/{id}") - @ResponseBody - public String getFoosBySimplePathWithPathVariable(@PathVariable final long id) { - return "Get a specific Foo with id=" + id; - } - - @RequestMapping(value = "/foos/{fooid}/bar/{barid}") - @ResponseBody - public String getFoosBySimplePathWithPathVariables(@PathVariable final long fooid, @PathVariable final long barid) { - return "Get a specific Bar with id=" + barid + " from a Foo with id=" + fooid; - } - - // other HTTP verbs - - @RequestMapping(value = "/foos", method = RequestMethod.POST) - @ResponseBody - public String postFoos() { - return "Post some Foos"; - } - - // with headers - - @RequestMapping(value = "/foos", headers = "key=val") - @ResponseBody - public String getFoosWithHeader() { - return "Get some Foos with Header"; - } - - @RequestMapping(value = "/foos", headers = { "key1=val1", "key2=val2" }) - @ResponseBody - public String getFoosWithHeaders() { - return "Get some Foos with Header"; - } - - @RequestMapping(value = "/foos", produces = { "application/json", "application/xml" }) - @ResponseBody - public String getFoosAsJsonFromREST() { - return "Get some Foos with Header Exact"; - } - - // advanced - multiple mappings - - @RequestMapping(value = { "/advanced/bars", "/advanced/foos" }) - @ResponseBody - public String getFoosOrBarsByPath() { - return "Advanced - Get some Foos or Bars"; - } - - @RequestMapping(value = "*") - @ResponseBody - public String getFallback() { - return "Fallback for GET Requests"; - } - - @RequestMapping(value = "*", method = { RequestMethod.GET, RequestMethod.POST }) - @ResponseBody - public String allFallback() { - return "Fallback for All Requests"; - } - - @RequestMapping(value = "/foos/multiple", method = { RequestMethod.PUT, RequestMethod.POST }) - @ResponseBody - public String putAndPostFoos() { - return "Advanced - PUT and POST within single method"; - } - -} From 9c9a07d2b8411dc6c2a336c6680d00d115c84207 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 17:41:41 +0300 Subject: [PATCH 285/796] minor eclipse artifacts --- guava/.settings/org.eclipse.jdt.core.prefs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/guava/.settings/org.eclipse.jdt.core.prefs b/guava/.settings/org.eclipse.jdt.core.prefs index 13a747365774..747acb809194 100644 --- a/guava/.settings/org.eclipse.jdt.core.prefs +++ b/guava/.settings/org.eclipse.jdt.core.prefs @@ -4,15 +4,7 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -21,7 +13,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled @@ -92,4 +83,3 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 From 361111b1e66f08889234c83aa2fd8ea8fd6bf932 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 18:03:26 +0300 Subject: [PATCH 286/796] initial testing work --- .../collections/GuavaCollectionsExamples.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java new file mode 100644 index 000000000000..7ee2c69c8464 --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java @@ -0,0 +1,34 @@ +package org.baeldung.guava.collections; + +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; + +public class GuavaCollectionsExamples { + + @SuppressWarnings({ "unused", "unchecked" }) + @Test + public final void whenCastingAllElementsOfACollectionToSubtype_thenCastIsOK() { + final class CastFunction implements Function { + @Override + @SuppressWarnings("unchecked") + public final T apply(final F from) { + return (T) from; + } + } + + final List originalList = Lists.newArrayList(); + final List selectedProductsQuick = (List) (List) originalList; + final List selectedProducts = Lists.transform(originalList, new CastFunction()); + System.out.println(selectedProducts); + } + + @Test + public final void when_then() { + + } + +} From e491f953a5e4ad86955c8fb4214feeef5af1666a Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 18:07:49 +0300 Subject: [PATCH 287/796] java guava examples --- guava/pom.xml | 29 ------------------- ...java => GuavaCollectionsExamplesTest.java} | 20 +++++++++---- 2 files changed, 14 insertions(+), 35 deletions(-) rename guava/src/test/java/org/baeldung/guava/collections/{GuavaCollectionsExamples.java => GuavaCollectionsExamplesTest.java} (57%) diff --git a/guava/pom.xml b/guava/pom.xml index cea354039456..e5e2c604ab98 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -65,35 +65,6 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java similarity index 57% rename from guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java rename to guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java index 7ee2c69c8464..fd764d6203da 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java @@ -7,28 +7,36 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; -public class GuavaCollectionsExamples { +public class GuavaCollectionsExamplesTest { + + // tests - @SuppressWarnings({ "unused", "unchecked" }) @Test - public final void whenCastingAllElementsOfACollectionToSubtype_thenCastIsOK() { + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() { final class CastFunction implements Function { - @Override @SuppressWarnings("unchecked") + @Override public final T apply(final F from) { return (T) from; } } final List originalList = Lists.newArrayList(); - final List selectedProductsQuick = (List) (List) originalList; final List selectedProducts = Lists.transform(originalList, new CastFunction()); System.out.println(selectedProducts); } + @SuppressWarnings({ "unchecked" }) @Test - public final void when_then() { + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() { + final List originalList = Lists.newArrayList(); + final List selectedProducts = (List) (List) originalList; + System.out.println(selectedProducts); + } + @Test + public final void when_then() { + // } } From 930f2c3b862aafad996fb5b303ef8745dd7c7496 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 18:36:29 +0300 Subject: [PATCH 288/796] further examples --- .../GuavaCollectionsExamplesTest.java | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java index fd764d6203da..7183f246da24 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java @@ -1,11 +1,19 @@ package org.baeldung.guava.collections; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; import java.util.List; +import java.util.Set; import org.junit.Test; import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; public class GuavaCollectionsExamplesTest { @@ -35,8 +43,69 @@ public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_t } @Test - public final void when_then() { - // + public final void whenAddingAnIterableToACollection_thenAddedOK() { + final Iterable iter = Lists.newArrayList(); + final Collection collector = Lists.newArrayList(); + Iterables.addAll(collector, iter); + } + + // + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch1_thenContains() { + final Iterable theCollection = Lists.newArrayList("a", "bc", "def"); + final boolean contains = Iterables.any(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch2_thenContains() { + final Set theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = !Sets.filter(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }).isEmpty(); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch3_thenContains() { + final Iterable theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }) != null; + + assertTrue(contains); + } + + // + + @Test + public final void givenNoSearchResult_whenFindingElementInIterable_thenNoException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final String found = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertNull(found); } } From 77b1225fddbd432cc1b313c8d7271e04a45ffebd Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 22 Oct 2013 18:38:49 +0300 Subject: [PATCH 289/796] minor work --- .../guava/collections/GuavaCollectionsExamplesTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java index 7183f246da24..326a1964fb90 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.List; +import java.util.NoSuchElementException; import java.util.Set; import org.junit.Test; @@ -94,7 +95,7 @@ public final boolean apply(final String input) { // - @Test + @Test(expected = NoSuchElementException.class) public final void givenNoSearchResult_whenFindingElementInIterable_thenNoException() { final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); From 9c3db850187f611a1d5c1744e0385e7230b1206f Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 23 Oct 2013 10:53:48 +0300 Subject: [PATCH 290/796] minor eclipse cleanup --- guava/.classpath | 2 +- guava/.project | 1 - guava/.settings/.jsdtscope | 7 ------- guava/.settings/org.eclipse.jdt.core.prefs | 10 ++++++++++ guava/.settings/org.eclipse.wst.common.component | 2 -- .../org.eclipse.wst.common.project.facet.core.xml | 2 -- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/guava/.classpath b/guava/.classpath index 506df5d23a7c..c370943e8c83 100644 --- a/guava/.classpath +++ b/guava/.classpath @@ -27,7 +27,7 @@ - + diff --git a/guava/.project b/guava/.project index 48be966b70b1..829dc8380991 100644 --- a/guava/.project +++ b/guava/.project @@ -32,6 +32,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature diff --git a/guava/.settings/.jsdtscope b/guava/.settings/.jsdtscope index b46b9207a89e..7b3f0c8b9fae 100644 --- a/guava/.settings/.jsdtscope +++ b/guava/.settings/.jsdtscope @@ -1,12 +1,5 @@ - - - - - - - diff --git a/guava/.settings/org.eclipse.jdt.core.prefs b/guava/.settings/org.eclipse.jdt.core.prefs index 747acb809194..723e5b12451a 100644 --- a/guava/.settings/org.eclipse.jdt.core.prefs +++ b/guava/.settings/org.eclipse.jdt.core.prefs @@ -4,7 +4,15 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -13,6 +21,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled @@ -83,3 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/guava/.settings/org.eclipse.wst.common.component b/guava/.settings/org.eclipse.wst.common.component index 8bb4ef127aa6..e98377cb0f7c 100644 --- a/guava/.settings/org.eclipse.wst.common.component +++ b/guava/.settings/org.eclipse.wst.common.component @@ -1,7 +1,5 @@ - - diff --git a/guava/.settings/org.eclipse.wst.common.project.facet.core.xml b/guava/.settings/org.eclipse.wst.common.project.facet.core.xml index a67649dfa5ae..bc0009a45587 100644 --- a/guava/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/guava/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,4 @@ - - From be8ac5daa51b74328d0fb0583ffd606e13dced4c Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 23 Oct 2013 12:13:43 +0300 Subject: [PATCH 291/796] finished first cookbook - examples --- .../GuavaCollectionsExamplesTest.java | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java index 326a1964fb90..b270653ffac9 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; @@ -12,10 +13,16 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.google.common.collect.Sets; +@SuppressWarnings("unused") public class GuavaCollectionsExamplesTest { // tests @@ -96,7 +103,7 @@ public final boolean apply(final String input) { // @Test(expected = NoSuchElementException.class) - public final void givenNoSearchResult_whenFindingElementInIterable_thenNoException() { + public final void givenNoSearchResult_whenFindingElementInIterable_thenException() { final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); final String found = Iterables.find(theCollection, new Predicate() { @@ -109,4 +116,61 @@ public final boolean apply(final String input) { assertNull(found); } + @Test + public final void givenNoSearchResult_whenFindingElementInIterableWithSpecifiedReturn_thenNoException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final Predicate inputOfLengthOne = new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }; + final String found = Iterables.find(theCollection, inputOfLengthOne, null); + + assertNull(found); + } + + // purge of nulls + + @Test + public final void givenListContainsNulls_whenPurgedOfNulls_thenNoLongerContainsNulls() { + final List values = Lists.newArrayList("a", null, "b", "c"); + final Iterable withoutNulls = Iterables.filter(values, Predicates.notNull()); + System.out.println(withoutNulls); + } + + // immutable collections + + @Test + public final void whenCreatingImuutableCollections_thenNoExceptions() { + final ImmutableList immutableList = ImmutableList.of("a", "b", "c"); + final ImmutableSet immutableSet = ImmutableSet.of("a", "b", "c"); + final ImmutableMap imuttableMap = ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3"); + } + + @Test + public final void whenTransformingCollectionsToImmutable_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList.copyOf(muttableList); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet.copyOf(muttableSet); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap.copyOf(muttableMap); + } + + @Test + public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList. builder().addAll(muttableList).build(); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet. builder().addAll(muttableSet).build(); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); + } + } From e8a904de202ef9b9b7a812fe5eb9e77c796e335b Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 23 Oct 2013 12:20:11 +0300 Subject: [PATCH 292/796] documentation worK --- guava/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/guava/README.md b/guava/README.md index b979f263ed51..d6d3ef275dad 100644 --- a/guava/README.md +++ b/guava/README.md @@ -1,9 +1,8 @@ ========= -## Spring REST Example Project +## Guava Cookbooks and Examples ### Relevant Articles: -- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) - +- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) From 4557807f001706bf1e383b13dbe4a359e4318846 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Thu, 24 Oct 2013 18:14:07 +0300 Subject: [PATCH 293/796] testing work for guava ordering --- .../GuavaOrderingExamplesTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java new file mode 100644 index 000000000000..ea9dc794ecb9 --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -0,0 +1,29 @@ +package org.baeldung.guava.collections; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +import com.google.common.collect.Ordering; + +public class GuavaOrderingExamplesTest { + + // tests + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { + final List nums = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(nums, Ordering.natural().nullsLast()); + System.out.println(nums); + } + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { + final List nums = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(nums, Ordering.natural().nullsFirst()); + System.out.println(nums); + } + +} From 83f2c36c0eed373516ad6ca9d2350f6f04cfb06a Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Fri, 25 Oct 2013 11:35:36 +0300 Subject: [PATCH 294/796] guava examples --- .../collections/GuavaOrderingExamplesTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java index ea9dc794ecb9..c1539d2af8ed 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -1,5 +1,8 @@ package org.baeldung.guava.collections; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -16,14 +19,20 @@ public class GuavaOrderingExamplesTest { public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { final List nums = Arrays.asList(3, 5, 4, null, 1, 2); Collections.sort(nums, Ordering.natural().nullsLast()); - System.out.println(nums); + assertThat(nums.get(nums.size() - 1), nullValue()); } @Test public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { final List nums = Arrays.asList(3, 5, 4, null, 1, 2); Collections.sort(nums, Ordering.natural().nullsFirst()); - System.out.println(nums); + assertThat(nums.get(0), nullValue()); } + @Test + public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { + final List nums = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(nums, Ordering.natural().nullsLast().reverse()); + assertThat(nums.get(0), nullValue()); + } } From 8c81ec9e427ce97daf9ef74cfdb058eadaa24860 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Fri, 25 Oct 2013 11:42:44 +0300 Subject: [PATCH 295/796] guava examples for ordering --- .../collections/GuavaOrderingExamplesTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java index c1539d2af8ed..660411f76fc4 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -1,5 +1,6 @@ package org.baeldung.guava.collections; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; @@ -10,6 +11,7 @@ import org.junit.Test; import com.google.common.collect.Ordering; +import com.google.common.primitives.Ints; public class GuavaOrderingExamplesTest { @@ -35,4 +37,20 @@ public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { Collections.sort(nums, Ordering.natural().nullsLast().reverse()); assertThat(nums.get(0), nullValue()); } + + @Test + public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { + final List toSort = Arrays.asList("aa", "b", null, "ccc"); + final Ordering byLength = new Ordering() { + @Override + public int compare(final String s1, final String s2) { + return Ints.compare(s1.length(), s2.length()); + } + }; + + Collections.sort(toSort, byLength.nullsFirst()); + assertThat(toSort.get(0), nullValue()); + assertThat(toSort.get(1), equalTo("b")); + } + } From b19a5af156493548caccd8674f0a22f1786afcbb Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Fri, 25 Oct 2013 12:01:33 +0300 Subject: [PATCH 296/796] ordering work --- .../GuavaOrderingExamplesTest.java | 67 +++++++++++++------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java index 660411f76fc4..a7e88fb90c8e 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -1,8 +1,8 @@ package org.baeldung.guava.collections; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collections; @@ -10,47 +10,72 @@ import org.junit.Test; +import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.common.primitives.Ints; public class GuavaOrderingExamplesTest { + private final class OrderingByLenght extends Ordering { + @Override + public final int compare(final String s1, final String s2) { + return Ints.compare(s1.length(), s2.length()); + } + } + // tests @Test public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { - final List nums = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(nums, Ordering.natural().nullsLast()); - assertThat(nums.get(nums.size() - 1), nullValue()); + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast()); + assertThat(toSort.get(toSort.size() - 1), nullValue()); } @Test public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { - final List nums = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(nums, Ordering.natural().nullsFirst()); - assertThat(nums.get(0), nullValue()); + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsFirst()); + assertThat(toSort.get(0), nullValue()); } @Test public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { - final List nums = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(nums, Ordering.natural().nullsLast().reverse()); - assertThat(nums.get(0), nullValue()); + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast().reverse()); + assertThat(toSort.get(0), nullValue()); + } + + @Test + public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); } @Test public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { - final List toSort = Arrays.asList("aa", "b", null, "ccc"); - final Ordering byLength = new Ordering() { - @Override - public int compare(final String s1, final String s2) { - return Ints.compare(s1.length(), s2.length()); - } - }; - - Collections.sort(toSort, byLength.nullsFirst()); - assertThat(toSort.get(0), nullValue()); - assertThat(toSort.get(1), equalTo("b")); + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrdering_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength.compound(Ordering.natural())); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "zz", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); } } From 2a5442477d18e68f386477d73ef1a4881816c9a1 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Fri, 25 Oct 2013 12:41:23 +0300 Subject: [PATCH 297/796] ordering examples --- .../GuavaOrderingExamplesTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java index a7e88fb90c8e..b96f751e4607 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -1,6 +1,7 @@ package org.baeldung.guava.collections; import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -25,6 +26,8 @@ public final int compare(final String s1, final String s2) { // tests + // dealing with null + @Test public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); @@ -46,6 +49,18 @@ public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { assertThat(toSort.get(0), nullValue()); } + // natural ordering + + @Test + public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { + final List toSort = Arrays.asList(3, 5, 4, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertTrue(Ordering.natural().isOrdered(toSort)); + } + + // custom - by length + @Test public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); @@ -78,4 +93,35 @@ public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrd assertTrue(expectedOrder.isOrdered(toSort)); } + @Test + public final void whenSortingCollectionsWithComplexOrderingExample_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", null, "b", "ccc"); + + Collections.sort(toSort, new OrderingByLenght().reverse().compound(Ordering.natural()).nullsLast()); + System.out.println(toSort); + } + + // sorted copy + + @Test + public final void givenUnorderdList_whenRetrievingSortedCopy_thenSorted() { + final List toSort = Arrays.asList("aa", "b", "ccc"); + final List sortedCopy = new OrderingByLenght().sortedCopy(toSort); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "ccc")); + assertFalse(expectedOrder.isOrdered(toSort)); + assertTrue(expectedOrder.isOrdered(sortedCopy)); + } + + // to string + + @Test + public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSortedWithToString() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList(1, 11, 2)); + assertTrue(expectedOrder.isOrdered(toSort)); + } + } From 31de9bbf62c2c1f29657666531cf1bcde742de12 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Fri, 25 Oct 2013 13:33:16 +0300 Subject: [PATCH 298/796] finishing the guava ordering examples --- .../GuavaOrderingExamplesTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java index b96f751e4607..1a2a6a816b35 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java @@ -1,5 +1,6 @@ package org.baeldung.guava.collections; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; @@ -11,6 +12,7 @@ import org.junit.Test; +import com.google.common.base.Functions; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.common.primitives.Ints; @@ -59,6 +61,16 @@ public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { assertTrue(Ordering.natural().isOrdered(toSort)); } + // checking string ordering + + @Test + public final void givenCollectionContainsDuplicates_whenCheckingStringOrdering_thenNo() { + final List toSort = Arrays.asList(3, 5, 4, 2, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertFalse(Ordering.natural().isStrictlyOrdered(toSort)); + } + // custom - by length @Test @@ -124,4 +136,44 @@ public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSorte assertTrue(expectedOrder.isOrdered(toSort)); } + // binary search + + @Test + public final void whenPerformingBinarySearch_thenFound() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + final int found = Ordering.usingToString().binarySearch(toSort, 2); + + System.out.println(found); + } + + // min/max without actually sorting + + @Test + public final void whenFindingTheMinimalElementWithoutSorting_thenFound() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final int found = Ordering.natural().min(toSort); + assertThat(found, equalTo(1)); + } + + @Test + public final void whenFindingTheFirstFewElements_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final List leastOf = Ordering.natural().leastOf(toSort, 3); + final List expected = Lists.newArrayList(1, 2, 8); + assertThat(expected, equalTo(leastOf)); + } + + // order the results of a Function + + @Test + public final void givenListOfNumbers_whenRunningAToStringFunctionThenSorting_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List sortedCopy = ordering.sortedCopy(toSort); + + final List expected = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(expected, equalTo(sortedCopy)); + } + } From e2371cec0172a2b876c4327b659b2d2a43277607 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Mon, 28 Oct 2013 15:30:07 +0200 Subject: [PATCH 299/796] testing examples for hamcrest --- .../GuavaCollectionsExamplesTest.java | 2 +- .../GuavaOrderingExamplesTest.java | 2 +- .../hamcrest/HamcrestExamplesTest.java | 68 +++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) rename guava/src/test/java/org/baeldung/guava/{collections => }/GuavaCollectionsExamplesTest.java (99%) rename guava/src/test/java/org/baeldung/guava/{collections => }/GuavaOrderingExamplesTest.java (99%) create mode 100644 guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java rename to guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java index b270653ffac9..dc6bfe4c0ba0 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava.collections; +package org.baeldung.guava; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; diff --git a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java rename to guava/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java index 1a2a6a816b35..5821d19ba05b 100644 --- a/guava/src/test/java/org/baeldung/guava/collections/GuavaOrderingExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava.collections; +package org.baeldung.guava; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java new file mode 100644 index 000000000000..99a9209b36f9 --- /dev/null +++ b/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java @@ -0,0 +1,68 @@ +package org.baeldung.hamcrest; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class HamcrestExamplesTest { + + // tests + + @Test + public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItem("cd")); + assertThat(collection, not(hasItem("zz"))); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItems("cd", "ef")); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, contains("ab", "cd", "ef")); + } + + @Test + public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { + final List collection = Lists.newArrayList(); + assertThat(collection, empty()); + } + + @Test + public final void givenCollectionIsNotEmpty_whenChecking_thenNotEmpty() { + final List collection = Lists.newArrayList("a"); + assertThat(collection, not(empty())); + } + + @Test + public final void givenMapIsEmpty_whenChecking_thenEmpty() { + final Map collection = Maps.newHashMap(); + assertThat(collection, equalTo(Collections.EMPTY_MAP)); + } + + @Test + public final void givenArrayIsEmpty_whenChecking_thenEmpty() { + final String[] array = new String[] { "ab" }; + assertThat(array, not(emptyArray())); + } + +} From 3d0def73d4b9d0f311ebbcbe0303f5f583efaa26 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Mon, 28 Oct 2013 16:56:35 +0200 Subject: [PATCH 300/796] testing work for hamcrest --- .../hamcrest/HamcrestExamplesTest.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java index 99a9209b36f9..a44ce766f067 100644 --- a/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java +++ b/guava/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java @@ -1,11 +1,15 @@ package org.baeldung.hamcrest; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; @@ -13,6 +17,7 @@ import java.util.List; import java.util.Map; +import org.hamcrest.Matchers; import org.junit.Test; import com.google.common.collect.Lists; @@ -32,15 +37,21 @@ public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { @Test public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasItems("cd", "ef")); + assertThat(collection, hasItems("ef", "cd")); } @Test - public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect2() { + public final void whenVerifyingMultipleElementsArePartOfCollectionInStrictOrder_thenCorrect2() { final List collection = Lists.newArrayList("ab", "cd", "ef"); assertThat(collection, contains("ab", "cd", "ef")); } + @Test + public final void whenVerifyingMultipleElementsArePartOfCollectionInAnyOrder_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, containsInAnyOrder("cd", "ab", "ef")); + } + @Test public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { final List collection = Lists.newArrayList(); @@ -65,4 +76,22 @@ public final void givenArrayIsEmpty_whenChecking_thenEmpty() { assertThat(array, not(emptyArray())); } + @Test + public final void whenCollectionSizeIsChecked_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasSize(3)); + } + + @Test + public final void whenIterableSizeIsChecked_thenCorrect() { + final Iterable collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, Matchers. iterableWithSize(3)); + } + + @Test + public final void whenCheckingConditionOverEachItem_thenCorrect() { + final List collection = Lists.newArrayList(15, 20, 25, 30); + assertThat(collection, everyItem(greaterThan(10))); + } + } From 79d73136800dd3d05941337bc9334aa65a44a78a Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 11:35:28 +0200 Subject: [PATCH 301/796] guava functional work --- .../guava/GuavaFunctionalExamplesTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java new file mode 100644 index 000000000000..ae7d84e56b1c --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -0,0 +1,36 @@ +package org.baeldung.guava; + +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.Lists; + +public class GuavaFunctionalExamplesTest { + + // tests + + // predicates + + @Test + public final void whenFilteringStringsAccordingToACondition_thenCorrectResults() { + final List randomNumbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final List evenNumbers = Lists.newArrayList(Collections2.filter(randomNumbers, acceptEvenNumber)); + + final Integer found = Collections.binarySearch(evenNumbers, 57); + assertThat(found, lessThan(0)); + } + +} From 6af58dce947f52a5811ad6cc501f24bea5b05b88 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 11:56:07 +0200 Subject: [PATCH 302/796] functional work --- .../guava/GuavaFunctionalExamplesTest.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java index ae7d84e56b1c..6618e42583c8 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -1,16 +1,24 @@ package org.baeldung.guava; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Set; import org.junit.Test; +import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; public class GuavaFunctionalExamplesTest { @@ -19,7 +27,7 @@ public class GuavaFunctionalExamplesTest { // predicates @Test - public final void whenFilteringStringsAccordingToACondition_thenCorrectResults() { + public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { final List randomNumbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); final Predicate acceptEvenNumber = new Predicate() { @Override @@ -33,4 +41,38 @@ public final boolean apply(final Integer number) { assertThat(found, lessThan(0)); } + @Test + public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { + final List eventNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + + assertTrue(Iterables.all(eventNumbers, acceptEvenNumber)); + } + + // Set+Function => Map + + /** + * - see: http://code.google.com/p/guava-libraries/issues/detail?id=56 + */ + @Test + public final void whenMapIsBackedBySetAndFunction_thenCorrect() { + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + final Set lowNumbers = Sets.newHashSet(2, 3, 4); + + final Map numberToPowerOfTwoMuttable = Maps.asMap(lowNumbers, powerOfTwo); + final Map numberToPowerOfTwoImuttable = Maps.toMap(lowNumbers, powerOfTwo); + assertThat(numberToPowerOfTwoMuttable.get(2), equalTo(4)); + assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); + } + } From b97de291f1370b0d9bc79e0cdad893ff19e52abd Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 12:18:46 +0200 Subject: [PATCH 303/796] functional examples --- .../guava/GuavaFunctionalExamplesTest.java | 68 ++++++++++++++++++- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java index 6618e42583c8..46b249324d63 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -1,11 +1,14 @@ package org.baeldung.guava; +import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import java.util.Arrays; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -13,18 +16,21 @@ import org.junit.Test; import com.google.common.base.Function; +import com.google.common.base.Functions; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; import com.google.common.collect.Sets; public class GuavaFunctionalExamplesTest { // tests - // predicates + // predicates - filtering @Test public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { @@ -41,9 +47,19 @@ public final boolean apply(final Integer number) { assertThat(found, lessThan(0)); } + @Test + public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { + final List collectionOfStringsWithNulls = Lists.newArrayList("a", "bc", null, "def", null, null, "ghij"); + final Iterable collectionWithoutNulls = Iterables.filter(collectionOfStringsWithNulls, Predicates.notNull()); + + assertTrue(Iterables.all(collectionWithoutNulls, Predicates.notNull())); + } + + // predicates - checking + @Test public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { - final List eventNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); final Predicate acceptEvenNumber = new Predicate() { @Override public final boolean apply(final Integer number) { @@ -51,7 +67,53 @@ public final boolean apply(final Integer number) { } }; - assertTrue(Iterables.all(eventNumbers, acceptEvenNumber)); + assertTrue(Iterables.all(evenNumbers, acceptEvenNumber)); + } + + // negating a predicate + + @Test + public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) != 0; + } + }; + + assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptEvenNumber))); + } + + // try - 1 + + @Test(expected = UnsupportedOperationException.class) + public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); + final Iterator iterator = unmodifiableIterable.iterator(); + if (iterator.hasNext()) { + iterator.remove(); + } + } + + // functions + + @Test + public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final List numbersAsStrings = Lists.transform(numbers, Functions.toStringFunction()); + assertThat(numbersAsStrings, contains("1", "2", "3")); + } + + @Test + public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { + final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List alphabeticalOrderingOfNumbers = ordering.sortedCopy(numbersToSort); + + final List expectedAlphabeticalOrderingOfNumbers = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(expectedAlphabeticalOrderingOfNumbers, equalTo(alphabeticalOrderingOfNumbers)); } // Set+Function => Map From c257a33969bc7fa331b80a55ccdf85085f2cca34 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 12:45:36 +0200 Subject: [PATCH 304/796] functional work --- .../guava/GuavaFunctionalExamplesTest.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java index 46b249324d63..26a05a70231b 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -20,6 +20,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; +import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -75,14 +76,14 @@ public final boolean apply(final Integer number) { @Test public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); - final Predicate acceptEvenNumber = new Predicate() { + final Predicate acceptOddNumber = new Predicate() { @Override public final boolean apply(final Integer number) { return (number % 2) != 0; } }; - assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptEvenNumber))); + assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); } // try - 1 @@ -97,6 +98,13 @@ public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAl } } + // char predicates + + @Test + public final void when_thenCorrect() { + // CharMatcher.forPredicate(predicate) + } + // functions @Test @@ -116,6 +124,26 @@ public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInA assertThat(expectedAlphabeticalOrderingOfNumbers, equalTo(alphabeticalOrderingOfNumbers)); } + @Test + public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { + final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbersToSort).filter(acceptEvenNumber).transform(powerOfTwo); + assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); + } + // Set+Function => Map /** From 625f4e126dfc2fc290a55a1c250798b11f47ee48 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 13:00:28 +0200 Subject: [PATCH 305/796] functional work --- .../guava/GuavaFunctionalExamplesTest.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java index 26a05a70231b..f58139a97439 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -98,7 +98,7 @@ public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAl } } - // char predicates + // other predicates @Test public final void when_thenCorrect() { @@ -126,7 +126,7 @@ public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInA @Test public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { - final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final List numbers = Arrays.asList(2, 1, 11, 100, 8, 14); final Predicate acceptEvenNumber = new Predicate() { @Override public final boolean apply(final Integer number) { @@ -140,10 +140,24 @@ public final Integer apply(final Integer input) { } }; - final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbersToSort).filter(acceptEvenNumber).transform(powerOfTwo); + final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbers).filter(acceptEvenNumber).transform(powerOfTwo); assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); } + @Test + public final void whenUsingFunctionComposition_thenCorrectResults() { + final List numbers = Arrays.asList(2, 3); + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final List result = Lists.transform(numbers, Functions.compose(powerOfTwo, powerOfTwo)); + assertThat(result, contains(16, 81)); + } + // Set+Function => Map /** From cf73a09b62b2a06b3654776aa514183fe63e758e Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 30 Oct 2013 17:42:47 +0200 Subject: [PATCH 306/796] guava functional work --- .../guava/GuavaCollectionsExamplesTest.java | 13 ++++++ .../guava/GuavaFunctionalExamplesTest.java | 46 ++++++++++--------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java index dc6bfe4c0ba0..2c137e6c8041 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertTrue; import java.util.Collection; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -173,4 +174,16 @@ public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExcept final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); } + // unmodifiable + + @Test(expected = UnsupportedOperationException.class) + public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); + final Iterator iterator = unmodifiableIterable.iterator(); + if (iterator.hasNext()) { + iterator.remove(); + } + } + } diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java index f58139a97439..08091639f169 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -8,7 +8,6 @@ import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -35,14 +34,14 @@ public class GuavaFunctionalExamplesTest { @Test public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { - final List randomNumbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); + final List numbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); final Predicate acceptEvenNumber = new Predicate() { @Override public final boolean apply(final Integer number) { return (number % 2) == 0; } }; - final List evenNumbers = Lists.newArrayList(Collections2.filter(randomNumbers, acceptEvenNumber)); + final List evenNumbers = Lists.newArrayList(Collections2.filter(numbers, acceptEvenNumber)); final Integer found = Collections.binarySearch(evenNumbers, 57); assertThat(found, lessThan(0)); @@ -50,10 +49,10 @@ public final boolean apply(final Integer number) { @Test public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { - final List collectionOfStringsWithNulls = Lists.newArrayList("a", "bc", null, "def", null, null, "ghij"); - final Iterable collectionWithoutNulls = Iterables.filter(collectionOfStringsWithNulls, Predicates.notNull()); + final List withNulls = Lists.newArrayList("a", "bc", null, "def"); + final Iterable withoutNuls = Iterables.filter(withNulls, Predicates.notNull()); - assertTrue(Iterables.all(collectionWithoutNulls, Predicates.notNull())); + assertTrue(Iterables.all(withoutNuls, Predicates.notNull())); } // predicates - checking @@ -86,18 +85,6 @@ public final boolean apply(final Integer number) { assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); } - // try - 1 - - @Test(expected = UnsupportedOperationException.class) - public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { - final List numbers = Lists.newArrayList(1, 2, 3); - final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); - final Iterator iterator = unmodifiableIterable.iterator(); - if (iterator.hasNext()) { - iterator.remove(); - } - } - // other predicates @Test @@ -118,10 +105,10 @@ public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); - final List alphabeticalOrderingOfNumbers = ordering.sortedCopy(numbersToSort); + final List inAlphabeticalOrder = ordering.sortedCopy(numbersToSort); - final List expectedAlphabeticalOrderingOfNumbers = Lists.newArrayList(1, 100, 11, 14, 2, 8); - assertThat(expectedAlphabeticalOrderingOfNumbers, equalTo(alphabeticalOrderingOfNumbers)); + final List correctAlphabeticalOrder = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(correctAlphabeticalOrder, equalTo(inAlphabeticalOrder)); } @Test @@ -179,4 +166,21 @@ public final Integer apply(final Integer input) { assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); } + // Predicate => Function + + @Test + public final void whenConvertingPredicateToFunction_thenCorrect() { + final List numbers = Lists.newArrayList(1, 2, 3, 6); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function isEventNumberFunction = Functions.forPredicate(acceptEvenNumber); + final List areNumbersEven = Lists.transform(numbers, isEventNumberFunction); + + assertThat(areNumbersEven, contains(false, true, false, true)); + } + } From ab9969a393ac840eb89ebd8886c0ad000bc5d29f Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 6 Nov 2013 15:10:49 +0200 Subject: [PATCH 307/796] mockito new tutorial --- mockito/.classpath | 36 ++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + mockito/.gitignore | 13 ++ mockito/.project | 36 ++++ mockito/.settings/.jsdtscope | 5 + mockito/.settings/org.eclipse.jdt.core.prefs | 95 +++++++++ mockito/.settings/org.eclipse.jdt.ui.prefs | 55 +++++ mockito/.settings/org.eclipse.m2e.core.prefs | 4 + mockito/.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + mockito/.springBeans | 14 ++ mockito/README.md | 8 + mockito/pom.xml | 110 ++++++++++ mockito/src/main/resources/logback.xml | 20 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + mockito/src/main/webapp/WEB-INF/web.xml | 42 ++++ .../guava/GuavaCollectionsExamplesTest.java | 189 ++++++++++++++++++ .../guava/GuavaFunctionalExamplesTest.java | 186 +++++++++++++++++ .../guava/GuavaOrderingExamplesTest.java | 179 +++++++++++++++++ .../hamcrest/HamcrestExamplesTest.java | 97 +++++++++ mockito/src/test/resources/.gitignore | 13 ++ 26 files changed, 1147 insertions(+) create mode 100644 mockito/.classpath create mode 100644 mockito/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 mockito/.gitignore create mode 100644 mockito/.project create mode 100644 mockito/.settings/.jsdtscope create mode 100644 mockito/.settings/org.eclipse.jdt.core.prefs create mode 100644 mockito/.settings/org.eclipse.jdt.ui.prefs create mode 100644 mockito/.settings/org.eclipse.m2e.core.prefs create mode 100644 mockito/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 mockito/.settings/org.eclipse.wst.common.component create mode 100644 mockito/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 mockito/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 mockito/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 mockito/.settings/org.eclipse.wst.validation.prefs create mode 100644 mockito/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 mockito/.springBeans create mode 100644 mockito/README.md create mode 100644 mockito/pom.xml create mode 100644 mockito/src/main/resources/logback.xml create mode 100644 mockito/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 mockito/src/main/webapp/WEB-INF/web.xml create mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java create mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java create mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java create mode 100644 mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java create mode 100644 mockito/src/test/resources/.gitignore diff --git a/mockito/.classpath b/mockito/.classpath new file mode 100644 index 000000000000..c370943e8c83 --- /dev/null +++ b/mockito/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mockito/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/mockito/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/mockito/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/mockito/.gitignore b/mockito/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/mockito/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/mockito/.project b/mockito/.project new file mode 100644 index 000000000000..1c6c0deddc5f --- /dev/null +++ b/mockito/.project @@ -0,0 +1,36 @@ + + + mockito + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/mockito/.settings/.jsdtscope b/mockito/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/mockito/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/mockito/.settings/org.eclipse.jdt.core.prefs b/mockito/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/mockito/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/mockito/.settings/org.eclipse.jdt.ui.prefs b/mockito/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/mockito/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/mockito/.settings/org.eclipse.m2e.core.prefs b/mockito/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/mockito/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/mockito/.settings/org.eclipse.m2e.wtp.prefs b/mockito/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/mockito/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/mockito/.settings/org.eclipse.wst.common.component b/mockito/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/mockito/.settings/org.eclipse.wst.common.project.facet.core.xml b/mockito/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.container b/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.name b/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/mockito/.settings/org.eclipse.wst.validation.prefs b/mockito/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/mockito/.settings/org.eclipse.wst.ws.service.policy.prefs b/mockito/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/mockito/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/mockito/.springBeans b/mockito/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/mockito/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/mockito/README.md b/mockito/README.md new file mode 100644 index 000000000000..d6d3ef275dad --- /dev/null +++ b/mockito/README.md @@ -0,0 +1,8 @@ +========= + +## Guava Cookbooks and Examples + + +### Relevant Articles: +- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) + diff --git a/mockito/pom.xml b/mockito/pom.xml new file mode 100644 index 000000000000..e5e2c604ab98 --- /dev/null +++ b/mockito/pom.xml @@ -0,0 +1,110 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 3.2.4.RELEASE + 3.1.4.RELEASE + + + 4.2.4.Final + 5.1.26 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.5 + + 1.8.1 + 1.8.9 + + + 1.4.3 + 2.16 + + + \ No newline at end of file diff --git a/mockito/src/main/resources/logback.xml b/mockito/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/mockito/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mockito/src/main/webapp/WEB-INF/api-servlet.xml b/mockito/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/mockito/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/mockito/src/main/webapp/WEB-INF/web.xml b/mockito/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/mockito/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java new file mode 100644 index 000000000000..2c137e6c8041 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java @@ -0,0 +1,189 @@ +package org.baeldung.guava; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +@SuppressWarnings("unused") +public class GuavaCollectionsExamplesTest { + + // tests + + @Test + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() { + final class CastFunction implements Function { + @SuppressWarnings("unchecked") + @Override + public final T apply(final F from) { + return (T) from; + } + } + + final List originalList = Lists.newArrayList(); + final List selectedProducts = Lists.transform(originalList, new CastFunction()); + System.out.println(selectedProducts); + } + + @SuppressWarnings({ "unchecked" }) + @Test + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() { + final List originalList = Lists.newArrayList(); + final List selectedProducts = (List) (List) originalList; + System.out.println(selectedProducts); + } + + @Test + public final void whenAddingAnIterableToACollection_thenAddedOK() { + final Iterable iter = Lists.newArrayList(); + final Collection collector = Lists.newArrayList(); + Iterables.addAll(collector, iter); + } + + // + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch1_thenContains() { + final Iterable theCollection = Lists.newArrayList("a", "bc", "def"); + final boolean contains = Iterables.any(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch2_thenContains() { + final Set theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = !Sets.filter(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }).isEmpty(); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch3_thenContains() { + final Iterable theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }) != null; + + assertTrue(contains); + } + + // + + @Test(expected = NoSuchElementException.class) + public final void givenNoSearchResult_whenFindingElementInIterable_thenException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final String found = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertNull(found); + } + + @Test + public final void givenNoSearchResult_whenFindingElementInIterableWithSpecifiedReturn_thenNoException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final Predicate inputOfLengthOne = new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }; + final String found = Iterables.find(theCollection, inputOfLengthOne, null); + + assertNull(found); + } + + // purge of nulls + + @Test + public final void givenListContainsNulls_whenPurgedOfNulls_thenNoLongerContainsNulls() { + final List values = Lists.newArrayList("a", null, "b", "c"); + final Iterable withoutNulls = Iterables.filter(values, Predicates.notNull()); + System.out.println(withoutNulls); + } + + // immutable collections + + @Test + public final void whenCreatingImuutableCollections_thenNoExceptions() { + final ImmutableList immutableList = ImmutableList.of("a", "b", "c"); + final ImmutableSet immutableSet = ImmutableSet.of("a", "b", "c"); + final ImmutableMap imuttableMap = ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3"); + } + + @Test + public final void whenTransformingCollectionsToImmutable_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList.copyOf(muttableList); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet.copyOf(muttableSet); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap.copyOf(muttableMap); + } + + @Test + public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList. builder().addAll(muttableList).build(); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet. builder().addAll(muttableSet).build(); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); + } + + // unmodifiable + + @Test(expected = UnsupportedOperationException.class) + public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); + final Iterator iterator = unmodifiableIterable.iterator(); + if (iterator.hasNext()) { + iterator.remove(); + } + } + +} diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java new file mode 100644 index 000000000000..08091639f169 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -0,0 +1,186 @@ +package org.baeldung.guava; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Collections2; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; +import com.google.common.collect.Sets; + +public class GuavaFunctionalExamplesTest { + + // tests + + // predicates - filtering + + @Test + public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { + final List numbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final List evenNumbers = Lists.newArrayList(Collections2.filter(numbers, acceptEvenNumber)); + + final Integer found = Collections.binarySearch(evenNumbers, 57); + assertThat(found, lessThan(0)); + } + + @Test + public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { + final List withNulls = Lists.newArrayList("a", "bc", null, "def"); + final Iterable withoutNuls = Iterables.filter(withNulls, Predicates.notNull()); + + assertTrue(Iterables.all(withoutNuls, Predicates.notNull())); + } + + // predicates - checking + + @Test + public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + + assertTrue(Iterables.all(evenNumbers, acceptEvenNumber)); + } + + // negating a predicate + + @Test + public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptOddNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) != 0; + } + }; + + assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); + } + + // other predicates + + @Test + public final void when_thenCorrect() { + // CharMatcher.forPredicate(predicate) + } + + // functions + + @Test + public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final List numbersAsStrings = Lists.transform(numbers, Functions.toStringFunction()); + assertThat(numbersAsStrings, contains("1", "2", "3")); + } + + @Test + public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { + final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List inAlphabeticalOrder = ordering.sortedCopy(numbersToSort); + + final List correctAlphabeticalOrder = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(correctAlphabeticalOrder, equalTo(inAlphabeticalOrder)); + } + + @Test + public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { + final List numbers = Arrays.asList(2, 1, 11, 100, 8, 14); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbers).filter(acceptEvenNumber).transform(powerOfTwo); + assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); + } + + @Test + public final void whenUsingFunctionComposition_thenCorrectResults() { + final List numbers = Arrays.asList(2, 3); + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final List result = Lists.transform(numbers, Functions.compose(powerOfTwo, powerOfTwo)); + assertThat(result, contains(16, 81)); + } + + // Set+Function => Map + + /** + * - see: http://code.google.com/p/guava-libraries/issues/detail?id=56 + */ + @Test + public final void whenMapIsBackedBySetAndFunction_thenCorrect() { + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + final Set lowNumbers = Sets.newHashSet(2, 3, 4); + + final Map numberToPowerOfTwoMuttable = Maps.asMap(lowNumbers, powerOfTwo); + final Map numberToPowerOfTwoImuttable = Maps.toMap(lowNumbers, powerOfTwo); + assertThat(numberToPowerOfTwoMuttable.get(2), equalTo(4)); + assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); + } + + // Predicate => Function + + @Test + public final void whenConvertingPredicateToFunction_thenCorrect() { + final List numbers = Lists.newArrayList(1, 2, 3, 6); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function isEventNumberFunction = Functions.forPredicate(acceptEvenNumber); + final List areNumbersEven = Lists.transform(numbers, isEventNumberFunction); + + assertThat(areNumbersEven, contains(false, true, false, true)); + } + +} diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java new file mode 100644 index 000000000000..5821d19ba05b --- /dev/null +++ b/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java @@ -0,0 +1,179 @@ +package org.baeldung.guava; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Functions; +import com.google.common.collect.Lists; +import com.google.common.collect.Ordering; +import com.google.common.primitives.Ints; + +public class GuavaOrderingExamplesTest { + + private final class OrderingByLenght extends Ordering { + @Override + public final int compare(final String s1, final String s2) { + return Ints.compare(s1.length(), s2.length()); + } + } + + // tests + + // dealing with null + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast()); + assertThat(toSort.get(toSort.size() - 1), nullValue()); + } + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsFirst()); + assertThat(toSort.get(0), nullValue()); + } + + @Test + public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast().reverse()); + assertThat(toSort.get(0), nullValue()); + } + + // natural ordering + + @Test + public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { + final List toSort = Arrays.asList(3, 5, 4, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertTrue(Ordering.natural().isOrdered(toSort)); + } + + // checking string ordering + + @Test + public final void givenCollectionContainsDuplicates_whenCheckingStringOrdering_thenNo() { + final List toSort = Arrays.asList(3, 5, 4, 2, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertFalse(Ordering.natural().isStrictlyOrdered(toSort)); + } + + // custom - by length + + @Test + public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrdering_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength.compound(Ordering.natural())); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "zz", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsWithComplexOrderingExample_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", null, "b", "ccc"); + + Collections.sort(toSort, new OrderingByLenght().reverse().compound(Ordering.natural()).nullsLast()); + System.out.println(toSort); + } + + // sorted copy + + @Test + public final void givenUnorderdList_whenRetrievingSortedCopy_thenSorted() { + final List toSort = Arrays.asList("aa", "b", "ccc"); + final List sortedCopy = new OrderingByLenght().sortedCopy(toSort); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "ccc")); + assertFalse(expectedOrder.isOrdered(toSort)); + assertTrue(expectedOrder.isOrdered(sortedCopy)); + } + + // to string + + @Test + public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSortedWithToString() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList(1, 11, 2)); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + // binary search + + @Test + public final void whenPerformingBinarySearch_thenFound() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + final int found = Ordering.usingToString().binarySearch(toSort, 2); + + System.out.println(found); + } + + // min/max without actually sorting + + @Test + public final void whenFindingTheMinimalElementWithoutSorting_thenFound() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final int found = Ordering.natural().min(toSort); + assertThat(found, equalTo(1)); + } + + @Test + public final void whenFindingTheFirstFewElements_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final List leastOf = Ordering.natural().leastOf(toSort, 3); + final List expected = Lists.newArrayList(1, 2, 8); + assertThat(expected, equalTo(leastOf)); + } + + // order the results of a Function + + @Test + public final void givenListOfNumbers_whenRunningAToStringFunctionThenSorting_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List sortedCopy = ordering.sortedCopy(toSort); + + final List expected = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(expected, equalTo(sortedCopy)); + } + +} diff --git a/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java new file mode 100644 index 000000000000..a44ce766f067 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java @@ -0,0 +1,97 @@ +package org.baeldung.hamcrest; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.hamcrest.Matchers; +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class HamcrestExamplesTest { + + // tests + + @Test + public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItem("cd")); + assertThat(collection, not(hasItem("zz"))); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItems("ef", "cd")); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollectionInStrictOrder_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, contains("ab", "cd", "ef")); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollectionInAnyOrder_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, containsInAnyOrder("cd", "ab", "ef")); + } + + @Test + public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { + final List collection = Lists.newArrayList(); + assertThat(collection, empty()); + } + + @Test + public final void givenCollectionIsNotEmpty_whenChecking_thenNotEmpty() { + final List collection = Lists.newArrayList("a"); + assertThat(collection, not(empty())); + } + + @Test + public final void givenMapIsEmpty_whenChecking_thenEmpty() { + final Map collection = Maps.newHashMap(); + assertThat(collection, equalTo(Collections.EMPTY_MAP)); + } + + @Test + public final void givenArrayIsEmpty_whenChecking_thenEmpty() { + final String[] array = new String[] { "ab" }; + assertThat(array, not(emptyArray())); + } + + @Test + public final void whenCollectionSizeIsChecked_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasSize(3)); + } + + @Test + public final void whenIterableSizeIsChecked_thenCorrect() { + final Iterable collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, Matchers. iterableWithSize(3)); + } + + @Test + public final void whenCheckingConditionOverEachItem_thenCorrect() { + final List collection = Lists.newArrayList(15, 20, 25, 30); + assertThat(collection, everyItem(greaterThan(10))); + } + +} diff --git a/mockito/src/test/resources/.gitignore b/mockito/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/mockito/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 3a3b0cb17518b4f5f22c540848fa11d27c2ec1cf Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 6 Nov 2013 15:12:25 +0200 Subject: [PATCH 308/796] cleanup work --- .../guava/GuavaCollectionsExamplesTest.java | 189 ------------------ .../guava/GuavaFunctionalExamplesTest.java | 186 ----------------- .../guava/GuavaOrderingExamplesTest.java | 179 ----------------- .../hamcrest/HamcrestExamplesTest.java | 97 --------- .../mockito/MockitoVerifyExamplesTest.java | 14 ++ 5 files changed, 14 insertions(+), 651 deletions(-) delete mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java delete mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java delete mode 100644 mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java delete mode 100644 mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java create mode 100644 mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java deleted file mode 100644 index 2c137e6c8041..000000000000 --- a/mockito/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.baeldung.guava; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import org.junit.Test; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -@SuppressWarnings("unused") -public class GuavaCollectionsExamplesTest { - - // tests - - @Test - public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() { - final class CastFunction implements Function { - @SuppressWarnings("unchecked") - @Override - public final T apply(final F from) { - return (T) from; - } - } - - final List originalList = Lists.newArrayList(); - final List selectedProducts = Lists.transform(originalList, new CastFunction()); - System.out.println(selectedProducts); - } - - @SuppressWarnings({ "unchecked" }) - @Test - public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() { - final List originalList = Lists.newArrayList(); - final List selectedProducts = (List) (List) originalList; - System.out.println(selectedProducts); - } - - @Test - public final void whenAddingAnIterableToACollection_thenAddedOK() { - final Iterable iter = Lists.newArrayList(); - final Collection collector = Lists.newArrayList(); - Iterables.addAll(collector, iter); - } - - // - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch1_thenContains() { - final Iterable theCollection = Lists.newArrayList("a", "bc", "def"); - final boolean contains = Iterables.any(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }); - - assertTrue(contains); - } - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch2_thenContains() { - final Set theCollection = Sets.newHashSet("a", "bc", "def"); - - final boolean contains = !Sets.filter(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }).isEmpty(); - - assertTrue(contains); - } - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch3_thenContains() { - final Iterable theCollection = Sets.newHashSet("a", "bc", "def"); - - final boolean contains = Iterables.find(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }) != null; - - assertTrue(contains); - } - - // - - @Test(expected = NoSuchElementException.class) - public final void givenNoSearchResult_whenFindingElementInIterable_thenException() { - final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); - - final String found = Iterables.find(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }); - - assertNull(found); - } - - @Test - public final void givenNoSearchResult_whenFindingElementInIterableWithSpecifiedReturn_thenNoException() { - final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); - - final Predicate inputOfLengthOne = new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }; - final String found = Iterables.find(theCollection, inputOfLengthOne, null); - - assertNull(found); - } - - // purge of nulls - - @Test - public final void givenListContainsNulls_whenPurgedOfNulls_thenNoLongerContainsNulls() { - final List values = Lists.newArrayList("a", null, "b", "c"); - final Iterable withoutNulls = Iterables.filter(values, Predicates.notNull()); - System.out.println(withoutNulls); - } - - // immutable collections - - @Test - public final void whenCreatingImuutableCollections_thenNoExceptions() { - final ImmutableList immutableList = ImmutableList.of("a", "b", "c"); - final ImmutableSet immutableSet = ImmutableSet.of("a", "b", "c"); - final ImmutableMap imuttableMap = ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3"); - } - - @Test - public final void whenTransformingCollectionsToImmutable_thenNoExceptions() { - final List muttableList = Lists.newArrayList(); - final ImmutableList immutableList = ImmutableList.copyOf(muttableList); - - final Set muttableSet = Sets.newHashSet(); - final ImmutableSet immutableSet = ImmutableSet.copyOf(muttableSet); - - final Map muttableMap = Maps.newHashMap(); - final ImmutableMap imuttableMap = ImmutableMap.copyOf(muttableMap); - } - - @Test - public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExceptions() { - final List muttableList = Lists.newArrayList(); - final ImmutableList immutableList = ImmutableList. builder().addAll(muttableList).build(); - - final Set muttableSet = Sets.newHashSet(); - final ImmutableSet immutableSet = ImmutableSet. builder().addAll(muttableSet).build(); - - final Map muttableMap = Maps.newHashMap(); - final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); - } - - // unmodifiable - - @Test(expected = UnsupportedOperationException.class) - public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { - final List numbers = Lists.newArrayList(1, 2, 3); - final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); - final Iterator iterator = unmodifiableIterable.iterator(); - if (iterator.hasNext()) { - iterator.remove(); - } - } - -} diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java deleted file mode 100644 index 08091639f169..000000000000 --- a/mockito/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.baeldung.guava; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Collections2; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Ordering; -import com.google.common.collect.Sets; - -public class GuavaFunctionalExamplesTest { - - // tests - - // predicates - filtering - - @Test - public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { - final List numbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final List evenNumbers = Lists.newArrayList(Collections2.filter(numbers, acceptEvenNumber)); - - final Integer found = Collections.binarySearch(evenNumbers, 57); - assertThat(found, lessThan(0)); - } - - @Test - public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { - final List withNulls = Lists.newArrayList("a", "bc", null, "def"); - final Iterable withoutNuls = Iterables.filter(withNulls, Predicates.notNull()); - - assertTrue(Iterables.all(withoutNuls, Predicates.notNull())); - } - - // predicates - checking - - @Test - public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { - final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - - assertTrue(Iterables.all(evenNumbers, acceptEvenNumber)); - } - - // negating a predicate - - @Test - public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { - final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); - final Predicate acceptOddNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) != 0; - } - }; - - assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); - } - - // other predicates - - @Test - public final void when_thenCorrect() { - // CharMatcher.forPredicate(predicate) - } - - // functions - - @Test - public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() { - final List numbers = Lists.newArrayList(1, 2, 3); - final List numbersAsStrings = Lists.transform(numbers, Functions.toStringFunction()); - assertThat(numbersAsStrings, contains("1", "2", "3")); - } - - @Test - public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { - final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); - final List inAlphabeticalOrder = ordering.sortedCopy(numbersToSort); - - final List correctAlphabeticalOrder = Lists.newArrayList(1, 100, 11, 14, 2, 8); - assertThat(correctAlphabeticalOrder, equalTo(inAlphabeticalOrder)); - } - - @Test - public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { - final List numbers = Arrays.asList(2, 1, 11, 100, 8, 14); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - - final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbers).filter(acceptEvenNumber).transform(powerOfTwo); - assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); - } - - @Test - public final void whenUsingFunctionComposition_thenCorrectResults() { - final List numbers = Arrays.asList(2, 3); - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - - final List result = Lists.transform(numbers, Functions.compose(powerOfTwo, powerOfTwo)); - assertThat(result, contains(16, 81)); - } - - // Set+Function => Map - - /** - * - see: http://code.google.com/p/guava-libraries/issues/detail?id=56 - */ - @Test - public final void whenMapIsBackedBySetAndFunction_thenCorrect() { - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - final Set lowNumbers = Sets.newHashSet(2, 3, 4); - - final Map numberToPowerOfTwoMuttable = Maps.asMap(lowNumbers, powerOfTwo); - final Map numberToPowerOfTwoImuttable = Maps.toMap(lowNumbers, powerOfTwo); - assertThat(numberToPowerOfTwoMuttable.get(2), equalTo(4)); - assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); - } - - // Predicate => Function - - @Test - public final void whenConvertingPredicateToFunction_thenCorrect() { - final List numbers = Lists.newArrayList(1, 2, 3, 6); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final Function isEventNumberFunction = Functions.forPredicate(acceptEvenNumber); - final List areNumbersEven = Lists.transform(numbers, isEventNumberFunction); - - assertThat(areNumbersEven, contains(false, true, false, true)); - } - -} diff --git a/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java b/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java deleted file mode 100644 index 5821d19ba05b..000000000000 --- a/mockito/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.baeldung.guava; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.Test; - -import com.google.common.base.Functions; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.primitives.Ints; - -public class GuavaOrderingExamplesTest { - - private final class OrderingByLenght extends Ordering { - @Override - public final int compare(final String s1, final String s2) { - return Ints.compare(s1.length(), s2.length()); - } - } - - // tests - - // dealing with null - - @Test - public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsLast()); - assertThat(toSort.get(toSort.size() - 1), nullValue()); - } - - @Test - public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsFirst()); - assertThat(toSort.get(0), nullValue()); - } - - @Test - public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsLast().reverse()); - assertThat(toSort.get(0), nullValue()); - } - - // natural ordering - - @Test - public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { - final List toSort = Arrays.asList(3, 5, 4, 1, 2); - Collections.sort(toSort, Ordering.natural()); - - assertTrue(Ordering.natural().isOrdered(toSort)); - } - - // checking string ordering - - @Test - public final void givenCollectionContainsDuplicates_whenCheckingStringOrdering_thenNo() { - final List toSort = Arrays.asList(3, 5, 4, 2, 1, 2); - Collections.sort(toSort, Ordering.natural()); - - assertFalse(Ordering.natural().isStrictlyOrdered(toSort)); - } - - // custom - by length - - @Test - public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - Collections.sort(toSort, byLength); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - - Collections.sort(toSort, byLength); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrdering_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - - Collections.sort(toSort, byLength.compound(Ordering.natural())); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "zz", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsWithComplexOrderingExample_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", null, "b", "ccc"); - - Collections.sort(toSort, new OrderingByLenght().reverse().compound(Ordering.natural()).nullsLast()); - System.out.println(toSort); - } - - // sorted copy - - @Test - public final void givenUnorderdList_whenRetrievingSortedCopy_thenSorted() { - final List toSort = Arrays.asList("aa", "b", "ccc"); - final List sortedCopy = new OrderingByLenght().sortedCopy(toSort); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "ccc")); - assertFalse(expectedOrder.isOrdered(toSort)); - assertTrue(expectedOrder.isOrdered(sortedCopy)); - } - - // to string - - @Test - public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSortedWithToString() { - final List toSort = Arrays.asList(1, 2, 11); - Collections.sort(toSort, Ordering.usingToString()); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList(1, 11, 2)); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - // binary search - - @Test - public final void whenPerformingBinarySearch_thenFound() { - final List toSort = Arrays.asList(1, 2, 11); - Collections.sort(toSort, Ordering.usingToString()); - final int found = Ordering.usingToString().binarySearch(toSort, 2); - - System.out.println(found); - } - - // min/max without actually sorting - - @Test - public final void whenFindingTheMinimalElementWithoutSorting_thenFound() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final int found = Ordering.natural().min(toSort); - assertThat(found, equalTo(1)); - } - - @Test - public final void whenFindingTheFirstFewElements_thenCorrect() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final List leastOf = Ordering.natural().leastOf(toSort, 3); - final List expected = Lists.newArrayList(1, 2, 8); - assertThat(expected, equalTo(leastOf)); - } - - // order the results of a Function - - @Test - public final void givenListOfNumbers_whenRunningAToStringFunctionThenSorting_thenCorrect() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); - final List sortedCopy = ordering.sortedCopy(toSort); - - final List expected = Lists.newArrayList(1, 100, 11, 14, 2, 8); - assertThat(expected, equalTo(sortedCopy)); - } - -} diff --git a/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java deleted file mode 100644 index a44ce766f067..000000000000 --- a/mockito/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.baeldung.hamcrest; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.emptyArray; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.everyItem; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.hamcrest.Matchers; -import org.junit.Test; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class HamcrestExamplesTest { - - // tests - - @Test - public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasItem("cd")); - assertThat(collection, not(hasItem("zz"))); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasItems("ef", "cd")); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollectionInStrictOrder_thenCorrect2() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, contains("ab", "cd", "ef")); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollectionInAnyOrder_thenCorrect2() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, containsInAnyOrder("cd", "ab", "ef")); - } - - @Test - public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { - final List collection = Lists.newArrayList(); - assertThat(collection, empty()); - } - - @Test - public final void givenCollectionIsNotEmpty_whenChecking_thenNotEmpty() { - final List collection = Lists.newArrayList("a"); - assertThat(collection, not(empty())); - } - - @Test - public final void givenMapIsEmpty_whenChecking_thenEmpty() { - final Map collection = Maps.newHashMap(); - assertThat(collection, equalTo(Collections.EMPTY_MAP)); - } - - @Test - public final void givenArrayIsEmpty_whenChecking_thenEmpty() { - final String[] array = new String[] { "ab" }; - assertThat(array, not(emptyArray())); - } - - @Test - public final void whenCollectionSizeIsChecked_thenCorrect() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasSize(3)); - } - - @Test - public final void whenIterableSizeIsChecked_thenCorrect() { - final Iterable collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, Matchers. iterableWithSize(3)); - } - - @Test - public final void whenCheckingConditionOverEachItem_thenCorrect() { - final List collection = Lists.newArrayList(15, 20, 25, 30); - assertThat(collection, everyItem(greaterThan(10))); - } - -} diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java new file mode 100644 index 000000000000..001c055b4619 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java @@ -0,0 +1,14 @@ +package org.baeldung.mockito; + +import org.junit.Test; + +public class MockitoVerifyExamplesTest { + + // tests + + @Test + public final void when_thenCorrect() { + // + } + +} From 311e86fe254815df5ecd99ea1aa9193a9eda3c27 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 6 Nov 2013 16:37:38 +0200 Subject: [PATCH 309/796] verification work --- .../mockito/MockitoVerifyExamplesTest.java | 81 ++++++++++++++++++- .../java/org/baeldung/mockito/MyList.java | 17 ++++ 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 mockito/src/test/java/org/baeldung/mockito/MyList.java diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java index 001c055b4619..b2502d50fe0e 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java @@ -1,14 +1,91 @@ package org.baeldung.mockito; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.atMost; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; + +import java.util.List; + import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.Mockito; +import org.mockito.exceptions.verification.NoInteractionsWanted; public class MockitoVerifyExamplesTest { // tests @Test - public final void when_thenCorrect() { - // + public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList).size(); + } + + @Test + public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList, times(1)).size(); + } + + @Test + public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verifyZeroInteractions(mockedList); + } + + @Test + public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verify(mockedList, times(0)).size(); + } + + @Test(expected = NoInteractionsWanted.class) + public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.clear(); + + verify(mockedList).size(); + verifyNoMoreInteractions(mockedList); + } + + @Test + public final void whenVerifyingOrderOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.add("a parameter"); + mockedList.clear(); + + final InOrder inOrder = Mockito.inOrder(mockedList); + inOrder.verify(mockedList).size(); + inOrder.verify(mockedList).add("a parameter"); + inOrder.verify(mockedList).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + + verify(mockedList, never()).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.clear(); + mockedList.clear(); + mockedList.clear(); + + verify(mockedList, atLeast(1)).clear(); + verify(mockedList, atMost(10)).clear(); } } diff --git a/mockito/src/test/java/org/baeldung/mockito/MyList.java b/mockito/src/test/java/org/baeldung/mockito/MyList.java new file mode 100644 index 000000000000..23a8f65e6c61 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/mockito/MyList.java @@ -0,0 +1,17 @@ +package org.baeldung.mockito; + +import java.util.AbstractList; + +public class MyList extends AbstractList { + + @Override + public String get(final int index) { + return null; + } + + @Override + public int size() { + return 0; + } + +} From ae6082ccec9c54144e4bb7c1e29b5e90fc46f469 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 6 Nov 2013 17:02:13 +0200 Subject: [PATCH 310/796] further examples and doc work --- mockito/README.md | 4 +- .../mockito/MockitoVerifyExamplesTest.java | 172 +++++++++++------- 2 files changed, 105 insertions(+), 71 deletions(-) diff --git a/mockito/README.md b/mockito/README.md index d6d3ef275dad..3479832586ee 100644 --- a/mockito/README.md +++ b/mockito/README.md @@ -1,8 +1,8 @@ ========= -## Guava Cookbooks and Examples +## Mockito Cookbooks and Examples ### Relevant Articles: -- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) +- [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java index b2502d50fe0e..6875a9f81947 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java @@ -1,5 +1,8 @@ package org.baeldung.mockito; +import static org.hamcrest.Matchers.hasItem; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.mock; @@ -12,80 +15,111 @@ import java.util.List; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mockito; import org.mockito.exceptions.verification.NoInteractionsWanted; +import com.google.common.collect.Lists; + public class MockitoVerifyExamplesTest { - // tests - - @Test - public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - verify(mockedList).size(); - } - - @Test - public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - verify(mockedList, times(1)).size(); - } - - @Test - public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - verifyZeroInteractions(mockedList); - } - - @Test - public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - verify(mockedList, times(0)).size(); - } - - @Test(expected = NoInteractionsWanted.class) - public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { - final List mockedList = mock(MyList.class); - mockedList.size(); - mockedList.clear(); - - verify(mockedList).size(); - verifyNoMoreInteractions(mockedList); - } - - @Test - public final void whenVerifyingOrderOfInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - mockedList.add("a parameter"); - mockedList.clear(); - - final InOrder inOrder = Mockito.inOrder(mockedList); - inOrder.verify(mockedList).size(); - inOrder.verify(mockedList).add("a parameter"); - inOrder.verify(mockedList).clear(); - } - - @Test - public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - - verify(mockedList, never()).clear(); - } - - @Test - public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.clear(); - mockedList.clear(); - mockedList.clear(); - - verify(mockedList, atLeast(1)).clear(); - verify(mockedList, atMost(10)).clear(); - } + // tests + + @Test + public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList).size(); + } + + @Test + public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList, times(1)).size(); + } + + @Test + public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verifyZeroInteractions(mockedList); + } + + @Test + public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verify(mockedList, times(0)).size(); + } + + @Test(expected = NoInteractionsWanted.class) + public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.clear(); + + verify(mockedList).size(); + verifyNoMoreInteractions(mockedList); + } + + @Test + public final void whenVerifyingOrderOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.add("a parameter"); + mockedList.clear(); + + final InOrder inOrder = Mockito.inOrder(mockedList); + inOrder.verify(mockedList).size(); + inOrder.verify(mockedList).add("a parameter"); + inOrder.verify(mockedList).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + + verify(mockedList, never()).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.clear(); + mockedList.clear(); + mockedList.clear(); + + verify(mockedList, atLeast(1)).clear(); + verify(mockedList, atMost(10)).clear(); + } + + // with arguments + + @Test + public final void whenVerifyingAnInteractionWithExactArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add("test"); + } + + @Test + public final void whenVerifyingAnInteractionWithAnyArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add(anyString()); + } + + @Test + public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.addAll(Lists. newArrayList("someElement")); + final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class); + verify(mockedList).addAll(argumentCaptor.capture()); + final List capturedArgument = argumentCaptor.> getValue(); + assertThat(capturedArgument, hasItem("someElement")); + } } From a66b72b25e899790439921fd469ce2a63d4d8528 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Nov 2013 16:59:04 +0200 Subject: [PATCH 311/796] initial testing work for mockito configuration of behavior --- mockito/pom.xml | 18 ++++-- .../mockito/MockitoConfigExamplesTest.java | 60 +++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java diff --git a/mockito/pom.xml b/mockito/pom.xml index e5e2c604ab98..39ae7cc94ac8 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -17,6 +17,12 @@ 15.0 + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + @@ -73,12 +79,12 @@ - 3.2.4.RELEASE + 3.2.5.RELEASE 3.1.4.RELEASE - 4.2.4.Final - 5.1.26 + 4.2.7.SP1 + 5.1.27 1.7.5 @@ -96,14 +102,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.2.5 + 4.2.6 1.8.1 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java new file mode 100644 index 000000000000..7861741a79d2 --- /dev/null +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java @@ -0,0 +1,60 @@ +package org.baeldung.mockito; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.mockito.Mockito; + +@SuppressWarnings("unchecked") +public class MockitoConfigExamplesTest { + + // tests + + @Test + public final void whenMockBehaviorIsConfigured_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + + @Test(expected = IllegalStateException.class) + public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = NullPointerException.class) + public final void whenMethodHasNoReturnType_whenConfiguringBehaviorOfMethod_thenPossible() { + final MyList listMock = Mockito.mock(MyList.class); + doThrow(NullPointerException.class).when(listMock).clear(); + + listMock.clear(); + } + + @Test + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingOnlyOnce_thenNoExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = IllegalStateException.class) + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingTwice_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + listMock.add(randomAlphabetic(6)); + } + +} From 6ed93723b8981ca3cca984986f9e5b263b2d892b Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Nov 2013 17:49:27 +0200 Subject: [PATCH 312/796] mockito further examples --- .../mockito/MockitoConfigExamplesTest.java | 49 ++++++++++++++++++- .../java/org/baeldung/mockito/MyList.java | 16 +++--- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java index 7861741a79d2..399c511d4e04 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java @@ -1,22 +1,27 @@ package org.baeldung.mockito; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; import org.junit.Test; import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; -@SuppressWarnings("unchecked") public class MockitoConfigExamplesTest { // tests @Test - public final void whenMockBehaviorIsConfigured_thenBehaviorIsVerified() { + public final void whenMockReturnBehaviorIsConfigured_thenBehaviorIsVerified() { final MyList listMock = Mockito.mock(MyList.class); when(listMock.add(anyString())).thenReturn(false); @@ -24,6 +29,15 @@ public final void whenMockBehaviorIsConfigured_thenBehaviorIsVerified() { assertThat(added, is(false)); } + @Test + public final void whenMockReturnBehaviorIsConfigured2_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + doReturn(false).when(listMock).add(anyString()); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + @Test(expected = IllegalStateException.class) public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() { final MyList listMock = Mockito.mock(MyList.class); @@ -57,4 +71,35 @@ public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCall listMock.add(randomAlphabetic(6)); } + @Test + public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMetehodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.size()).thenCallRealMethod(); + + assertThat(listMock.size(), equalTo(1)); + } + + @Test + public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMetehodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + doAnswer(new Answer() { + @Override + public final String answer(final InvocationOnMock invocation) { + return "Always the same"; + } + }).when(listMock).get(anyInt()); + + final String element = listMock.get(1); + assertThat(element, is(equalTo("Always the same"))); + } + + @Test(expected = NullPointerException.class) + public final void givenSpy_whenConfiguringBehaviorOfSpy_thenCorrectlyConfigured() { + final MyList instance = new MyList(); + final MyList spy = Mockito.spy(instance); + + doThrow(NullPointerException.class).when(spy).size(); + spy.size(); + } + } diff --git a/mockito/src/test/java/org/baeldung/mockito/MyList.java b/mockito/src/test/java/org/baeldung/mockito/MyList.java index 23a8f65e6c61..548596e6b6e1 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MyList.java +++ b/mockito/src/test/java/org/baeldung/mockito/MyList.java @@ -4,14 +4,14 @@ public class MyList extends AbstractList { - @Override - public String get(final int index) { - return null; - } + @Override + public String get(final int index) { + return null; + } - @Override - public int size() { - return 0; - } + @Override + public int size() { + return 1; + } } From fb407c845a542206b177d7f6707b5e0b268ed7d3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 19 Nov 2013 16:16:23 +0200 Subject: [PATCH 313/796] new httpclient sample project --- httpclient/.classpath | 36 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + httpclient/.gitignore | 13 ++ httpclient/.project | 36 +++++ httpclient/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 +++++++++++++ httpclient/.settings/org.eclipse.jdt.ui.prefs | 55 ++++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 ++ ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + httpclient/.springBeans | 14 ++ httpclient/README.md | 8 ++ httpclient/pom.xml | 116 ++++++++++++++++ httpclient/src/main/resources/logback.xml | 20 +++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + httpclient/src/main/webapp/WEB-INF/web.xml | 42 ++++++ .../mockito/MockitoConfigExamplesTest.java | 105 +++++++++++++++ .../mockito/MockitoVerifyExamplesTest.java | 125 ++++++++++++++++++ .../java/org/baeldung/mockito/MyList.java | 17 +++ httpclient/src/test/resources/.gitignore | 13 ++ 25 files changed, 749 insertions(+) create mode 100644 httpclient/.classpath create mode 100644 httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 httpclient/.gitignore create mode 100644 httpclient/.project create mode 100644 httpclient/.settings/.jsdtscope create mode 100644 httpclient/.settings/org.eclipse.jdt.core.prefs create mode 100644 httpclient/.settings/org.eclipse.jdt.ui.prefs create mode 100644 httpclient/.settings/org.eclipse.m2e.core.prefs create mode 100644 httpclient/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 httpclient/.settings/org.eclipse.wst.common.component create mode 100644 httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 httpclient/.settings/org.eclipse.wst.validation.prefs create mode 100644 httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 httpclient/.springBeans create mode 100644 httpclient/README.md create mode 100644 httpclient/pom.xml create mode 100644 httpclient/src/main/resources/logback.xml create mode 100644 httpclient/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 httpclient/src/main/webapp/WEB-INF/web.xml create mode 100644 httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java create mode 100644 httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java create mode 100644 httpclient/src/test/java/org/baeldung/mockito/MyList.java create mode 100644 httpclient/src/test/resources/.gitignore diff --git a/httpclient/.classpath b/httpclient/.classpath new file mode 100644 index 000000000000..c370943e8c83 --- /dev/null +++ b/httpclient/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/httpclient/.gitignore b/httpclient/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/httpclient/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/httpclient/.project b/httpclient/.project new file mode 100644 index 000000000000..83c3ed049314 --- /dev/null +++ b/httpclient/.project @@ -0,0 +1,36 @@ + + + httpclient + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/httpclient/.settings/.jsdtscope b/httpclient/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/httpclient/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/httpclient/.settings/org.eclipse.jdt.core.prefs b/httpclient/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/httpclient/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/httpclient/.settings/org.eclipse.jdt.ui.prefs b/httpclient/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/httpclient/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/httpclient/.settings/org.eclipse.m2e.core.prefs b/httpclient/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/httpclient/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/httpclient/.settings/org.eclipse.m2e.wtp.prefs b/httpclient/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/httpclient/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/httpclient/.settings/org.eclipse.wst.common.component b/httpclient/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml b/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/httpclient/.settings/org.eclipse.wst.validation.prefs b/httpclient/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs b/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/httpclient/.springBeans b/httpclient/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/httpclient/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/httpclient/README.md b/httpclient/README.md new file mode 100644 index 000000000000..3479832586ee --- /dev/null +++ b/httpclient/README.md @@ -0,0 +1,8 @@ +========= + +## Mockito Cookbooks and Examples + + +### Relevant Articles: +- [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) + diff --git a/httpclient/pom.xml b/httpclient/pom.xml new file mode 100644 index 000000000000..cf6ba14ed686 --- /dev/null +++ b/httpclient/pom.xml @@ -0,0 +1,116 @@ + + 4.0.0 + org.baeldung + httpclient + 0.1-SNAPSHOT + + httpclient + + + + + + + com.google.guava + guava + 15.0 + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 3.2.5.RELEASE + 3.1.4.RELEASE + + + 4.2.7.SP1 + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 1.8.1 + 1.8.9 + + + 1.4.5 + 2.16 + + + \ No newline at end of file diff --git a/httpclient/src/main/resources/logback.xml b/httpclient/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/httpclient/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/httpclient/src/main/webapp/WEB-INF/web.xml b/httpclient/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/httpclient/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java new file mode 100644 index 000000000000..399c511d4e04 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java @@ -0,0 +1,105 @@ +package org.baeldung.mockito; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +public class MockitoConfigExamplesTest { + + // tests + + @Test + public final void whenMockReturnBehaviorIsConfigured_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + + @Test + public final void whenMockReturnBehaviorIsConfigured2_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + doReturn(false).when(listMock).add(anyString()); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + + @Test(expected = IllegalStateException.class) + public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = NullPointerException.class) + public final void whenMethodHasNoReturnType_whenConfiguringBehaviorOfMethod_thenPossible() { + final MyList listMock = Mockito.mock(MyList.class); + doThrow(NullPointerException.class).when(listMock).clear(); + + listMock.clear(); + } + + @Test + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingOnlyOnce_thenNoExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = IllegalStateException.class) + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingTwice_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + listMock.add(randomAlphabetic(6)); + } + + @Test + public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMetehodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.size()).thenCallRealMethod(); + + assertThat(listMock.size(), equalTo(1)); + } + + @Test + public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMetehodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + doAnswer(new Answer() { + @Override + public final String answer(final InvocationOnMock invocation) { + return "Always the same"; + } + }).when(listMock).get(anyInt()); + + final String element = listMock.get(1); + assertThat(element, is(equalTo("Always the same"))); + } + + @Test(expected = NullPointerException.class) + public final void givenSpy_whenConfiguringBehaviorOfSpy_thenCorrectlyConfigured() { + final MyList instance = new MyList(); + final MyList spy = Mockito.spy(instance); + + doThrow(NullPointerException.class).when(spy).size(); + spy.size(); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java new file mode 100644 index 000000000000..6875a9f81947 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java @@ -0,0 +1,125 @@ +package org.baeldung.mockito; + +import static org.hamcrest.Matchers.hasItem; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.atMost; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; + +import java.util.List; + +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.InOrder; +import org.mockito.Mockito; +import org.mockito.exceptions.verification.NoInteractionsWanted; + +import com.google.common.collect.Lists; + +public class MockitoVerifyExamplesTest { + + // tests + + @Test + public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList).size(); + } + + @Test + public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList, times(1)).size(); + } + + @Test + public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verifyZeroInteractions(mockedList); + } + + @Test + public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verify(mockedList, times(0)).size(); + } + + @Test(expected = NoInteractionsWanted.class) + public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.clear(); + + verify(mockedList).size(); + verifyNoMoreInteractions(mockedList); + } + + @Test + public final void whenVerifyingOrderOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.add("a parameter"); + mockedList.clear(); + + final InOrder inOrder = Mockito.inOrder(mockedList); + inOrder.verify(mockedList).size(); + inOrder.verify(mockedList).add("a parameter"); + inOrder.verify(mockedList).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + + verify(mockedList, never()).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.clear(); + mockedList.clear(); + mockedList.clear(); + + verify(mockedList, atLeast(1)).clear(); + verify(mockedList, atMost(10)).clear(); + } + + // with arguments + + @Test + public final void whenVerifyingAnInteractionWithExactArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add("test"); + } + + @Test + public final void whenVerifyingAnInteractionWithAnyArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add(anyString()); + } + + @Test + public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.addAll(Lists. newArrayList("someElement")); + final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class); + verify(mockedList).addAll(argumentCaptor.capture()); + final List capturedArgument = argumentCaptor.> getValue(); + assertThat(capturedArgument, hasItem("someElement")); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/mockito/MyList.java b/httpclient/src/test/java/org/baeldung/mockito/MyList.java new file mode 100644 index 000000000000..548596e6b6e1 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/mockito/MyList.java @@ -0,0 +1,17 @@ +package org.baeldung.mockito; + +import java.util.AbstractList; + +public class MyList extends AbstractList { + + @Override + public String get(final int index) { + return null; + } + + @Override + public int size() { + return 1; + } + +} diff --git a/httpclient/src/test/resources/.gitignore b/httpclient/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/httpclient/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 2448ea7e478dee90a7e4ee6a2b1e0addfe2d9e53 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 19 Nov 2013 16:27:25 +0200 Subject: [PATCH 314/796] cleanup work before starting to implement examples --- httpclient/README.md | 1 - httpclient/pom.xml | 2 +- .../baeldung/mockito/HttpClientLiveTest.java | 5 + .../mockito/MockitoConfigExamplesTest.java | 105 --------------- .../mockito/MockitoVerifyExamplesTest.java | 125 ------------------ .../java/org/baeldung/mockito/MyList.java | 17 --- 6 files changed, 6 insertions(+), 249 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java delete mode 100644 httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java delete mode 100644 httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java delete mode 100644 httpclient/src/test/java/org/baeldung/mockito/MyList.java diff --git a/httpclient/README.md b/httpclient/README.md index 3479832586ee..a480372c5f2a 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -4,5 +4,4 @@ ### Relevant Articles: -- [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index cf6ba14ed686..7ce13c1b817a 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -57,7 +57,7 @@ - spring-rest + httpclient src/main/resources diff --git a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java new file mode 100644 index 000000000000..81e6fb8b257e --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java @@ -0,0 +1,5 @@ +package org.baeldung.mockito; + +public class HttpClientLiveTest { + // +} diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java deleted file mode 100644 index 399c511d4e04..000000000000 --- a/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.baeldung.mockito; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -import org.junit.Test; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -public class MockitoConfigExamplesTest { - - // tests - - @Test - public final void whenMockReturnBehaviorIsConfigured_thenBehaviorIsVerified() { - final MyList listMock = Mockito.mock(MyList.class); - when(listMock.add(anyString())).thenReturn(false); - - final boolean added = listMock.add(randomAlphabetic(6)); - assertThat(added, is(false)); - } - - @Test - public final void whenMockReturnBehaviorIsConfigured2_thenBehaviorIsVerified() { - final MyList listMock = Mockito.mock(MyList.class); - doReturn(false).when(listMock).add(anyString()); - - final boolean added = listMock.add(randomAlphabetic(6)); - assertThat(added, is(false)); - } - - @Test(expected = IllegalStateException.class) - public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() { - final MyList listMock = Mockito.mock(MyList.class); - when(listMock.add(anyString())).thenThrow(IllegalStateException.class); - - listMock.add(randomAlphabetic(6)); - } - - @Test(expected = NullPointerException.class) - public final void whenMethodHasNoReturnType_whenConfiguringBehaviorOfMethod_thenPossible() { - final MyList listMock = Mockito.mock(MyList.class); - doThrow(NullPointerException.class).when(listMock).clear(); - - listMock.clear(); - } - - @Test - public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingOnlyOnce_thenNoExceptionIsThrown() { - final MyList listMock = Mockito.mock(MyList.class); - when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); - - listMock.add(randomAlphabetic(6)); - } - - @Test(expected = IllegalStateException.class) - public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingTwice_thenExceptionIsThrown() { - final MyList listMock = Mockito.mock(MyList.class); - when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); - - listMock.add(randomAlphabetic(6)); - listMock.add(randomAlphabetic(6)); - } - - @Test - public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMetehodIsCalled() { - final MyList listMock = Mockito.mock(MyList.class); - when(listMock.size()).thenCallRealMethod(); - - assertThat(listMock.size(), equalTo(1)); - } - - @Test - public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMetehodIsCalled() { - final MyList listMock = Mockito.mock(MyList.class); - doAnswer(new Answer() { - @Override - public final String answer(final InvocationOnMock invocation) { - return "Always the same"; - } - }).when(listMock).get(anyInt()); - - final String element = listMock.get(1); - assertThat(element, is(equalTo("Always the same"))); - } - - @Test(expected = NullPointerException.class) - public final void givenSpy_whenConfiguringBehaviorOfSpy_thenCorrectlyConfigured() { - final MyList instance = new MyList(); - final MyList spy = Mockito.spy(instance); - - doThrow(NullPointerException.class).when(spy).size(); - spy.size(); - } - -} diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java deleted file mode 100644 index 6875a9f81947..000000000000 --- a/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.baeldung.mockito; - -import static org.hamcrest.Matchers.hasItem; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.atMost; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; - -import java.util.List; - -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InOrder; -import org.mockito.Mockito; -import org.mockito.exceptions.verification.NoInteractionsWanted; - -import com.google.common.collect.Lists; - -public class MockitoVerifyExamplesTest { - - // tests - - @Test - public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - verify(mockedList).size(); - } - - @Test - public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - verify(mockedList, times(1)).size(); - } - - @Test - public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - verifyZeroInteractions(mockedList); - } - - @Test - public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - verify(mockedList, times(0)).size(); - } - - @Test(expected = NoInteractionsWanted.class) - public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { - final List mockedList = mock(MyList.class); - mockedList.size(); - mockedList.clear(); - - verify(mockedList).size(); - verifyNoMoreInteractions(mockedList); - } - - @Test - public final void whenVerifyingOrderOfInteractions_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - mockedList.add("a parameter"); - mockedList.clear(); - - final InOrder inOrder = Mockito.inOrder(mockedList); - inOrder.verify(mockedList).size(); - inOrder.verify(mockedList).add("a parameter"); - inOrder.verify(mockedList).clear(); - } - - @Test - public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.size(); - - verify(mockedList, never()).clear(); - } - - @Test - public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.clear(); - mockedList.clear(); - mockedList.clear(); - - verify(mockedList, atLeast(1)).clear(); - verify(mockedList, atMost(10)).clear(); - } - - // with arguments - - @Test - public final void whenVerifyingAnInteractionWithExactArgument_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.add("test"); - - verify(mockedList).add("test"); - } - - @Test - public final void whenVerifyingAnInteractionWithAnyArgument_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.add("test"); - - verify(mockedList).add(anyString()); - } - - @Test - public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() { - final List mockedList = mock(MyList.class); - mockedList.addAll(Lists. newArrayList("someElement")); - final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class); - verify(mockedList).addAll(argumentCaptor.capture()); - final List capturedArgument = argumentCaptor.> getValue(); - assertThat(capturedArgument, hasItem("someElement")); - } - -} diff --git a/httpclient/src/test/java/org/baeldung/mockito/MyList.java b/httpclient/src/test/java/org/baeldung/mockito/MyList.java deleted file mode 100644 index 548596e6b6e1..000000000000 --- a/httpclient/src/test/java/org/baeldung/mockito/MyList.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.mockito; - -import java.util.AbstractList; - -public class MyList extends AbstractList { - - @Override - public String get(final int index) { - return null; - } - - @Override - public int size() { - return 1; - } - -} From 6b45feb185a2570131d42c3cee5afd8381055c11 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 19 Nov 2013 18:02:45 +0200 Subject: [PATCH 315/796] Dependencies and custom logic --- httpclient/pom.xml | 8 ++- .../baeldung/mockito/HttpClientLiveTest.java | 63 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 7ce13c1b817a..3f3f0f3cdef8 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -23,7 +23,13 @@ ${commons-lang3.version} - + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + diff --git a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java index 81e6fb8b257e..997f5a012ae3 100644 --- a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java @@ -1,5 +1,66 @@ package org.baeldung.mockito; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.net.SocketTimeoutException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.junit.Before; +import org.junit.Test; + public class HttpClientLiveTest { - // + + private static final String SAMPLE_URL = "http://www.google.com"; + + private HttpClient instance; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + // tests + + @Test + public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { + instance.execute(new HttpGet(SAMPLE_URL)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { + final HttpResponse response = instance.execute(new HttpGet(SAMPLE_URL)); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { + final HttpResponse response = instance.execute(new HttpGet(SAMPLE_URL)); + final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); + + assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); + } + + @Test(expected = SocketTimeoutException.class) + public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws ClientProtocolException, IOException { + final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(50).build(); + final HttpGet request = new HttpGet(SAMPLE_URL); + request.setConfig(requestConfig); + instance.execute(request); + } + + @Test + public final void givenHttpClientIsConfiguredWithCustomConnectionManager_whenExecutingRequest_thenNoExceptions() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().setConnectionManager(new BasicHttpClientConnectionManager()).build(); + instance.execute(new HttpGet(SAMPLE_URL)); + } + } From 1ea85b4a62a06ab64e810793c2a01dc09459892d Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 19 Nov 2013 18:40:58 +0200 Subject: [PATCH 316/796] new examples for cookbook --- .../baeldung/mockito/HttpClientLiveTest.java | 84 +++++++++++++++++-- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java index 997f5a012ae3..8c478c334e6f 100644 --- a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java @@ -1,19 +1,29 @@ package org.baeldung.mockito; +import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; import java.io.IOException; +import java.io.InputStream; import java.net.SocketTimeoutException; -import org.apache.http.HttpResponse; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.apache.http.util.EntityUtils; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -21,15 +31,36 @@ public class HttpClientLiveTest { private static final String SAMPLE_URL = "http://www.google.com"; - private HttpClient instance; + private CloseableHttpClient instance; + + private CloseableHttpResponse response; @Before public final void before() { instance = HttpClientBuilder.create().build(); } + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + // tests + // simple request - response + @Test public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { instance.execute(new HttpGet(SAMPLE_URL)); @@ -37,30 +68,69 @@ public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientP @Test public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { - final HttpResponse response = instance.execute(new HttpGet(SAMPLE_URL)); + response = instance.execute(new HttpGet(SAMPLE_URL)); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } @Test public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { - final HttpResponse response = instance.execute(new HttpGet(SAMPLE_URL)); + response = instance.execute(new HttpGet(SAMPLE_URL)); final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); } + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBody() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final String bodyAsString = EntityUtils.toString(response.getEntity()); + + assertThat(bodyAsString, notNullValue()); + } + @Test(expected = SocketTimeoutException.class) public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws ClientProtocolException, IOException { final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(50).build(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setConfig(requestConfig); - instance.execute(request); + response = instance.execute(request); + } + + // tests - non-GET + + @Test + public final void whenExecutingBasicRequest_thenNoExceptions() throws ClientProtocolException, IOException { + instance.execute(new HttpPost(SAMPLE_URL)); } + // tests - configs + @Test public final void givenHttpClientIsConfiguredWithCustomConnectionManager_whenExecutingRequest_thenNoExceptions() throws ClientProtocolException, IOException { instance = HttpClientBuilder.create().setConnectionManager(new BasicHttpClientConnectionManager()).build(); - instance.execute(new HttpGet(SAMPLE_URL)); + response = instance.execute(new HttpGet(SAMPLE_URL)); + } + + @Test + public final void givenRedirectsAreDisabled_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().disableRedirectHandling().build(); + response = instance.execute(new HttpGet("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); + } + + @Test + public final void givenCustomHeaderIsSet_whenSendingRequest_thenNoExceptions() throws ClientProtocolException, IOException { + final HttpGet request = new HttpGet(SAMPLE_URL); + request.addHeader(HttpHeaders.ACCEPT, "application/xml"); + response = instance.execute(request); + } + + @Test + public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCorrect() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + + final Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE); + assertThat(headers, not(emptyArray())); } } From 3a4edeeabe94bc791554ee4f1ec7cc69e0e9ea91 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 19 Nov 2013 21:04:22 +0200 Subject: [PATCH 317/796] http client examples cleanup --- .../src/test/java/org/baeldung/mockito/HttpClientLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java index 8c478c334e6f..064ace1d2c03 100644 --- a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java @@ -63,7 +63,7 @@ public final void after() throws IllegalStateException, IOException { @Test public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { - instance.execute(new HttpGet(SAMPLE_URL)); + response = instance.execute(new HttpGet(SAMPLE_URL)); } @Test From 152132b1d54a5d0aeb068e7588268976afa340ab Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 24 Nov 2013 20:09:17 +0200 Subject: [PATCH 318/796] documentation cleanup --- guava/README.md | 5 ++++- httpclient/README.md | 4 ++-- mockito/README.md | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/guava/README.md b/guava/README.md index d6d3ef275dad..3b9a2800d699 100644 --- a/guava/README.md +++ b/guava/README.md @@ -1,8 +1,11 @@ ========= -## Guava Cookbooks and Examples +## Guava and Hamcrest Cookbooks and Examples ### Relevant Articles: - [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) +- [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) +- [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) +- [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) diff --git a/httpclient/README.md b/httpclient/README.md index a480372c5f2a..907630299207 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -1,7 +1,7 @@ ========= -## Mockito Cookbooks and Examples +## HttpClient 4.x Cookbooks and Examples ### Relevant Articles: - +- [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) diff --git a/mockito/README.md b/mockito/README.md index 3479832586ee..5ecc5722b08b 100644 --- a/mockito/README.md +++ b/mockito/README.md @@ -5,4 +5,5 @@ ### Relevant Articles: - [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) +- [Mockito When/Then Cookbook](http://www.baeldung.com/mockito-behavior) From 930c34c8d3bbb61485664d3a953e22c8b231954f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 6 Dec 2013 11:26:26 +0200 Subject: [PATCH 319/796] Eclipse cleanup and maven build fix --- spring-mvc-java/.classpath | 7 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +- .../org.eclipse.wst.common.component | 2 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- .../org.eclipse.wst.validation.prefs | 3 +- spring-mvc-java/pom.xml | 331 ++++++++++-------- 6 files changed, 187 insertions(+), 164 deletions(-) diff --git a/spring-mvc-java/.classpath b/spring-mvc-java/.classpath index efc51b414b0b..26784dcaf4e7 100644 --- a/spring-mvc-java/.classpath +++ b/spring-mvc-java/.classpath @@ -22,14 +22,15 @@ - + + - + - + diff --git a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs index 0924ed68cff2..0f5e3349075a 100644 --- a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs @@ -5,8 +5,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -88,4 +88,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/spring-mvc-java/.settings/org.eclipse.wst.common.component b/spring-mvc-java/.settings/org.eclipse.wst.common.component index 73770253eef9..386dfc1dcd10 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-java/.settings/org.eclipse.wst.common.component @@ -4,7 +4,7 @@ - + diff --git a/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml index a67649dfa5ae..546ff4ce8c9b 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,6 @@ - + diff --git a/spring-mvc-java/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-java/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.validation.prefs +++ b/spring-mvc-java/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 038e70b84590..0cf687e6f7a3 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -1,158 +1,179 @@ - 4.0.0 - org.baeldung - spring-mvc-java - 0.1-SNAPSHOT - - spring-mvc-java - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-mvc - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.4.RELEASE - 3.1.4.RELEASE - - - 4.2.4.Final - 5.1.26 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 14.0.1 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.2.4 - 4.2.5 - - 1.8.1 - 1.8.9 - - - 1.4.3 - 2.16 - + 4.0.0 + org.baeldung + spring-mvc-java + 0.1-SNAPSHOT + + spring-mvc-java + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-mvc + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-war-plugin + 2.4 + + false + + + + + + + + + + 3.2.5.RELEASE + 3.1.4.RELEASE + + + 4.2.8.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.0.1 + 1.8.9 + + + 1.4.5 + 3.1 + 2.6 + 2.16 + + \ No newline at end of file From 3fccfb34007f58549807dde401e17e90b2ddfbd0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 12:21:42 +0200 Subject: [PATCH 320/796] maven upgrades --- experiments/pom.xml | 14 +++++++------- guava/pom.xml | 12 ++++++------ httpclient/pom.xml | 2 +- mockito/pom.xml | 2 +- spring-all/pom.xml | 16 ++++++++-------- spring-exceptions/pom.xml | 16 ++++++++-------- spring-hibernate3/pom.xml | 14 +++++++------- spring-hibernate4/pom.xml | 16 ++++++++-------- spring-jpa/pom.xml | 14 +++++++------- spring-mvc-no-xml/pom.xml | 10 +++++----- spring-mvc-xml/pom.xml | 10 +++++----- spring-rest/pom.xml | 14 +++++++------- spring-security-basic-auth/pom.xml | 14 +++++++------- spring-security-mvc-custom/pom.xml | 14 +++++++------- spring-security-mvc-digest-auth/pom.xml | 14 +++++++------- spring-security-mvc-login/pom.xml | 14 +++++++------- spring-security-mvc-session/pom.xml | 14 +++++++------- spring-security-rest-basic-auth/pom.xml | 14 +++++++------- spring-security-rest-custom/pom.xml | 14 +++++++------- spring-security-rest-digest-auth/pom.xml | 14 +++++++------- spring-security-rest-full/pom.xml | 14 +++++++------- spring-security-rest/pom.xml | 14 +++++++------- 22 files changed, 140 insertions(+), 140 deletions(-) diff --git a/experiments/pom.xml b/experiments/pom.xml index f92ef16c8d52..60d3f5febc65 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -245,11 +245,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -260,7 +260,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -268,14 +268,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/guava/pom.xml b/guava/pom.xml index e5e2c604ab98..53e8ea815a0d 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -73,11 +73,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -96,14 +96,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 3f3f0f3cdef8..b90f6c69e14e 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -111,7 +111,7 @@ 4.3 4.3.1 - 1.8.1 + 2.1.0 1.8.9 diff --git a/mockito/pom.xml b/mockito/pom.xml index 39ae7cc94ac8..86b7ecdf91eb 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -105,7 +105,7 @@ 4.2.5 4.2.6 - 1.8.1 + 2.1.0 1.8.9 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 12ac684ffdd1..b5d306436d4d 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -182,13 +182,13 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 3.18.0-GA + 3.18.1-GA 1.2 - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -199,7 +199,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -207,14 +207,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 3e4f4f1241fb..b06fad36c8b8 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -193,13 +193,13 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 3.18.0-GA + 3.18.1-GA 1.2 - 4.2.4.Final + 4.3.0.Final 5.1.26 7.0.42 @@ -211,7 +211,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -219,14 +219,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 9cb4b4d01a38..6c76a8a0bfd0 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -158,9 +158,9 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 3.18.0-GA + 3.18.1-GA 3.6.10.Final @@ -175,7 +175,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -183,14 +183,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 6c9d64c5191e..d55b43f69287 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -166,12 +166,12 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 3.18.0-GA + 3.18.1-GA - 4.2.4.Final + 4.3.0.Final 5.1.26 7.0.42 @@ -183,7 +183,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -191,14 +191,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 65c6bace8779..bd495c3a2608 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -160,11 +160,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -175,7 +175,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -183,14 +183,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index ea0f92cdfd1c..ccff21aa6458 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -110,7 +110,7 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 1.7.5 @@ -121,14 +121,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 2.4 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index eb390e738a15..764a85260d00 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -101,7 +101,7 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 1.7.5 @@ -112,14 +112,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index d4c58cd7bbe0..e703d2eb168e 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -121,11 +121,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -136,7 +136,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -144,14 +144,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 2fc3dc000764..8eb53fbde44b 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -179,11 +179,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -194,7 +194,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -202,14 +202,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 73e3ea9cee1a..87eabffd8098 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -183,11 +183,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -198,7 +198,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -206,14 +206,14 @@ 4.11 1.9.5 - 4.2.5 - 4.2.4 + 4.3.1 + 4.3 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 300825ca4428..a9ea234b6c5a 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -179,11 +179,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -194,7 +194,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -202,14 +202,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 1b788afa414d..da46cbe1892f 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -175,11 +175,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -190,7 +190,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -198,14 +198,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index a04a7f0da4b2..ff496deed15c 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -183,11 +183,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -198,7 +198,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -206,14 +206,14 @@ 4.11 1.9.5 - 4.2.5 - 4.2.4 + 4.3.1 + 4.3 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 0ee8056b0577..ffc3199bdff9 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -280,16 +280,16 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 1.7.5 @@ -299,7 +299,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -307,11 +307,11 @@ 4.11 1.9.5 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 880fb314e7b1..363d51d3af45 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -235,11 +235,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -250,7 +250,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -258,14 +258,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 1c472b6016c1..643697b7ccd8 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -268,16 +268,16 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 1.7.5 @@ -287,7 +287,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -295,11 +295,11 @@ 4.11 1.9.5 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 1d3368c456ed..2f62544bf23b 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -216,11 +216,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 1.3.2.RELEASE @@ -236,7 +236,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -244,14 +244,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 3a2b884cb77f..3ceba77ca89f 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -192,11 +192,11 @@ - 3.2.4.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.4.Final + 4.3.0.Final 5.1.26 @@ -207,7 +207,7 @@ 5.0.1.Final - 14.0.1 + 15.0 3.1 @@ -215,14 +215,14 @@ 4.11 1.9.5 - 4.2.4 - 4.2.5 + 4.3 + 4.3.1 - 1.8.1 + 2.1.0 1.8.9 - 1.4.3 + 1.4.5 2.16 From 7faea3a5693c817423fd2f7fd60ccf7ff7c308f3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 12:26:02 +0200 Subject: [PATCH 321/796] maven upgrades --- experiments/pom.xml | 2 +- guava/pom.xml | 2 +- httpclient/pom.xml | 4 ++-- mockito/pom.xml | 8 ++++---- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- spring-hibernate3/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- spring-jpa/pom.xml | 2 +- spring-mvc-java/pom.xml | 7 ++++--- spring-rest/pom.xml | 2 +- spring-security-basic-auth/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 2 +- spring-security-mvc-login/pom.xml | 2 +- spring-security-mvc-session/pom.xml | 2 +- spring-security-rest-basic-auth/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-digest-auth/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 21 files changed, 28 insertions(+), 27 deletions(-) diff --git a/experiments/pom.xml b/experiments/pom.xml index 60d3f5febc65..0c83141f7591 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -250,7 +250,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/guava/pom.xml b/guava/pom.xml index 53e8ea815a0d..adab96cf3ffc 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -78,7 +78,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index b90f6c69e14e..699f8c6ed176 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -85,11 +85,11 @@ - 3.2.5.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.7.SP1 + 4.3.0.Final 5.1.27 diff --git a/mockito/pom.xml b/mockito/pom.xml index 86b7ecdf91eb..348fd8dcb5fe 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -79,11 +79,11 @@ - 3.2.5.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.7.SP1 + 4.3.0.Final 5.1.27 @@ -102,8 +102,8 @@ 4.11 1.9.5 - 4.2.5 - 4.2.6 + 4.3 + 4.3.1 2.1.0 1.8.9 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index b5d306436d4d..c98aa24fc858 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -189,7 +189,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index b06fad36c8b8..2dd1f46bb455 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -200,7 +200,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 7.0.42 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 6c76a8a0bfd0..2019b53a2b74 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -164,7 +164,7 @@ 3.6.10.Final - 5.1.26 + 5.1.27 7.0.41 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index d55b43f69287..070a9d8f3f4a 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -172,7 +172,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 7.0.42 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index bd495c3a2608..0dc7fce652e3 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -165,7 +165,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 0cf687e6f7a3..230e0b93429e 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -127,7 +127,7 @@ org.apache.maven.plugins maven-war-plugin - 2.4 + ${maven-war-plugin.version} false @@ -139,11 +139,11 @@ - 3.2.5.RELEASE + 3.2.6.RELEASE 3.1.4.RELEASE - 4.2.8.Final + 4.3.0.Final 5.1.27 @@ -173,6 +173,7 @@ 3.1 2.6 2.16 + 2.4 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index e703d2eb168e..7e86a5d59b4e 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -126,7 +126,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 8eb53fbde44b..a7b77f3b4b21 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -184,7 +184,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 87eabffd8098..b4842ec74c03 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -188,7 +188,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index a9ea234b6c5a..2aa998f70679 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -184,7 +184,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index da46cbe1892f..a075e64a13b2 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -180,7 +180,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index ff496deed15c..ca4eedefe5d2 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -188,7 +188,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index ffc3199bdff9..bde8f98a4f01 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -285,7 +285,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 4.3 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 363d51d3af45..cd946897a83e 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -240,7 +240,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 643697b7ccd8..94712aee2585 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -273,7 +273,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 4.3 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 2f62544bf23b..dd360dcda60e 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -221,7 +221,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.3.2.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 3ceba77ca89f..5b0907bb8120 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -197,7 +197,7 @@ 4.3.0.Final - 5.1.26 + 5.1.27 1.7.5 From 4fa323c03b14116251bd7ddc147a646e13391d57 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 12:48:44 +0200 Subject: [PATCH 322/796] maven upgrades --- spring-rest/pom.xml | 331 ++++++------ spring-security-rest-basic-auth/pom.xml | 14 +- spring-security-rest-custom/pom.xml | 549 ++++++++++---------- spring-security-rest-digest-auth/pom.xml | 617 ++++++++++++----------- spring-security-rest-full/README.md | 14 +- spring-security-rest-full/pom.xml | 15 +- spring-security-rest/pom.xml | 22 +- 7 files changed, 822 insertions(+), 740 deletions(-) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 7e86a5d59b4e..c205d6f5a7c5 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -1,158 +1,177 @@ - - 4.0.0 - org.baeldung - spring-rest - 0.1-SNAPSHOT - - spring-rest - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-rest - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.1.4.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index bde8f98a4f01..ce6e807f0803 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -239,6 +239,12 @@ + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin @@ -308,11 +314,13 @@ 1.9.5 2.1.0 - 1.8.9 - 1.4.5 - 2.16 + 3.1 + 2.4 + 2.16 + 1.4.5 + \ No newline at end of file diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index cd946897a83e..12abd6826eaf 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -1,272 +1,281 @@ - - 4.0.0 - org.baeldung - spring-security-rest-custom - 0.1-SNAPSHOT - - spring-security-rest-custom - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - commons-logging - commons-logging - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-custom - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-security-rest-custom + 0.1-SNAPSHOT + + spring-security-rest-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-custom + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.1.4.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 94712aee2585..440f09017354 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -1,306 +1,315 @@ - - 4.0.0 - org.baeldung - spring-security-rest-digest-auth - 0.1-SNAPSHOT - - spring-security-rest-digest-auth - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - org.springframework - spring-oxm - ${org.springframework.version} - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - commons-logging - commons-logging - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-digest-auth - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - true - source - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 4.3 - 4.3.1 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-security-rest-digest-auth + 0.1-SNAPSHOT + + spring-security-rest-digest-auth + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-rest-digest-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + source + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*LiveTest.java + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.1.4.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 4.3 + 4.3.1 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index daa0176cad05..a2b7dedbd8d0 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -1,10 +1,10 @@ ========= -## Spring Security REST Example Project +## REST Example Project with Spring Security ### Relevant Articles: -- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) +- [Spring Security Expressions � hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) ### Build the Project @@ -12,6 +12,16 @@ mvn clean install ``` + +### Set up MySQL +``` +mysql -u root -p +> CREATE USER 'tutorialuser'@'localhost' IDENTIFIED BY 'tutorialmy5ql'; +> GRANT ALL PRIVILEGES ON *.* TO 'tutorialuser'@'localhost'; +> FLUSH PRIVILEGES; +``` + + ### Use the REST Service ``` diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index dd360dcda60e..914cd5fd580d 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -210,6 +210,12 @@ + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + @@ -222,11 +228,11 @@ 4.3.0.Final 5.1.27 - 1.3.2.RELEASE + 1.4.3.RELEASE - 2.2.2 + 2.2.3 1.7.5 @@ -251,8 +257,11 @@ 1.8.9 - 1.4.5 + 3.1 + 2.4 2.16 + 1.4.5 + \ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 5b0907bb8120..11456654f562 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -151,6 +151,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin @@ -219,11 +235,13 @@ 4.3.1 2.1.0 - 1.8.9 - 1.4.5 + 3.1 + 2.4 2.16 + 1.4.5 + \ No newline at end of file From 56240e0fcebfdbe58b049958480b622f67c63c25 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 12:55:26 +0200 Subject: [PATCH 323/796] classpath fix --- spring-security-rest/.classpath | 3 ++- .../.settings/org.eclipse.wst.validation.prefs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-security-rest/.classpath b/spring-security-rest/.classpath index ee67eca8cf5b..6cb510b80c3f 100644 --- a/spring-security-rest/.classpath +++ b/spring-security-rest/.classpath @@ -25,11 +25,12 @@ + - + diff --git a/spring-security-rest/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-rest/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-rest/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false From f58149a0ccc79a6a5c697545c98f8d222161ab3f Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 13:16:19 +0200 Subject: [PATCH 324/796] upgrades to spring security 3.2 - testing work as well --- spring-rest/pom.xml | 2 +- spring-security-rest-basic-auth/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../org/baeldung/client/ClientLiveTest.java | 2 ++ .../baeldung/client/RawClientLiveTest.java | 34 ++++++------------- spring-security-rest-custom/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-rest-digest-auth/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../baeldung/client/RawClientLiveTest.java | 31 ++++------------- spring-security-rest-full/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-rest/pom.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- 14 files changed, 30 insertions(+), 59 deletions(-) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index c205d6f5a7c5..66ad302bc69e 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -139,7 +139,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index ce6e807f0803..c383ed6341e4 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,7 +287,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml index e30e9120a16f..470ea8d44a28 100644 --- a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index e14fc1403e62..4ca5ca9e64d0 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -15,6 +15,7 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.baeldung.client.spring.ClientConfig; import org.baeldung.web.dto.Foo; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -54,6 +55,7 @@ public final void whenHttpsUrlIsConsumed_thenException() { } @Test + @Ignore("Only to run against a Server with HTTPS enabled (on 8443)") public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index 61c782b00a58..312222d9bb33 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -13,18 +13,18 @@ import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.params.ClientPNames; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; +import org.junit.Ignore; import org.junit.Test; public class RawClientLiveTest { @@ -33,14 +33,12 @@ public class RawClientLiveTest { @Test public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { - final DefaultHttpClient httpClient = new DefaultHttpClient(); + final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); final int timeout = 20; // seconds - final HttpParams httpParams = httpClient.getParams(); - configureViaRawApi(timeout, httpParams); - // configureViaHighLevelApi(timeout, httpParams); - + final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build(); final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1"); + getMethod.setConfig(requestConfig); final int hardTimeout = 5; // seconds final TimerTask task = new TimerTask() { @@ -58,8 +56,9 @@ public void run() { } @Test(expected = SSLPeerUnverifiedException.class) + @Ignore("Only for a server that has HTTPS enabled (on 8443)") public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolException, IOException { - final DefaultHttpClient httpClient = new DefaultHttpClient(); + final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; final HttpGet getMethod = new HttpGet(urlOverHttps); @@ -80,7 +79,7 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String registry.register(new Scheme("https", 8443, sf)); final ClientConnectionManager ccm = new PoolingClientConnectionManager(registry); - final DefaultHttpClient httpClient = new DefaultHttpClient(ccm); + final CloseableHttpClient httpClient = new DefaultHttpClient(ccm); final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; final HttpGet getMethod = new HttpGet(urlOverHttps); @@ -88,17 +87,4 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } - // util - - final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) { - HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout - HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout - httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); - } - - final void configureViaRawApi(final int timeout, final HttpParams httpParams) { - httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); - httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); - httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); - } } diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 12abd6826eaf..b820175ec965 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -243,7 +243,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml index 3766574f346b..e36bcd3a25fb 100644 --- a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 440f09017354..8a1d800206c6 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -276,7 +276,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 2dbcf84eeeaa..38321aeea15b 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index a535c246efdb..93c3af387681 100644 --- a/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-digest-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -6,12 +6,10 @@ import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.params.ClientPNames; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.baeldung.client.spring.ClientConfig; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,14 +25,12 @@ public class RawClientLiveTest { @Test public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { - final DefaultHttpClient httpClient = new DefaultHttpClient(); + final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); final int timeout = 20; // seconds - final HttpParams httpParams = httpClient.getParams(); - configureViaRawApi(timeout, httpParams); - // configureViaHighLevelApi(timeout, httpParams); - - final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-digest-auth/api/bars/1"); + final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build(); + final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1"); + getMethod.setConfig(requestConfig); final int hardTimeout = 5; // seconds final TimerTask task = new TimerTask() { @@ -51,17 +47,4 @@ public void run() { System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode()); } - // util - - final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) { - HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout - HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout - httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); - } - - final void configureViaRawApi(final int timeout, final HttpParams httpParams) { - httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); - httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); - httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); - } } diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 914cd5fd580d..747550d4e3bc 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -223,7 +223,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index de79430530bf..ce48352f3e28 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 11456654f562..a7eb3546b23c 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -209,7 +209,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index f53b15752c57..841e609d4975 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:sec="http://www.springframework.org/schema/security" xsi:schemaLocation=" http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> From dac56fd805fde6ebfb3b38fd94260f5e8034c3c2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 13:21:29 +0200 Subject: [PATCH 325/796] cleanup work --- .../baeldung/live/HttpLiveServiceTemp.java | 3 +- spring-security-rest-full/pom.xml | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java index 03378284b1a9..19f8f5325e9f 100644 --- a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java +++ b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java @@ -14,6 +14,7 @@ import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; @@ -26,7 +27,7 @@ public class HttpLiveServiceTemp { - private DefaultHttpClient client; + private CloseableHttpClient client; // fixtures diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 747550d4e3bc..db0e888479fe 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -130,9 +130,34 @@ com.google.guava guava - 14.0.1 + ${guava.version} + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + @@ -254,7 +279,6 @@ 4.3.1 2.1.0 - 1.8.9 3.1 From f40c9d3a96a3901300554c7d9ad1c7a11ffd9beb Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 13:25:45 +0200 Subject: [PATCH 326/796] upgrading to spring security 3.2, other maven upgrades, cleanup work --- spring-mvc-java/pom.xml | 9 +- spring-mvc-no-xml/pom.xml | 8 +- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-mvc-xml/pom.xml | 11 +- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-basic-auth/pom.xml | 59 +-- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-mvc-custom/pom.xml | 440 +++++++++--------- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 59 +-- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-security-mvc-login/pom.xml | 424 ++++++++--------- .../src/main/resources/webSecurityConfig.xml | 32 +- spring-security-mvc-session/pom.xml | 440 +++++++++--------- .../src/main/resources/webSecurityConfig.xml | 2 +- 15 files changed, 756 insertions(+), 738 deletions(-) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 230e0b93429e..a6311565bc7a 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -140,7 +140,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final @@ -166,14 +166,13 @@ 4.3.1 2.0.1 - 1.8.9 - 1.4.5 3.1 - 2.6 - 2.16 2.4 + 2.16 + 2.6 + 1.4.5 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index ccff21aa6458..b9ac911e8e8a 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -125,12 +125,14 @@ 4.3.1 2.1.0 - 1.8.9 - 1.4.5 - 2.16 + 3.1 2.4 + 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml index 5569cc69508a..3012a337af54 100644 --- a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml +++ b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 764a85260d00..802968b97613 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -116,11 +116,14 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 - 2.16 + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml index 5569cc69508a..3012a337af54 100644 --- a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml +++ b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index a7b77f3b4b21..4be7c4e9cb3e 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -141,7 +141,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + ${maven-surefire-plugin.version} @@ -155,7 +155,7 @@ org.codehaus.cargo cargo-maven2-plugin - ${cargo-maven2-plugin.version} + ${cargo-maven2-plugin.version} true @@ -178,39 +178,42 @@ - - 3.2.6.RELEASE - 3.1.4.RELEASE + + 3.2.6.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 - - 4.3.0.Final - 5.1.27 + + 1.7.5 + 1.0.11 - - 1.7.5 - 1.0.11 + + 5.0.1.Final - - 5.0.1.Final + + 15.0 + 3.1 - - 15.0 - 3.1 + + 1.3 + 4.11 + 1.9.5 - - 1.3 - 4.11 - 1.9.5 + 4.3 + 4.3.1 - 4.3 - 4.3.1 + 2.1.0 - 2.1.0 - 1.8.9 + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 - - 1.4.5 - 2.16 - + \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index 2b55ca1c7366..5c56b26ddda2 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index b4842ec74c03..8e9834887fd8 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -1,220 +1,224 @@ - - 4.0.0 - org.baeldung - spring-security-mvc-custom - 0.1-SNAPSHOT - - spring-security-mvc-custom - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - org.springframework.security - spring-security-taglibs - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - - - - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-mvc-custom - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.1 - 4.3 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-security-mvc-custom + 0.1-SNAPSHOT + + spring-security-mvc-custom + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + + + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-custom + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.1 + 4.3 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index 186a435cdb99..9bce45af78ae 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 2aa998f70679..405f8f9a0ced 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -141,7 +141,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + ${maven-surefire-plugin.version} @@ -155,7 +155,7 @@ org.codehaus.cargo cargo-maven2-plugin - ${cargo-maven2-plugin.version} + ${cargo-maven2-plugin.version} true @@ -178,39 +178,42 @@ - - 3.2.6.RELEASE - 3.1.4.RELEASE + + 3.2.6.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 - - 4.3.0.Final - 5.1.27 + + 1.7.5 + 1.0.11 - - 1.7.5 - 1.0.11 + + 5.0.1.Final - - 5.0.1.Final + + 15.0 + 3.1 - - 15.0 - 3.1 + + 1.3 + 4.11 + 1.9.5 - - 1.3 - 4.11 - 1.9.5 + 4.3 + 4.3.1 - 4.3 - 4.3.1 + 2.1.0 - 2.1.0 - 1.8.9 + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 - - 1.4.5 - 2.16 - + \ No newline at end of file diff --git a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml index dfd0b853713d..bb13271adb21 100644 --- a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml @@ -1,7 +1,7 @@ diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index a075e64a13b2..52cc7d5a8025 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -1,212 +1,216 @@ - - 4.0.0 - org.baeldung - spring-security-mvc-login - 0.1-SNAPSHOT - - spring-security-mvc-login - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - org.springframework.security - spring-security-taglibs - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-mvc-login - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-security-mvc-login + 0.1-SNAPSHOT + + spring-security-mvc-login + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-login + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml index 742d9fdf03c3..89d7bd3f569d 100644 --- a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml @@ -3,30 +3,26 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + - - + + + + + + - - - - - - + + diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index ca4eedefe5d2..b5c173859091 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -1,220 +1,224 @@ - - 4.0.0 - org.baeldung - spring-security-mvc-session - 0.1-SNAPSHOT - - spring-security-mvc-session - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - org.springframework.security - spring-security-taglibs - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.codahale.metrics - metrics-core - 3.0.1 - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-mvc-session - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.1 - 4.3 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-security-mvc-session + 0.1-SNAPSHOT + + spring-security-mvc-session + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.codahale.metrics + metrics-core + 3.0.1 + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-session + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.1 + 4.3 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index cb7e3f06456a..b2dc8572e606 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ From 3199aa3b44e161e3409bd3c1ddca23f25d2f021a Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:18:11 +0200 Subject: [PATCH 327/796] maven build fix --- spring-mvc-no-xml/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index b9ac911e8e8a..6f57abf069b4 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -86,7 +86,7 @@ maven-war-plugin ${maven-war-plugin.version} - false + false From bae8efe53de7cb8af5df8d5fa83ff9e120b6de43 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:28:30 +0200 Subject: [PATCH 328/796] maven work --- spring-security-basic-auth/.classpath | 1 + .../org.eclipse.wst.validation.prefs | 3 ++- spring-security-basic-auth/pom.xml | 16 +++++++++++++++ spring-security-mvc-custom/.classpath | 6 ++++++ .../org.eclipse.wst.validation.prefs | 3 ++- spring-security-mvc-custom/pom.xml | 16 +++++++++++++++ spring-security-mvc-digest-auth/.classpath | 12 ++++++++--- .../.settings/org.eclipse.jdt.core.prefs | 4 ---- .../org.eclipse.wst.validation.prefs | 3 ++- spring-security-mvc-digest-auth/pom.xml | 20 +++++++++++++++++-- spring-security-mvc-login/.classpath | 6 ++++++ .../org.eclipse.wst.validation.prefs | 3 ++- spring-security-mvc-login/pom.xml | 16 +++++++++++++++ spring-security-mvc-session/.classpath | 6 ++++++ .../org.eclipse.wst.validation.prefs | 3 ++- spring-security-mvc-session/pom.xml | 16 +++++++++++++++ spring-security-rest-custom/.classpath | 7 ++++++- .../org.eclipse.wst.validation.prefs | 3 ++- 18 files changed, 128 insertions(+), 16 deletions(-) diff --git a/spring-security-basic-auth/.classpath b/spring-security-basic-auth/.classpath index 15b58ba46e03..ca257cf1f962 100644 --- a/spring-security-basic-auth/.classpath +++ b/spring-security-basic-auth/.classpath @@ -30,6 +30,7 @@ + diff --git a/spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-basic-auth/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 4be7c4e9cb3e..cf98ffb935f8 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -138,6 +138,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-mvc-custom/.classpath b/spring-security-mvc-custom/.classpath index 5dea19367768..51523b07e123 100644 --- a/spring-security-mvc-custom/.classpath +++ b/spring-security-mvc-custom/.classpath @@ -27,5 +27,11 @@ + + + + + + diff --git a/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-mvc-custom/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 8e9834887fd8..294e3a7fa4e1 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -143,6 +143,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-mvc-digest-auth/.classpath b/spring-security-mvc-digest-auth/.classpath index 5dea19367768..a72442544ce8 100644 --- a/spring-security-mvc-digest-auth/.classpath +++ b/spring-security-mvc-digest-auth/.classpath @@ -16,15 +16,21 @@ - + + - + + + + + + + - diff --git a/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs index df8135651462..0d30335b6adc 100644 --- a/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs +++ b/spring-security-mvc-digest-auth/.settings/org.eclipse.jdt.core.prefs @@ -6,11 +6,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore diff --git a/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-mvc-digest-auth/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 405f8f9a0ced..29622458ed6a 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -93,7 +93,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -137,7 +137,23 @@ - + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-mvc-login/.classpath b/spring-security-mvc-login/.classpath index 5dea19367768..51523b07e123 100644 --- a/spring-security-mvc-login/.classpath +++ b/spring-security-mvc-login/.classpath @@ -27,5 +27,11 @@ + + + + + + diff --git a/spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-mvc-login/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 52cc7d5a8025..31443362b621 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -135,6 +135,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-mvc-session/.classpath b/spring-security-mvc-session/.classpath index 5dea19367768..51523b07e123 100644 --- a/spring-security-mvc-session/.classpath +++ b/spring-security-mvc-session/.classpath @@ -27,5 +27,11 @@ + + + + + + diff --git a/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs b/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-mvc-session/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index b5c173859091..6a3bce7aeeaa 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -143,6 +143,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-rest-custom/.classpath b/spring-security-rest-custom/.classpath index 5b66010de692..ca257cf1f962 100644 --- a/spring-security-rest-custom/.classpath +++ b/spring-security-rest-custom/.classpath @@ -16,7 +16,12 @@ - + + + + + + diff --git a/spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-rest-custom/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false From 62865699e7827e9764101173a5559450b3daf60e Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:35:20 +0200 Subject: [PATCH 329/796] maven work --- spring-mvc-java/pom.xml | 19 +++++++++++- spring-mvc-no-xml/pom.xml | 25 ++++++++++++++++ spring-mvc-xml/pom.xml | 40 +++++++++++++++++++++++++ spring-security-basic-auth/pom.xml | 25 ++++++++++++++++ spring-security-mvc-custom/pom.xml | 25 ++++++++++++++++ spring-security-mvc-digest-auth/pom.xml | 25 ++++++++++++++++ spring-security-mvc-login/pom.xml | 25 ++++++++++++++++ spring-security-mvc-session/pom.xml | 25 ++++++++++++++++ 8 files changed, 208 insertions(+), 1 deletion(-) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index a6311565bc7a..6e1bbf1b4dc3 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.baeldung spring-mvc-java @@ -80,6 +81,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 6f57abf069b4..ff3f0a801050 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -39,6 +39,31 @@ runtime + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 802968b97613..91bf1a5235fa 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -39,6 +39,31 @@ runtime + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + @@ -80,7 +105,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index cf98ffb935f8..75244cf6df48 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -96,6 +96,31 @@ 14.0.1 + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 294e3a7fa4e1..b62e43ff008f 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -101,6 +101,31 @@ + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 29622458ed6a..f38cc29c90e3 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -96,6 +96,31 @@ ${guava.version} + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 31443362b621..b2be5d7f1b85 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -93,6 +93,31 @@ runtime + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 6a3bce7aeeaa..73b55d0c7da1 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -101,6 +101,31 @@ 3.0.1 + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + From 8ebbd1fd6d951eff9a9a91b3f5711dc81c7daed5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:37:34 +0200 Subject: [PATCH 330/796] maven work --- spring-mvc-java/.classpath | 2 +- spring-mvc-no-xml/.classpath | 6 ++-- .../org.eclipse.wst.validation.prefs | 3 +- spring-mvc-no-xml/pom.xml | 14 ++++++++-- .../org.eclipse.wst.common.component | 2 +- .../org.eclipse.wst.validation.prefs | 3 +- .../org.eclipse.wst.validation.prefs | 3 +- .../org.eclipse.wst.validation.prefs | 3 +- .../org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.validation.prefs | 3 +- spring-security-rest-full/.classpath | 12 ++++++-- .../org.eclipse.wst.validation.prefs | 3 +- spring-security-rest-full/pom.xml | 28 +++++++++++++------ 14 files changed, 57 insertions(+), 27 deletions(-) diff --git a/spring-mvc-java/.classpath b/spring-mvc-java/.classpath index 26784dcaf4e7..540ef9eab17e 100644 --- a/spring-mvc-java/.classpath +++ b/spring-mvc-java/.classpath @@ -30,7 +30,7 @@ - + diff --git a/spring-mvc-no-xml/.classpath b/spring-mvc-no-xml/.classpath index eed10d8a8b04..26c5f263e2a9 100644 --- a/spring-mvc-no-xml/.classpath +++ b/spring-mvc-no-xml/.classpath @@ -22,15 +22,15 @@ - + + - + - diff --git a/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs +++ b/spring-mvc-no-xml/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index ff3f0a801050..ab5a0d271dcc 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -63,7 +63,7 @@ log4j-over-slf4j ${org.slf4j.version} - + @@ -105,7 +105,17 @@ - + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-war-plugin diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-xml/.settings/org.eclipse.wst.common.component index 4d41b2e1b495..02d347382a88 100644 --- a/spring-mvc-xml/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-xml/.settings/org.eclipse.wst.common.component @@ -4,7 +4,7 @@ - + diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs b/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs +++ b/spring-mvc-xml/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-rest/.settings/org.eclipse.wst.validation.prefs b/spring-rest/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-rest/.settings/org.eclipse.wst.validation.prefs +++ b/spring-rest/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-rest-basic-auth/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component index 4bf6e222f354..3b22cb60bb1f 100644 --- a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component index 9e1a61e740ae..128f61d7111b 100644 --- a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-rest-full/.classpath b/spring-security-rest-full/.classpath index 5dea19367768..a72442544ce8 100644 --- a/spring-security-rest-full/.classpath +++ b/spring-security-rest-full/.classpath @@ -16,15 +16,21 @@ - + + - + + + + + + + - diff --git a/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs b/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs +++ b/spring-security-rest-full/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index db0e888479fe..fe45280b3372 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -132,7 +132,7 @@ guava ${guava.version} - + @@ -157,7 +157,7 @@ log4j-over-slf4j ${org.slf4j.version} - + @@ -200,6 +200,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin @@ -235,12 +251,6 @@ - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - @@ -285,7 +295,7 @@ 2.4 2.16 1.4.5 - + \ No newline at end of file From c9aaabcb001315b49330b0f794f9fd957cb990e5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:40:12 +0200 Subject: [PATCH 331/796] cleanup work --- spring-mvc-java/.settings/org.eclipse.wst.common.component | 2 +- spring-mvc-java/pom.xml | 2 +- spring-mvc-xml/.settings/org.eclipse.wst.common.component | 2 +- spring-mvc-xml/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-mvc-java/.settings/org.eclipse.wst.common.component b/spring-mvc-java/.settings/org.eclipse.wst.common.component index 386dfc1dcd10..b23283ab37b2 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-java/.settings/org.eclipse.wst.common.component @@ -5,6 +5,6 @@ - + diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 6e1bbf1b4dc3..c3bfdd9592d5 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -71,7 +71,7 @@ - spring-mvc + spring-mvc-java src/main/resources diff --git a/spring-mvc-xml/.settings/org.eclipse.wst.common.component b/spring-mvc-xml/.settings/org.eclipse.wst.common.component index 02d347382a88..fc995759ac67 100644 --- a/spring-mvc-xml/.settings/org.eclipse.wst.common.component +++ b/spring-mvc-xml/.settings/org.eclipse.wst.common.component @@ -5,6 +5,6 @@ - + diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 91bf1a5235fa..4fec71f3a50a 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -96,7 +96,7 @@ - spring-mvc + spring-mvc-xml src/main/resources From 2a3ec485d02f419f499674304c54d720f6b7209f Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:49:24 +0200 Subject: [PATCH 332/796] cleanup work --- experiments/.classpath | 7 +- .../org.eclipse.wst.validation.prefs | 3 +- experiments/pom.xml | 20 +- guava/.classpath | 2 +- guava/pom.xml | 21 +- httpclient/.classpath | 2 +- httpclient/pom.xml | 21 +- mockito/.classpath | 2 +- mockito/pom.xml | 19 +- .../org.eclipse.wst.validation.prefs | 3 +- spring-all/pom.xml | 38 +- .../org.eclipse.wst.validation.prefs | 3 +- spring-exceptions/pom.xml | 477 +++++++++--------- spring-hibernate3/.classpath | 1 + .../org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.validation.prefs | 3 +- spring-hibernate3/pom.xml | 25 +- spring-hibernate4/.classpath | 1 + .../org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.validation.prefs | 3 +- spring-hibernate4/pom.xml | 26 +- .../org.eclipse.wst.common.component | 1 - .../org.eclipse.wst.validation.prefs | 3 +- spring-jpa/pom.xml | 411 ++++++++------- spring-mvc-java/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- spring-mvc-java/pom.xml | 21 +- 28 files changed, 631 insertions(+), 494 deletions(-) diff --git a/experiments/.classpath b/experiments/.classpath index 5b66010de692..ca257cf1f962 100644 --- a/experiments/.classpath +++ b/experiments/.classpath @@ -16,7 +16,12 @@ - + + + + + + diff --git a/experiments/.settings/org.eclipse.wst.validation.prefs b/experiments/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/experiments/.settings/org.eclipse.wst.validation.prefs +++ b/experiments/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/experiments/pom.xml b/experiments/pom.xml index 0c83141f7591..b4fa82a924ab 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -204,6 +204,16 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-surefire-plugin @@ -272,11 +282,15 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 + + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/guava/.classpath b/guava/.classpath index c370943e8c83..0720e4851bd7 100644 --- a/guava/.classpath +++ b/guava/.classpath @@ -27,7 +27,7 @@ - + diff --git a/guava/pom.xml b/guava/pom.xml index adab96cf3ffc..29bbc542776e 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -61,6 +61,16 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-surefire-plugin @@ -100,11 +110,14 @@ 4.3.1 2.1.0 - 1.8.9 - - - 1.4.5 + + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/httpclient/.classpath b/httpclient/.classpath index c370943e8c83..0720e4851bd7 100644 --- a/httpclient/.classpath +++ b/httpclient/.classpath @@ -27,7 +27,7 @@ - + diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 699f8c6ed176..ce99de04e681 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -73,6 +73,16 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-surefire-plugin @@ -112,11 +122,14 @@ 4.3.1 2.1.0 - 1.8.9 - - - 1.4.5 + + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/mockito/.classpath b/mockito/.classpath index c370943e8c83..0720e4851bd7 100644 --- a/mockito/.classpath +++ b/mockito/.classpath @@ -27,7 +27,7 @@ - + diff --git a/mockito/pom.xml b/mockito/pom.xml index 348fd8dcb5fe..2b5f831313e6 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -67,6 +67,16 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-surefire-plugin @@ -106,11 +116,14 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-all/.settings/org.eclipse.wst.validation.prefs b/spring-all/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-all/.settings/org.eclipse.wst.validation.prefs +++ b/spring-all/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-all/pom.xml b/spring-all/pom.xml index c98aa24fc858..874b851887f9 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -132,14 +132,24 @@ - - org.apache.maven.plugins - maven-war-plugin - 2.3 - - false - - + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + org.apache.maven.plugins @@ -211,11 +221,15 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 - 2.16 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-exceptions/.settings/org.eclipse.wst.validation.prefs b/spring-exceptions/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-exceptions/.settings/org.eclipse.wst.validation.prefs +++ b/spring-exceptions/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 2dd1f46bb455..c89028b33461 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -1,233 +1,248 @@ - - 4.0.0 - org.baeldung - spring-exceptions - 0.1-SNAPSHOT - - spring-exceptions - war - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.javassist - javassist - ${javassist.version} - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - org.apache.tomcat - tomcat-dbcp - ${tomcat-dbcp.version} - - - - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - ${jstl.version} - runtime - - - - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-exceptions - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-war-plugin - 2.3 - - false - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - 3.18.1-GA - 1.2 - - - 4.3.0.Final - 5.1.27 - 7.0.42 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + org.baeldung + spring-exceptions + 0.1-SNAPSHOT + + spring-exceptions + war + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.javassist + javassist + ${javassist.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + + + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + ${jstl.version} + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-exceptions + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.1.4.RELEASE + 3.18.1-GA + 1.2 + + + 4.3.0.Final + 5.1.27 + 7.0.42 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + 1.8.9 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/spring-hibernate3/.classpath b/spring-hibernate3/.classpath index efc51b414b0b..eed10d8a8b04 100644 --- a/spring-hibernate3/.classpath +++ b/spring-hibernate3/.classpath @@ -30,6 +30,7 @@ + diff --git a/spring-hibernate3/.settings/org.eclipse.wst.common.component b/spring-hibernate3/.settings/org.eclipse.wst.common.component index 2078f0abbbc5..14b1679703ce 100644 --- a/spring-hibernate3/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate3/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-hibernate3/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate3/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-hibernate3/.settings/org.eclipse.wst.validation.prefs +++ b/spring-hibernate3/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 2019b53a2b74..fe3d1f48dca5 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -117,6 +117,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin @@ -187,11 +203,14 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index 15b58ba46e03..ca257cf1f962 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -30,6 +30,7 @@ + diff --git a/spring-hibernate4/.settings/org.eclipse.wst.common.component b/spring-hibernate4/.settings/org.eclipse.wst.common.component index 59f6da9f9587..619260207900 100644 --- a/spring-hibernate4/.settings/org.eclipse.wst.common.component +++ b/spring-hibernate4/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-hibernate4/.settings/org.eclipse.wst.validation.prefs b/spring-hibernate4/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-hibernate4/.settings/org.eclipse.wst.validation.prefs +++ b/spring-hibernate4/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 070a9d8f3f4a..0694bab59551 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -125,6 +125,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + org.apache.maven.plugins maven-surefire-plugin @@ -195,11 +211,15 @@ 4.3.1 2.1.0 - 1.8.9 - - 1.4.5 + + + 3.1 + 2.4 2.16 + 2.6 + 1.4.5 + \ No newline at end of file diff --git a/spring-jpa/.settings/org.eclipse.wst.common.component b/spring-jpa/.settings/org.eclipse.wst.common.component index 68573b98202a..0327e45de6dc 100644 --- a/spring-jpa/.settings/org.eclipse.wst.common.component +++ b/spring-jpa/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/spring-jpa/.settings/org.eclipse.wst.validation.prefs b/spring-jpa/.settings/org.eclipse.wst.validation.prefs index cacf5451aef7..0d0aee4f7201 100644 --- a/spring-jpa/.settings/org.eclipse.wst.validation.prefs +++ b/spring-jpa/.settings/org.eclipse.wst.validation.prefs @@ -1,7 +1,8 @@ DELEGATES_PREFERENCE=delegateValidatorList USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target eclipse.preferences.version=1 override=true suspend=false diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 0dc7fce652e3..5c26f3c62b8e 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -1,197 +1,218 @@ - - 4.0.0 - - org.baeldung - spring-jpa - 0.1-SNAPSHOT - - war - spring-jpa - - - - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - org.javassist - javassist - 3.18.0-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-jpa - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 3.2.6.RELEASE - 3.1.4.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - 1.8.9 - - - 1.4.5 - 2.16 - + + 4.0.0 + + org.baeldung + spring-jpa + 0.1-SNAPSHOT + + war + spring-jpa + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.javassist + javassist + 3.18.0-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-jpa + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 3.2.6.RELEASE + 3.1.4.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/spring-mvc-java/.classpath b/spring-mvc-java/.classpath index 540ef9eab17e..26c5f263e2a9 100644 --- a/spring-mvc-java/.classpath +++ b/spring-mvc-java/.classpath @@ -28,7 +28,7 @@ - + diff --git a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs index 0f5e3349075a..0924ed68cff2 100644 --- a/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs +++ b/spring-mvc-java/.settings/org.eclipse.jdt.core.prefs @@ -5,8 +5,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -88,4 +88,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml index 546ff4ce8c9b..3ad4cd9302cc 100644 --- a/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-mvc-java/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,5 +2,5 @@ - + diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index c3bfdd9592d5..b9fca2626da5 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -95,6 +95,9 @@ org.apache.maven.plugins maven-war-plugin ${maven-war-plugin.version} + + false + @@ -132,24 +135,6 @@ - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.6 - 1.6 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - false - - - From 757843907da99a087ded25713008108a1e86a06f Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:52:47 +0200 Subject: [PATCH 333/796] maven upgrade to spring 3.2 --- experiments/pom.xml | 4 ++-- .../org/baeldung/live/{CrawlTest.java => CrawlLiveTest.java} | 2 +- guava/pom.xml | 2 +- httpclient/pom.xml | 2 +- mockito/pom.xml | 2 +- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- .../Cause4MappingExceptionIntegrationTest.java | 2 +- spring-hibernate3/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- spring-hibernate4/src/main/resources/webSecurityConfig.xml | 2 +- spring-jpa/pom.xml | 2 +- spring-jpa/src/main/resources/webSecurityConfig.xml | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) rename experiments/src/test/java/org/baeldung/live/{CrawlTest.java => CrawlLiveTest.java} (99%) diff --git a/experiments/pom.xml b/experiments/pom.xml index b4fa82a924ab..d91b88e49c36 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -220,7 +220,7 @@ ${maven-surefire-plugin.version} - + **/*LiveTest.java @@ -256,7 +256,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/experiments/src/test/java/org/baeldung/live/CrawlTest.java b/experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java similarity index 99% rename from experiments/src/test/java/org/baeldung/live/CrawlTest.java rename to experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java index ba7e92db5c85..d7367d7bd0c8 100644 --- a/experiments/src/test/java/org/baeldung/live/CrawlTest.java +++ b/experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java @@ -32,7 +32,7 @@ import org.w3c.dom.Document; import org.xml.sax.SAXException; -public class CrawlTest { +public class CrawlLiveTest { private DefaultHttpClient client; diff --git a/guava/pom.xml b/guava/pom.xml index 29bbc542776e..f1c8adb4ee0c 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -84,7 +84,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/httpclient/pom.xml b/httpclient/pom.xml index ce99de04e681..339500651cdc 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -96,7 +96,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/mockito/pom.xml b/mockito/pom.xml index 2b5f831313e6..72353719b053 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -90,7 +90,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 874b851887f9..a683a4c4199c 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -193,7 +193,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 3.18.1-GA 1.2 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index c89028b33461..c57fe2259fe8 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -205,7 +205,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 3.18.1-GA 1.2 diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java index ea24a1342e36..864da76e4bf2 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java +++ b/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionIntegrationTest.java @@ -35,7 +35,7 @@ private final SessionFactory configureSessionFactory() throws IOException { configuration.addAnnotatedClass(Foo.class); - final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); + final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); final SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; } diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index fe3d1f48dca5..3c1cd2d0b60a 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -175,7 +175,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 3.18.1-GA diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 0694bab59551..29bda8bb21d7 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -183,7 +183,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 3.18.1-GA diff --git a/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/spring-hibernate4/src/main/resources/webSecurityConfig.xml index 5569cc69508a..3012a337af54 100644 --- a/spring-hibernate4/src/main/resources/webSecurityConfig.xml +++ b/spring-hibernate4/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 5c26f3c62b8e..bdf959e161b7 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -178,7 +178,7 @@ 3.2.6.RELEASE - 3.1.4.RELEASE + 3.2.0.RELEASE 4.3.0.Final diff --git a/spring-jpa/src/main/resources/webSecurityConfig.xml b/spring-jpa/src/main/resources/webSecurityConfig.xml index 5569cc69508a..3012a337af54 100644 --- a/spring-jpa/src/main/resources/webSecurityConfig.xml +++ b/spring-jpa/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ From 43757b1955507ee538c007757ff9b5c2e0dd429a Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:55:41 +0200 Subject: [PATCH 334/796] cleanup work --- .../service/FooServicePersistenceIntegrationTest.java | 5 ++--- .../service/FooServicePersistenceIntegrationTest.java | 4 ++-- .../service/FooServicePersistenceIntegrationTest.java | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 974498535652..fe84ff5f65fe 100644 --- a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -5,7 +5,7 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.FooService; import org.baeldung.spring.PersistenceConfig; -import org.junit.Ignore; +import org.hibernate.exception.DataException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -51,8 +51,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test - @Ignore + @Test(expected = DataException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 99dd630803d5..6e90e87c903b 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -5,6 +5,7 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; +import org.hibernate.exception.DataException; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -52,8 +53,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test - @Ignore + @Test(expected = DataException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index da40949cf3d1..77a3ce95d97e 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,6 +4,7 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceJPAConfig; +import org.hibernate.exception.DataException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -49,7 +50,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test + @Test(expected = DataException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } From b9176ba5efe18f288cd117f801bd0e14ea391abe Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 14:59:26 +0200 Subject: [PATCH 335/796] testing work --- .../src/main/java/org/baeldung/spring/PersistenceConfig.java | 2 +- .../src/main/java/org/baeldung/spring/PersistenceXmlConfig.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java index 473c0c1714b4..4bfc6233d497 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -21,7 +21,7 @@ @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) public class PersistenceConfig { @Autowired diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java index c535d1b1bd1b..5831d2745cba 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java @@ -6,7 +6,7 @@ // @Configuration @EnableTransactionManagement -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) @ImportResource({ "classpath:persistenceConfig.xml" }) public class PersistenceXmlConfig { From 9bd7030906a2d4835708336923fe8dbb927b421d Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:37:44 +0200 Subject: [PATCH 336/796] upgrading to spring 4 --- spring-hibernate4/pom.xml | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 29bda8bb21d7..45f6dbbe8e9c 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,7 +182,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE 3.18.1-GA diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index 6e90e87c903b..4c0413a01a66 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -5,11 +5,11 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; -import org.hibernate.exception.DataException; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.ContextConfiguration; @@ -53,7 +53,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test(expected = DataException.class) + @Test(expected = DataAccessException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } From df46e27e23ec56ae3f931ed3279cfeb687cd862d Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:41:36 +0200 Subject: [PATCH 337/796] upgrading to spring 4 --- spring-hibernate3/pom.xml | 4 ++-- .../service/FooServicePersistenceIntegrationTest.java | 4 ++-- spring-security-rest-basic-auth/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-digest-auth/pom.xml | 2 +- spring-security-rest-full/pom.xml | 2 +- spring-security-rest/pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 3c1cd2d0b60a..d329bb12f080 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,14 +174,14 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE 3.18.1-GA 3.6.10.Final 5.1.27 - 7.0.41 + 7.0.47 1.7.5 diff --git a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java index fe84ff5f65fe..aaf0dd23e6aa 100644 --- a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java @@ -5,10 +5,10 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.FooService; import org.baeldung.spring.PersistenceConfig; -import org.hibernate.exception.DataException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.ContextConfiguration; @@ -51,7 +51,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test(expected = DataException.class) + @Test(expected = DataAccessException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo(randomAlphabetic(2048))); } diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index c383ed6341e4..08038ba23ec8 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -286,7 +286,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index b820175ec965..783dfd06253b 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -242,7 +242,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 8a1d800206c6..61ad000edf88 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,7 +275,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index fe45280b3372..0270d43096b7 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -257,7 +257,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index a7eb3546b23c..7c856cd44630 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -208,7 +208,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE From 6b89587e8ba1aa023cad5fff51a22cf4690c3c55 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:43:41 +0200 Subject: [PATCH 338/796] upgrading to spring 4 --- spring-mvc-java/pom.xml | 2 +- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 2 +- spring-security-basic-auth/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 2 +- spring-security-mvc-login/pom.xml | 2 +- spring-security-mvc-session/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index b9fca2626da5..091e4f3f362e 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,7 +141,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index ab5a0d271dcc..76187c2c7c7f 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 1.7.5 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 4fec71f3a50a..f53e1b2a2d6c 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,7 +141,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 1.7.5 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 66ad302bc69e..e7396227eeb8 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -138,7 +138,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 75244cf6df48..0413373c8699 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -220,7 +220,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index b62e43ff008f..acf5094423e1 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -225,7 +225,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index f38cc29c90e3..9a1f883ea859 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -220,7 +220,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index b2be5d7f1b85..ad71b17bb042 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -217,7 +217,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 73b55d0c7da1..7dcd791cacc7 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -225,7 +225,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE From d0a08ef594006b9780e79cede246c26a3e602ad6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:46:29 +0200 Subject: [PATCH 339/796] upgrading to spring 4 --- experiments/pom.xml | 2 +- guava/pom.xml | 2 +- httpclient/pom.xml | 2 +- mockito/pom.xml | 2 +- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- spring-jpa/pom.xml | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/experiments/pom.xml b/experiments/pom.xml index d91b88e49c36..5dac0d546f85 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,7 +255,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/guava/pom.xml b/guava/pom.xml index f1c8adb4ee0c..f853a4d36a80 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -83,7 +83,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 339500651cdc..6185838d2b2c 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -95,7 +95,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/mockito/pom.xml b/mockito/pom.xml index 72353719b053..c2d0e48b922e 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,7 +89,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-all/pom.xml b/spring-all/pom.xml index a683a4c4199c..e7578a418165 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,7 +192,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE 3.18.1-GA 1.2 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index c57fe2259fe8..3f17e77d5843 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,7 +204,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE 3.18.1-GA 1.2 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index bdf959e161b7..fea23f07b388 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,7 +177,7 @@ - 3.2.6.RELEASE + 4.0.0.RELEASE 3.2.0.RELEASE diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 77a3ce95d97e..2d8de007dbfc 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -4,10 +4,10 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceJPAConfig; -import org.hibernate.exception.DataException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.ContextConfiguration; @@ -50,7 +50,7 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } - @Test(expected = DataException.class) + @Test(expected = DataAccessException.class) public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } From afb7814656efb11430f024fecb240ae21d2706fb Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:50:57 +0200 Subject: [PATCH 340/796] minor testing work --- .../BeanCreationExceptionTestSuite.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java new file mode 100644 index 000000000000..ab5b14f7875a --- /dev/null +++ b/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java @@ -0,0 +1,20 @@ +package org.baeldung.ex.beancreationexception; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({// @formatter:off + Cause1BeanCreationExceptionIntegrationTest.class + ,Cause2BeanCreationExceptionIntegrationTest.class + ,Cause3BeanCreationExceptionIntegrationTest.class + ,Cause4BeanCreationExceptionIntegrationTest.class + ,Cause5BeanCreationExceptionIntegrationTest.class + ,Cause6BeanCreationExceptionIntegrationTest.class + ,Cause7BeanCreationExceptionIntegrationTest.class + ,Cause8BeanCreationExceptionIntegrationTest.class + ,Cause9BeanCreationExceptionIntegrationTest.class +}) // @formatter:on +public class BeanCreationExceptionTestSuite { + // +} From eb2c88d90c30b95aa06a6bcf169bc372d3bbc6e5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 18 Dec 2013 15:52:42 +0200 Subject: [PATCH 341/796] minor cleanup --- experiments/.settings/org.eclipse.wst.common.component | 1 - experiments/pom.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/experiments/.settings/org.eclipse.wst.common.component b/experiments/.settings/org.eclipse.wst.common.component index f03553e4f51d..893209cc5760 100644 --- a/experiments/.settings/org.eclipse.wst.common.component +++ b/experiments/.settings/org.eclipse.wst.common.component @@ -4,7 +4,6 @@ - diff --git a/experiments/pom.xml b/experiments/pom.xml index 5dac0d546f85..79c969935626 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -282,7 +282,6 @@ 4.3.1 2.1.0 - 3.1 From bf18f6d15d884077e4d1a3b1399d27a2d816faf1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 19 Dec 2013 15:09:11 +0200 Subject: [PATCH 342/796] new list partitioning examples --- guava/pom.xml | 10 +++- .../CollectionApachePartitionUnitTest.java | 43 ++++++++++++++ .../CollectionGuavaPartitionUnitTest.java | 56 +++++++++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 guava/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java create mode 100644 guava/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java diff --git a/guava/pom.xml b/guava/pom.xml index f853a4d36a80..f9994defec69 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -16,7 +16,13 @@ guava 15.0 - + + + org.apache.commons + commons-collections4 + 4.0 + + @@ -110,7 +116,7 @@ 4.3.1 2.1.0 - + 3.1 2.4 diff --git a/guava/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java b/guava/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java new file mode 100644 index 000000000000..1071d4a5fb67 --- /dev/null +++ b/guava/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java @@ -0,0 +1,43 @@ +package org.baeldung.java; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class CollectionApachePartitionUnitTest { + + // tests - apache common collections + + @Test + public final void givenList_whenParitioningIntoNSublists_thenCorrect() { + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final List> subSets = ListUtils.partition(intList, 3); + + // When + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8); + assertThat(subSets.size(), equalTo(3)); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChange() { + // Given + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + final List> subSets = ListUtils.partition(intList, 3); + + // When + intList.add(9); + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8, 9); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + +} diff --git a/guava/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java b/guava/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java new file mode 100644 index 000000000000..c4ddb35da249 --- /dev/null +++ b/guava/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java @@ -0,0 +1,56 @@ +package org.baeldung.java; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.Collection; +import java.util.List; + +import org.junit.Test; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +public class CollectionGuavaPartitionUnitTest { + + // tests - guava + + @Test + public final void givenList_whenParitioningIntoNSublists_thenCorrect() { + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final List> subSets = Lists.partition(intList, 3); + + // When + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8); + assertThat(subSets.size(), equalTo(3)); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChangeAsWell() { + // Given + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + final List> subSets = Lists.partition(intList, 3); + + // When + intList.add(9); + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8, 9); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenCollection_whenParitioningIntoNSublists_thenCorrect() { + final Collection intCollection = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final Iterable> subSets = Iterables.partition(intCollection, 3); + + // When + final List firstPartition = subSets.iterator().next(); + final List expectedLastPartition = Lists. newArrayList(1, 2, 3); + assertThat(firstPartition, equalTo(expectedLastPartition)); + } + +} From 06724f7ab3d04926e1de65cab66d44c71bdf1dd0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 19 Dec 2013 15:11:44 +0200 Subject: [PATCH 343/796] documentation work --- guava/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guava/README.md b/guava/README.md index 3b9a2800d699..8960b4676efb 100644 --- a/guava/README.md +++ b/guava/README.md @@ -9,3 +9,5 @@ - [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) - [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) + +- [Partition a List in Java](http://www.baeldung.com/java-list-split) From 06d88fac2b41302a8668baefc04e7f61dd5e74e7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 19 Dec 2013 17:33:08 +0200 Subject: [PATCH 344/796] minor maven upgrade --- spring-jpa/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index fea23f07b388..f139c609ec43 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -39,7 +39,7 @@ org.javassist javassist - 3.18.0-GA + 3.18.1-GA mysql From 611dd456b65933af32a0d75a97635d1069663db1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 15:25:07 +0200 Subject: [PATCH 345/796] initial jackson work --- jackson/.classpath | 36 ++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + jackson/.gitignore | 13 ++ jackson/.project | 36 ++++ jackson/.settings/.jsdtscope | 5 + jackson/.settings/org.eclipse.jdt.core.prefs | 95 +++++++++ jackson/.settings/org.eclipse.jdt.ui.prefs | 55 +++++ jackson/.settings/org.eclipse.m2e.core.prefs | 4 + jackson/.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + jackson/.springBeans | 14 ++ jackson/README.md | 13 ++ jackson/pom.xml | 139 +++++++++++++ jackson/src/main/resources/logback.xml | 20 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + jackson/src/main/webapp/WEB-INF/web.xml | 42 ++++ jackson/src/test/java/jackson/FooDto.java | 43 ++++ .../test/java/jackson/JacksonUnitTest.java | 37 ++++ .../guava/GuavaCollectionsExamplesTest.java | 189 ++++++++++++++++++ .../guava/GuavaFunctionalExamplesTest.java | 186 +++++++++++++++++ .../guava/GuavaOrderingExamplesTest.java | 179 +++++++++++++++++ .../hamcrest/HamcrestExamplesTest.java | 97 +++++++++ .../CollectionApachePartitionUnitTest.java | 43 ++++ .../CollectionGuavaPartitionUnitTest.java | 56 ++++++ jackson/src/test/resources/.gitignore | 13 ++ 30 files changed, 1360 insertions(+) create mode 100644 jackson/.classpath create mode 100644 jackson/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 jackson/.gitignore create mode 100644 jackson/.project create mode 100644 jackson/.settings/.jsdtscope create mode 100644 jackson/.settings/org.eclipse.jdt.core.prefs create mode 100644 jackson/.settings/org.eclipse.jdt.ui.prefs create mode 100644 jackson/.settings/org.eclipse.m2e.core.prefs create mode 100644 jackson/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 jackson/.settings/org.eclipse.wst.common.component create mode 100644 jackson/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 jackson/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 jackson/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 jackson/.settings/org.eclipse.wst.validation.prefs create mode 100644 jackson/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 jackson/.springBeans create mode 100644 jackson/README.md create mode 100644 jackson/pom.xml create mode 100644 jackson/src/main/resources/logback.xml create mode 100644 jackson/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 jackson/src/main/webapp/WEB-INF/web.xml create mode 100644 jackson/src/test/java/jackson/FooDto.java create mode 100644 jackson/src/test/java/jackson/JacksonUnitTest.java create mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java create mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java create mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java create mode 100644 jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java create mode 100644 jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java create mode 100644 jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java create mode 100644 jackson/src/test/resources/.gitignore diff --git a/jackson/.classpath b/jackson/.classpath new file mode 100644 index 000000000000..0720e4851bd7 --- /dev/null +++ b/jackson/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jackson/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/jackson/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/jackson/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/jackson/.gitignore b/jackson/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/jackson/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/jackson/.project b/jackson/.project new file mode 100644 index 000000000000..ea8ae1a67fa9 --- /dev/null +++ b/jackson/.project @@ -0,0 +1,36 @@ + + + jackson + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/jackson/.settings/.jsdtscope b/jackson/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/jackson/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/jackson/.settings/org.eclipse.jdt.core.prefs b/jackson/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/jackson/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jackson/.settings/org.eclipse.jdt.ui.prefs b/jackson/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/jackson/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/jackson/.settings/org.eclipse.m2e.core.prefs b/jackson/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/jackson/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/jackson/.settings/org.eclipse.m2e.wtp.prefs b/jackson/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/jackson/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/jackson/.settings/org.eclipse.wst.common.component b/jackson/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/jackson/.settings/org.eclipse.wst.common.project.facet.core.xml b/jackson/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.container b/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.name b/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/jackson/.settings/org.eclipse.wst.validation.prefs b/jackson/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/jackson/.settings/org.eclipse.wst.ws.service.policy.prefs b/jackson/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/jackson/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/jackson/.springBeans b/jackson/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/jackson/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/jackson/README.md b/jackson/README.md new file mode 100644 index 000000000000..8960b4676efb --- /dev/null +++ b/jackson/README.md @@ -0,0 +1,13 @@ +========= + +## Guava and Hamcrest Cookbooks and Examples + + +### Relevant Articles: +- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) +- [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) +- [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) + +- [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) + +- [Partition a List in Java](http://www.baeldung.com/java-list-split) diff --git a/jackson/pom.xml b/jackson/pom.xml new file mode 100644 index 000000000000..89f025bd443b --- /dev/null +++ b/jackson/pom.xml @@ -0,0 +1,139 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 2.2.3 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + + + \ No newline at end of file diff --git a/jackson/src/main/resources/logback.xml b/jackson/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/jackson/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jackson/src/main/webapp/WEB-INF/api-servlet.xml b/jackson/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/jackson/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/jackson/src/main/webapp/WEB-INF/web.xml b/jackson/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/jackson/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/jackson/src/test/java/jackson/FooDto.java b/jackson/src/test/java/jackson/FooDto.java new file mode 100644 index 000000000000..b086769f44be --- /dev/null +++ b/jackson/src/test/java/jackson/FooDto.java @@ -0,0 +1,43 @@ +package jackson; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(Include.NON_DEFAULT) +public class FooDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public FooDto() { + super(); + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/jackson/JacksonUnitTest.java b/jackson/src/test/java/jackson/JacksonUnitTest.java new file mode 100644 index 000000000000..d4e40d655046 --- /dev/null +++ b/jackson/src/test/java/jackson/JacksonUnitTest.java @@ -0,0 +1,37 @@ +package jackson; + +import java.io.IOException; + +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JacksonUnitTest { + + // tests + + @Test + public final void whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String fooDtoAsString = mapper.writeValueAsString(new FooDto()); + System.out.println(fooDtoAsString); + } + + @Test + public final void whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final FooDto dtoObject = new FooDto(); + dtoObject.setBooleanValue(true); + + final String fooDtoAsString = mapper.writeValueAsString(dtoObject); + System.out.println(fooDtoAsString); + } + +} + +/* +Article Ideas: +- Deserializing with a custom JsonParser + + */ diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java new file mode 100644 index 000000000000..2c137e6c8041 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java @@ -0,0 +1,189 @@ +package org.baeldung.guava; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +@SuppressWarnings("unused") +public class GuavaCollectionsExamplesTest { + + // tests + + @Test + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() { + final class CastFunction implements Function { + @SuppressWarnings("unchecked") + @Override + public final T apply(final F from) { + return (T) from; + } + } + + final List originalList = Lists.newArrayList(); + final List selectedProducts = Lists.transform(originalList, new CastFunction()); + System.out.println(selectedProducts); + } + + @SuppressWarnings({ "unchecked" }) + @Test + public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() { + final List originalList = Lists.newArrayList(); + final List selectedProducts = (List) (List) originalList; + System.out.println(selectedProducts); + } + + @Test + public final void whenAddingAnIterableToACollection_thenAddedOK() { + final Iterable iter = Lists.newArrayList(); + final Collection collector = Lists.newArrayList(); + Iterables.addAll(collector, iter); + } + + // + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch1_thenContains() { + final Iterable theCollection = Lists.newArrayList("a", "bc", "def"); + final boolean contains = Iterables.any(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch2_thenContains() { + final Set theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = !Sets.filter(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }).isEmpty(); + + assertTrue(contains); + } + + @Test + public final void whenCheckingIfCollectionContainsElementsByCustomMatch3_thenContains() { + final Iterable theCollection = Sets.newHashSet("a", "bc", "def"); + + final boolean contains = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }) != null; + + assertTrue(contains); + } + + // + + @Test(expected = NoSuchElementException.class) + public final void givenNoSearchResult_whenFindingElementInIterable_thenException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final String found = Iterables.find(theCollection, new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }); + + assertNull(found); + } + + @Test + public final void givenNoSearchResult_whenFindingElementInIterableWithSpecifiedReturn_thenNoException() { + final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); + + final Predicate inputOfLengthOne = new Predicate() { + @Override + public final boolean apply(final String input) { + return input.length() == 1; + } + }; + final String found = Iterables.find(theCollection, inputOfLengthOne, null); + + assertNull(found); + } + + // purge of nulls + + @Test + public final void givenListContainsNulls_whenPurgedOfNulls_thenNoLongerContainsNulls() { + final List values = Lists.newArrayList("a", null, "b", "c"); + final Iterable withoutNulls = Iterables.filter(values, Predicates.notNull()); + System.out.println(withoutNulls); + } + + // immutable collections + + @Test + public final void whenCreatingImuutableCollections_thenNoExceptions() { + final ImmutableList immutableList = ImmutableList.of("a", "b", "c"); + final ImmutableSet immutableSet = ImmutableSet.of("a", "b", "c"); + final ImmutableMap imuttableMap = ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3"); + } + + @Test + public final void whenTransformingCollectionsToImmutable_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList.copyOf(muttableList); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet.copyOf(muttableSet); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap.copyOf(muttableMap); + } + + @Test + public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExceptions() { + final List muttableList = Lists.newArrayList(); + final ImmutableList immutableList = ImmutableList. builder().addAll(muttableList).build(); + + final Set muttableSet = Sets.newHashSet(); + final ImmutableSet immutableSet = ImmutableSet. builder().addAll(muttableSet).build(); + + final Map muttableMap = Maps.newHashMap(); + final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); + } + + // unmodifiable + + @Test(expected = UnsupportedOperationException.class) + public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); + final Iterator iterator = unmodifiableIterable.iterator(); + if (iterator.hasNext()) { + iterator.remove(); + } + } + +} diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java new file mode 100644 index 000000000000..08091639f169 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java @@ -0,0 +1,186 @@ +package org.baeldung.guava; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Collections2; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; +import com.google.common.collect.Sets; + +public class GuavaFunctionalExamplesTest { + + // tests + + // predicates - filtering + + @Test + public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { + final List numbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final List evenNumbers = Lists.newArrayList(Collections2.filter(numbers, acceptEvenNumber)); + + final Integer found = Collections.binarySearch(evenNumbers, 57); + assertThat(found, lessThan(0)); + } + + @Test + public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { + final List withNulls = Lists.newArrayList("a", "bc", null, "def"); + final Iterable withoutNuls = Iterables.filter(withNulls, Predicates.notNull()); + + assertTrue(Iterables.all(withoutNuls, Predicates.notNull())); + } + + // predicates - checking + + @Test + public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + + assertTrue(Iterables.all(evenNumbers, acceptEvenNumber)); + } + + // negating a predicate + + @Test + public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { + final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); + final Predicate acceptOddNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) != 0; + } + }; + + assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); + } + + // other predicates + + @Test + public final void when_thenCorrect() { + // CharMatcher.forPredicate(predicate) + } + + // functions + + @Test + public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() { + final List numbers = Lists.newArrayList(1, 2, 3); + final List numbersAsStrings = Lists.transform(numbers, Functions.toStringFunction()); + assertThat(numbersAsStrings, contains("1", "2", "3")); + } + + @Test + public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { + final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List inAlphabeticalOrder = ordering.sortedCopy(numbersToSort); + + final List correctAlphabeticalOrder = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(correctAlphabeticalOrder, equalTo(inAlphabeticalOrder)); + } + + @Test + public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { + final List numbers = Arrays.asList(2, 1, 11, 100, 8, 14); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbers).filter(acceptEvenNumber).transform(powerOfTwo); + assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); + } + + @Test + public final void whenUsingFunctionComposition_thenCorrectResults() { + final List numbers = Arrays.asList(2, 3); + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + + final List result = Lists.transform(numbers, Functions.compose(powerOfTwo, powerOfTwo)); + assertThat(result, contains(16, 81)); + } + + // Set+Function => Map + + /** + * - see: http://code.google.com/p/guava-libraries/issues/detail?id=56 + */ + @Test + public final void whenMapIsBackedBySetAndFunction_thenCorrect() { + final Function powerOfTwo = new Function() { + @Override + public final Integer apply(final Integer input) { + return (int) Math.pow(input, 2); + } + }; + final Set lowNumbers = Sets.newHashSet(2, 3, 4); + + final Map numberToPowerOfTwoMuttable = Maps.asMap(lowNumbers, powerOfTwo); + final Map numberToPowerOfTwoImuttable = Maps.toMap(lowNumbers, powerOfTwo); + assertThat(numberToPowerOfTwoMuttable.get(2), equalTo(4)); + assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); + } + + // Predicate => Function + + @Test + public final void whenConvertingPredicateToFunction_thenCorrect() { + final List numbers = Lists.newArrayList(1, 2, 3, 6); + final Predicate acceptEvenNumber = new Predicate() { + @Override + public final boolean apply(final Integer number) { + return (number % 2) == 0; + } + }; + final Function isEventNumberFunction = Functions.forPredicate(acceptEvenNumber); + final List areNumbersEven = Lists.transform(numbers, isEventNumberFunction); + + assertThat(areNumbersEven, contains(false, true, false, true)); + } + +} diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java new file mode 100644 index 000000000000..5821d19ba05b --- /dev/null +++ b/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java @@ -0,0 +1,179 @@ +package org.baeldung.guava; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Functions; +import com.google.common.collect.Lists; +import com.google.common.collect.Ordering; +import com.google.common.primitives.Ints; + +public class GuavaOrderingExamplesTest { + + private final class OrderingByLenght extends Ordering { + @Override + public final int compare(final String s1, final String s2) { + return Ints.compare(s1.length(), s2.length()); + } + } + + // tests + + // dealing with null + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast()); + assertThat(toSort.get(toSort.size() - 1), nullValue()); + } + + @Test + public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsFirst()); + assertThat(toSort.get(0), nullValue()); + } + + @Test + public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { + final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); + Collections.sort(toSort, Ordering.natural().nullsLast().reverse()); + assertThat(toSort.get(0), nullValue()); + } + + // natural ordering + + @Test + public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { + final List toSort = Arrays.asList(3, 5, 4, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertTrue(Ordering.natural().isOrdered(toSort)); + } + + // checking string ordering + + @Test + public final void givenCollectionContainsDuplicates_whenCheckingStringOrdering_thenNo() { + final List toSort = Arrays.asList(3, 5, 4, 2, 1, 2); + Collections.sort(toSort, Ordering.natural()); + + assertFalse(Ordering.natural().isStrictlyOrdered(toSort)); + } + + // custom - by length + + @Test + public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrdering_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); + final Ordering byLength = new OrderingByLenght(); + + Collections.sort(toSort, byLength.compound(Ordering.natural())); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "zz", "ccc")); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + @Test + public final void whenSortingCollectionsWithComplexOrderingExample_thenCorrectlySorted() { + final List toSort = Arrays.asList("zz", "aa", null, "b", "ccc"); + + Collections.sort(toSort, new OrderingByLenght().reverse().compound(Ordering.natural()).nullsLast()); + System.out.println(toSort); + } + + // sorted copy + + @Test + public final void givenUnorderdList_whenRetrievingSortedCopy_thenSorted() { + final List toSort = Arrays.asList("aa", "b", "ccc"); + final List sortedCopy = new OrderingByLenght().sortedCopy(toSort); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "ccc")); + assertFalse(expectedOrder.isOrdered(toSort)); + assertTrue(expectedOrder.isOrdered(sortedCopy)); + } + + // to string + + @Test + public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSortedWithToString() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + + final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList(1, 11, 2)); + assertTrue(expectedOrder.isOrdered(toSort)); + } + + // binary search + + @Test + public final void whenPerformingBinarySearch_thenFound() { + final List toSort = Arrays.asList(1, 2, 11); + Collections.sort(toSort, Ordering.usingToString()); + final int found = Ordering.usingToString().binarySearch(toSort, 2); + + System.out.println(found); + } + + // min/max without actually sorting + + @Test + public final void whenFindingTheMinimalElementWithoutSorting_thenFound() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final int found = Ordering.natural().min(toSort); + assertThat(found, equalTo(1)); + } + + @Test + public final void whenFindingTheFirstFewElements_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final List leastOf = Ordering.natural().leastOf(toSort, 3); + final List expected = Lists.newArrayList(1, 2, 8); + assertThat(expected, equalTo(leastOf)); + } + + // order the results of a Function + + @Test + public final void givenListOfNumbers_whenRunningAToStringFunctionThenSorting_thenCorrect() { + final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); + final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); + final List sortedCopy = ordering.sortedCopy(toSort); + + final List expected = Lists.newArrayList(1, 100, 11, 14, 2, 8); + assertThat(expected, equalTo(sortedCopy)); + } + +} diff --git a/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java new file mode 100644 index 000000000000..a44ce766f067 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java @@ -0,0 +1,97 @@ +package org.baeldung.hamcrest; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.hamcrest.Matchers; +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class HamcrestExamplesTest { + + // tests + + @Test + public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItem("cd")); + assertThat(collection, not(hasItem("zz"))); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasItems("ef", "cd")); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollectionInStrictOrder_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, contains("ab", "cd", "ef")); + } + + @Test + public final void whenVerifyingMultipleElementsArePartOfCollectionInAnyOrder_thenCorrect2() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, containsInAnyOrder("cd", "ab", "ef")); + } + + @Test + public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { + final List collection = Lists.newArrayList(); + assertThat(collection, empty()); + } + + @Test + public final void givenCollectionIsNotEmpty_whenChecking_thenNotEmpty() { + final List collection = Lists.newArrayList("a"); + assertThat(collection, not(empty())); + } + + @Test + public final void givenMapIsEmpty_whenChecking_thenEmpty() { + final Map collection = Maps.newHashMap(); + assertThat(collection, equalTo(Collections.EMPTY_MAP)); + } + + @Test + public final void givenArrayIsEmpty_whenChecking_thenEmpty() { + final String[] array = new String[] { "ab" }; + assertThat(array, not(emptyArray())); + } + + @Test + public final void whenCollectionSizeIsChecked_thenCorrect() { + final List collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, hasSize(3)); + } + + @Test + public final void whenIterableSizeIsChecked_thenCorrect() { + final Iterable collection = Lists.newArrayList("ab", "cd", "ef"); + assertThat(collection, Matchers. iterableWithSize(3)); + } + + @Test + public final void whenCheckingConditionOverEachItem_thenCorrect() { + final List collection = Lists.newArrayList(15, 20, 25, 30); + assertThat(collection, everyItem(greaterThan(10))); + } + +} diff --git a/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java b/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java new file mode 100644 index 000000000000..1071d4a5fb67 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java @@ -0,0 +1,43 @@ +package org.baeldung.java; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class CollectionApachePartitionUnitTest { + + // tests - apache common collections + + @Test + public final void givenList_whenParitioningIntoNSublists_thenCorrect() { + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final List> subSets = ListUtils.partition(intList, 3); + + // When + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8); + assertThat(subSets.size(), equalTo(3)); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChange() { + // Given + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + final List> subSets = ListUtils.partition(intList, 3); + + // When + intList.add(9); + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8, 9); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + +} diff --git a/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java b/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java new file mode 100644 index 000000000000..c4ddb35da249 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java @@ -0,0 +1,56 @@ +package org.baeldung.java; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.Collection; +import java.util.List; + +import org.junit.Test; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +public class CollectionGuavaPartitionUnitTest { + + // tests - guava + + @Test + public final void givenList_whenParitioningIntoNSublists_thenCorrect() { + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final List> subSets = Lists.partition(intList, 3); + + // When + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8); + assertThat(subSets.size(), equalTo(3)); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChangeAsWell() { + // Given + final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + final List> subSets = Lists.partition(intList, 3); + + // When + intList.add(9); + final List lastPartition = subSets.get(2); + final List expectedLastPartition = Lists. newArrayList(7, 8, 9); + assertThat(lastPartition, equalTo(expectedLastPartition)); + } + + @Test + public final void givenCollection_whenParitioningIntoNSublists_thenCorrect() { + final Collection intCollection = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); + + final Iterable> subSets = Iterables.partition(intCollection, 3); + + // When + final List firstPartition = subSets.iterator().next(); + final List expectedLastPartition = Lists. newArrayList(1, 2, 3); + assertThat(firstPartition, equalTo(expectedLastPartition)); + } + +} diff --git a/jackson/src/test/resources/.gitignore b/jackson/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/jackson/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From c9d4d73b48d4b77cb8d168798bd0245dc48fe7f1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 15:25:50 +0200 Subject: [PATCH 346/796] cleanup work --- .../guava/GuavaCollectionsExamplesTest.java | 189 ------------------ .../guava/GuavaFunctionalExamplesTest.java | 186 ----------------- .../guava/GuavaOrderingExamplesTest.java | 179 ----------------- .../hamcrest/HamcrestExamplesTest.java | 97 --------- .../{ => org/baeldung}/jackson/FooDto.java | 2 +- .../baeldung}/jackson/JacksonUnitTest.java | 2 +- .../CollectionApachePartitionUnitTest.java | 43 ---- .../CollectionGuavaPartitionUnitTest.java | 56 ------ 8 files changed, 2 insertions(+), 752 deletions(-) delete mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java delete mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java delete mode 100644 jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java delete mode 100644 jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java rename jackson/src/test/java/{ => org/baeldung}/jackson/FooDto.java (96%) rename jackson/src/test/java/{ => org/baeldung}/jackson/JacksonUnitTest.java (96%) delete mode 100644 jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java delete mode 100644 jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java deleted file mode 100644 index 2c137e6c8041..000000000000 --- a/jackson/src/test/java/org/baeldung/guava/GuavaCollectionsExamplesTest.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.baeldung.guava; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import org.junit.Test; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -@SuppressWarnings("unused") -public class GuavaCollectionsExamplesTest { - - // tests - - @Test - public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() { - final class CastFunction implements Function { - @SuppressWarnings("unchecked") - @Override - public final T apply(final F from) { - return (T) from; - } - } - - final List originalList = Lists.newArrayList(); - final List selectedProducts = Lists.transform(originalList, new CastFunction()); - System.out.println(selectedProducts); - } - - @SuppressWarnings({ "unchecked" }) - @Test - public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() { - final List originalList = Lists.newArrayList(); - final List selectedProducts = (List) (List) originalList; - System.out.println(selectedProducts); - } - - @Test - public final void whenAddingAnIterableToACollection_thenAddedOK() { - final Iterable iter = Lists.newArrayList(); - final Collection collector = Lists.newArrayList(); - Iterables.addAll(collector, iter); - } - - // - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch1_thenContains() { - final Iterable theCollection = Lists.newArrayList("a", "bc", "def"); - final boolean contains = Iterables.any(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }); - - assertTrue(contains); - } - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch2_thenContains() { - final Set theCollection = Sets.newHashSet("a", "bc", "def"); - - final boolean contains = !Sets.filter(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }).isEmpty(); - - assertTrue(contains); - } - - @Test - public final void whenCheckingIfCollectionContainsElementsByCustomMatch3_thenContains() { - final Iterable theCollection = Sets.newHashSet("a", "bc", "def"); - - final boolean contains = Iterables.find(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }) != null; - - assertTrue(contains); - } - - // - - @Test(expected = NoSuchElementException.class) - public final void givenNoSearchResult_whenFindingElementInIterable_thenException() { - final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); - - final String found = Iterables.find(theCollection, new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }); - - assertNull(found); - } - - @Test - public final void givenNoSearchResult_whenFindingElementInIterableWithSpecifiedReturn_thenNoException() { - final Iterable theCollection = Sets.newHashSet("abcd", "efgh", "ijkl"); - - final Predicate inputOfLengthOne = new Predicate() { - @Override - public final boolean apply(final String input) { - return input.length() == 1; - } - }; - final String found = Iterables.find(theCollection, inputOfLengthOne, null); - - assertNull(found); - } - - // purge of nulls - - @Test - public final void givenListContainsNulls_whenPurgedOfNulls_thenNoLongerContainsNulls() { - final List values = Lists.newArrayList("a", null, "b", "c"); - final Iterable withoutNulls = Iterables.filter(values, Predicates.notNull()); - System.out.println(withoutNulls); - } - - // immutable collections - - @Test - public final void whenCreatingImuutableCollections_thenNoExceptions() { - final ImmutableList immutableList = ImmutableList.of("a", "b", "c"); - final ImmutableSet immutableSet = ImmutableSet.of("a", "b", "c"); - final ImmutableMap imuttableMap = ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3"); - } - - @Test - public final void whenTransformingCollectionsToImmutable_thenNoExceptions() { - final List muttableList = Lists.newArrayList(); - final ImmutableList immutableList = ImmutableList.copyOf(muttableList); - - final Set muttableSet = Sets.newHashSet(); - final ImmutableSet immutableSet = ImmutableSet.copyOf(muttableSet); - - final Map muttableMap = Maps.newHashMap(); - final ImmutableMap imuttableMap = ImmutableMap.copyOf(muttableMap); - } - - @Test - public final void whenTransformingCollectionsToImmutableViaBuilders_thenNoExceptions() { - final List muttableList = Lists.newArrayList(); - final ImmutableList immutableList = ImmutableList. builder().addAll(muttableList).build(); - - final Set muttableSet = Sets.newHashSet(); - final ImmutableSet immutableSet = ImmutableSet. builder().addAll(muttableSet).build(); - - final Map muttableMap = Maps.newHashMap(); - final ImmutableMap imuttableMap = ImmutableMap. builder().putAll(muttableMap).build(); - } - - // unmodifiable - - @Test(expected = UnsupportedOperationException.class) - public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() { - final List numbers = Lists.newArrayList(1, 2, 3); - final Iterable unmodifiableIterable = Iterables.unmodifiableIterable(numbers); - final Iterator iterator = unmodifiableIterable.iterator(); - if (iterator.hasNext()) { - iterator.remove(); - } - } - -} diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java deleted file mode 100644 index 08091639f169..000000000000 --- a/jackson/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.baeldung.guava; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Collections2; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Ordering; -import com.google.common.collect.Sets; - -public class GuavaFunctionalExamplesTest { - - // tests - - // predicates - filtering - - @Test - public final void whenFilteringNumbersAccordingToACondition_thenCorrectResults() { - final List numbers = Lists.newArrayList(1, 2, 3, 6, 8, 10, 34, 57, 89); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final List evenNumbers = Lists.newArrayList(Collections2.filter(numbers, acceptEvenNumber)); - - final Integer found = Collections.binarySearch(evenNumbers, 57); - assertThat(found, lessThan(0)); - } - - @Test - public final void givenCollectionContainsNulls_whenNullsAreFilteredOut_thenResultingCollectionsHasNoNulls() { - final List withNulls = Lists.newArrayList("a", "bc", null, "def"); - final Iterable withoutNuls = Iterables.filter(withNulls, Predicates.notNull()); - - assertTrue(Iterables.all(withoutNuls, Predicates.notNull())); - } - - // predicates - checking - - @Test - public final void givenEvenNumbers_whenCheckingIfAllSatisfyTheEvenPredicate_thenYes() { - final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - - assertTrue(Iterables.all(evenNumbers, acceptEvenNumber)); - } - - // negating a predicate - - @Test - public final void givenCollectionOfEvenNumbers_whenCheckingThatCollectionContainsNoOddNumber_thenTrue() { - final List evenNumbers = Lists.newArrayList(2, 6, 8, 10, 34, 90); - final Predicate acceptOddNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) != 0; - } - }; - - assertTrue(Iterables.all(evenNumbers, Predicates.not(acceptOddNumber))); - } - - // other predicates - - @Test - public final void when_thenCorrect() { - // CharMatcher.forPredicate(predicate) - } - - // functions - - @Test - public final void whenApplyingSimpleFunctionToInputs_thenCorrectlyTransformed() { - final List numbers = Lists.newArrayList(1, 2, 3); - final List numbersAsStrings = Lists.transform(numbers, Functions.toStringFunction()); - assertThat(numbersAsStrings, contains("1", "2", "3")); - } - - @Test - public final void whenUsingAnIntermediaryFunctionToOrder_thenCorerctlyOrderedInAlphabeticalOrder() { - final List numbersToSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); - final List inAlphabeticalOrder = ordering.sortedCopy(numbersToSort); - - final List correctAlphabeticalOrder = Lists.newArrayList(1, 100, 11, 14, 2, 8); - assertThat(correctAlphabeticalOrder, equalTo(inAlphabeticalOrder)); - } - - @Test - public final void whenChainingPredicatesAndFunctions_thenCorrectResults() { - final List numbers = Arrays.asList(2, 1, 11, 100, 8, 14); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - - final FluentIterable powerOfTwoOnlyForEvenNumbers = FluentIterable.from(numbers).filter(acceptEvenNumber).transform(powerOfTwo); - assertThat(powerOfTwoOnlyForEvenNumbers, contains(4, 10000, 64, 196)); - } - - @Test - public final void whenUsingFunctionComposition_thenCorrectResults() { - final List numbers = Arrays.asList(2, 3); - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - - final List result = Lists.transform(numbers, Functions.compose(powerOfTwo, powerOfTwo)); - assertThat(result, contains(16, 81)); - } - - // Set+Function => Map - - /** - * - see: http://code.google.com/p/guava-libraries/issues/detail?id=56 - */ - @Test - public final void whenMapIsBackedBySetAndFunction_thenCorrect() { - final Function powerOfTwo = new Function() { - @Override - public final Integer apply(final Integer input) { - return (int) Math.pow(input, 2); - } - }; - final Set lowNumbers = Sets.newHashSet(2, 3, 4); - - final Map numberToPowerOfTwoMuttable = Maps.asMap(lowNumbers, powerOfTwo); - final Map numberToPowerOfTwoImuttable = Maps.toMap(lowNumbers, powerOfTwo); - assertThat(numberToPowerOfTwoMuttable.get(2), equalTo(4)); - assertThat(numberToPowerOfTwoImuttable.get(2), equalTo(4)); - } - - // Predicate => Function - - @Test - public final void whenConvertingPredicateToFunction_thenCorrect() { - final List numbers = Lists.newArrayList(1, 2, 3, 6); - final Predicate acceptEvenNumber = new Predicate() { - @Override - public final boolean apply(final Integer number) { - return (number % 2) == 0; - } - }; - final Function isEventNumberFunction = Functions.forPredicate(acceptEvenNumber); - final List areNumbersEven = Lists.transform(numbers, isEventNumberFunction); - - assertThat(areNumbersEven, contains(false, true, false, true)); - } - -} diff --git a/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java b/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java deleted file mode 100644 index 5821d19ba05b..000000000000 --- a/jackson/src/test/java/org/baeldung/guava/GuavaOrderingExamplesTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.baeldung.guava; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.Test; - -import com.google.common.base.Functions; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.primitives.Ints; - -public class GuavaOrderingExamplesTest { - - private final class OrderingByLenght extends Ordering { - @Override - public final int compare(final String s1, final String s2) { - return Ints.compare(s1.length(), s2.length()); - } - } - - // tests - - // dealing with null - - @Test - public final void givenCollectionWithNulls_whenSortingWithNullsLast_thenNullsAreLast() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsLast()); - assertThat(toSort.get(toSort.size() - 1), nullValue()); - } - - @Test - public final void givenCollectionWithNulls_whenSortingWithNullsFirst_thenNullsAreFirst() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsFirst()); - assertThat(toSort.get(0), nullValue()); - } - - @Test - public final void whenCollectionIsSortedNullsLastReversed_thenNullAreFirst() { - final List toSort = Arrays.asList(3, 5, 4, null, 1, 2); - Collections.sort(toSort, Ordering.natural().nullsLast().reverse()); - assertThat(toSort.get(0), nullValue()); - } - - // natural ordering - - @Test - public final void whenSortingWithNaturalOrdering_thenCorectlySorted() { - final List toSort = Arrays.asList(3, 5, 4, 1, 2); - Collections.sort(toSort, Ordering.natural()); - - assertTrue(Ordering.natural().isOrdered(toSort)); - } - - // checking string ordering - - @Test - public final void givenCollectionContainsDuplicates_whenCheckingStringOrdering_thenNo() { - final List toSort = Arrays.asList(3, 5, 4, 2, 1, 2); - Collections.sort(toSort, Ordering.natural()); - - assertFalse(Ordering.natural().isStrictlyOrdered(toSort)); - } - - // custom - by length - - @Test - public final void givenCollectionIsSorted_whenUsingOrderingApiToCheckOrder_thenCheckCanBePerformed() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - Collections.sort(toSort, byLength); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsOfStringsByLenght_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - - Collections.sort(toSort, byLength); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "zz", "aa", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsOfStringsByLenghtWithSecondaryNaturalOrdering_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", "b", "ccc"); - final Ordering byLength = new OrderingByLenght(); - - Collections.sort(toSort, byLength.compound(Ordering.natural())); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "zz", "ccc")); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - @Test - public final void whenSortingCollectionsWithComplexOrderingExample_thenCorrectlySorted() { - final List toSort = Arrays.asList("zz", "aa", null, "b", "ccc"); - - Collections.sort(toSort, new OrderingByLenght().reverse().compound(Ordering.natural()).nullsLast()); - System.out.println(toSort); - } - - // sorted copy - - @Test - public final void givenUnorderdList_whenRetrievingSortedCopy_thenSorted() { - final List toSort = Arrays.asList("aa", "b", "ccc"); - final List sortedCopy = new OrderingByLenght().sortedCopy(toSort); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList("b", "aa", "ccc")); - assertFalse(expectedOrder.isOrdered(toSort)); - assertTrue(expectedOrder.isOrdered(sortedCopy)); - } - - // to string - - @Test - public final void givenUnorderdList_whenUsingToStringForSortingObjects_thenSortedWithToString() { - final List toSort = Arrays.asList(1, 2, 11); - Collections.sort(toSort, Ordering.usingToString()); - - final Ordering expectedOrder = Ordering.explicit(Lists.newArrayList(1, 11, 2)); - assertTrue(expectedOrder.isOrdered(toSort)); - } - - // binary search - - @Test - public final void whenPerformingBinarySearch_thenFound() { - final List toSort = Arrays.asList(1, 2, 11); - Collections.sort(toSort, Ordering.usingToString()); - final int found = Ordering.usingToString().binarySearch(toSort, 2); - - System.out.println(found); - } - - // min/max without actually sorting - - @Test - public final void whenFindingTheMinimalElementWithoutSorting_thenFound() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final int found = Ordering.natural().min(toSort); - assertThat(found, equalTo(1)); - } - - @Test - public final void whenFindingTheFirstFewElements_thenCorrect() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final List leastOf = Ordering.natural().leastOf(toSort, 3); - final List expected = Lists.newArrayList(1, 2, 8); - assertThat(expected, equalTo(leastOf)); - } - - // order the results of a Function - - @Test - public final void givenListOfNumbers_whenRunningAToStringFunctionThenSorting_thenCorrect() { - final List toSort = Arrays.asList(2, 1, 11, 100, 8, 14); - final Ordering ordering = Ordering.natural().onResultOf(Functions.toStringFunction()); - final List sortedCopy = ordering.sortedCopy(toSort); - - final List expected = Lists.newArrayList(1, 100, 11, 14, 2, 8); - assertThat(expected, equalTo(sortedCopy)); - } - -} diff --git a/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java b/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java deleted file mode 100644 index a44ce766f067..000000000000 --- a/jackson/src/test/java/org/baeldung/hamcrest/HamcrestExamplesTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.baeldung.hamcrest; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.emptyArray; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.everyItem; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.hamcrest.Matchers; -import org.junit.Test; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class HamcrestExamplesTest { - - // tests - - @Test - public final void whenVerifyingSingleElementIsPartOfCollection_thenCorrect() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasItem("cd")); - assertThat(collection, not(hasItem("zz"))); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollection_thenCorrect1() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasItems("ef", "cd")); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollectionInStrictOrder_thenCorrect2() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, contains("ab", "cd", "ef")); - } - - @Test - public final void whenVerifyingMultipleElementsArePartOfCollectionInAnyOrder_thenCorrect2() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, containsInAnyOrder("cd", "ab", "ef")); - } - - @Test - public final void givenCollectionIsEmpty_whenChecking_thenEmpty() { - final List collection = Lists.newArrayList(); - assertThat(collection, empty()); - } - - @Test - public final void givenCollectionIsNotEmpty_whenChecking_thenNotEmpty() { - final List collection = Lists.newArrayList("a"); - assertThat(collection, not(empty())); - } - - @Test - public final void givenMapIsEmpty_whenChecking_thenEmpty() { - final Map collection = Maps.newHashMap(); - assertThat(collection, equalTo(Collections.EMPTY_MAP)); - } - - @Test - public final void givenArrayIsEmpty_whenChecking_thenEmpty() { - final String[] array = new String[] { "ab" }; - assertThat(array, not(emptyArray())); - } - - @Test - public final void whenCollectionSizeIsChecked_thenCorrect() { - final List collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, hasSize(3)); - } - - @Test - public final void whenIterableSizeIsChecked_thenCorrect() { - final Iterable collection = Lists.newArrayList("ab", "cd", "ef"); - assertThat(collection, Matchers. iterableWithSize(3)); - } - - @Test - public final void whenCheckingConditionOverEachItem_thenCorrect() { - final List collection = Lists.newArrayList(15, 20, 25, 30); - assertThat(collection, everyItem(greaterThan(10))); - } - -} diff --git a/jackson/src/test/java/jackson/FooDto.java b/jackson/src/test/java/org/baeldung/jackson/FooDto.java similarity index 96% rename from jackson/src/test/java/jackson/FooDto.java rename to jackson/src/test/java/org/baeldung/jackson/FooDto.java index b086769f44be..b5315b0d7ea0 100644 --- a/jackson/src/test/java/jackson/FooDto.java +++ b/jackson/src/test/java/org/baeldung/jackson/FooDto.java @@ -1,4 +1,4 @@ -package jackson; +package org.baeldung.jackson; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/jackson/JacksonUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java similarity index 96% rename from jackson/src/test/java/jackson/JacksonUnitTest.java rename to jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java index d4e40d655046..dceb2cc4f3a2 100644 --- a/jackson/src/test/java/jackson/JacksonUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java @@ -1,4 +1,4 @@ -package jackson; +package org.baeldung.jackson; import java.io.IOException; diff --git a/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java b/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java deleted file mode 100644 index 1071d4a5fb67..000000000000 --- a/jackson/src/test/java/org/baeldung/java/CollectionApachePartitionUnitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.baeldung.java; - -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.util.List; - -import org.apache.commons.collections4.ListUtils; -import org.junit.Test; - -import com.google.common.collect.Lists; - -public class CollectionApachePartitionUnitTest { - - // tests - apache common collections - - @Test - public final void givenList_whenParitioningIntoNSublists_thenCorrect() { - final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); - - final List> subSets = ListUtils.partition(intList, 3); - - // When - final List lastPartition = subSets.get(2); - final List expectedLastPartition = Lists. newArrayList(7, 8); - assertThat(subSets.size(), equalTo(3)); - assertThat(lastPartition, equalTo(expectedLastPartition)); - } - - @Test - public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChange() { - // Given - final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); - final List> subSets = ListUtils.partition(intList, 3); - - // When - intList.add(9); - final List lastPartition = subSets.get(2); - final List expectedLastPartition = Lists. newArrayList(7, 8, 9); - assertThat(lastPartition, equalTo(expectedLastPartition)); - } - -} diff --git a/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java b/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java deleted file mode 100644 index c4ddb35da249..000000000000 --- a/jackson/src/test/java/org/baeldung/java/CollectionGuavaPartitionUnitTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.baeldung.java; - -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.util.Collection; -import java.util.List; - -import org.junit.Test; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -public class CollectionGuavaPartitionUnitTest { - - // tests - guava - - @Test - public final void givenList_whenParitioningIntoNSublists_thenCorrect() { - final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); - - final List> subSets = Lists.partition(intList, 3); - - // When - final List lastPartition = subSets.get(2); - final List expectedLastPartition = Lists. newArrayList(7, 8); - assertThat(subSets.size(), equalTo(3)); - assertThat(lastPartition, equalTo(expectedLastPartition)); - } - - @Test - public final void givenListPartitioned_whenOriginalListIsModified_thenPartitionsChangeAsWell() { - // Given - final List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); - final List> subSets = Lists.partition(intList, 3); - - // When - intList.add(9); - final List lastPartition = subSets.get(2); - final List expectedLastPartition = Lists. newArrayList(7, 8, 9); - assertThat(lastPartition, equalTo(expectedLastPartition)); - } - - @Test - public final void givenCollection_whenParitioningIntoNSublists_thenCorrect() { - final Collection intCollection = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8); - - final Iterable> subSets = Iterables.partition(intCollection, 3); - - // When - final List firstPartition = subSets.iterator().next(); - final List expectedLastPartition = Lists. newArrayList(1, 2, 3); - assertThat(firstPartition, equalTo(expectedLastPartition)); - } - -} From 88fe235abc89422ac34f3a061b90833473b48f83 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 15:26:49 +0200 Subject: [PATCH 347/796] cleanup work --- jackson/README.md | 10 +--------- jackson/pom.xml | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/jackson/README.md b/jackson/README.md index 8960b4676efb..e11f1b53efb9 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -1,13 +1,5 @@ ========= -## Guava and Hamcrest Cookbooks and Examples - +## Jackson Cookbooks and Examples ### Relevant Articles: -- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) -- [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) -- [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) - -- [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) - -- [Partition a List in Java](http://www.baeldung.com/java-list-split) diff --git a/jackson/pom.xml b/jackson/pom.xml index 89f025bd443b..5e72eb5cf135 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -64,7 +64,7 @@ - spring-rest + jackson src/main/resources From 6f9026a18322a16e1e15b0663e9d1e09d9af083f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 16:18:32 +0200 Subject: [PATCH 348/796] jackson work --- .../java/org/baeldung/jackson/BarDto.java | 42 +++++++ .../org/baeldung/jackson/JacksonUnitTest.java | 112 ++++++++++++++++-- .../test/java/org/baeldung/jackson/MyDto.java | 47 ++++++++ .../baeldung/jackson/MyDtoIgnoreUnkown.java | 50 ++++++++ 4 files changed, 243 insertions(+), 8 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/BarDto.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/MyDto.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java diff --git a/jackson/src/test/java/org/baeldung/jackson/BarDto.java b/jackson/src/test/java/org/baeldung/jackson/BarDto.java new file mode 100644 index 000000000000..0318dd06169a --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/BarDto.java @@ -0,0 +1,42 @@ +package org.baeldung.jackson; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(value = { "intValue" }) +public class BarDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public BarDto() { + super(); + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java index dceb2cc4f3a2..3bb2041a176f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java @@ -1,37 +1,133 @@ package org.baeldung.jackson; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + import java.io.IOException; +import java.util.List; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; +import com.google.common.collect.Lists; public class JacksonUnitTest { - // tests + // tests - single entity to json @Test - public final void whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { + public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String fooDtoAsString = mapper.writeValueAsString(new FooDto()); - System.out.println(fooDtoAsString); + final String dtoAsString = mapper.writeValueAsString(new FooDto()); + + assertThat(dtoAsString, not(containsString("intValue"))); + System.out.println(dtoAsString); } @Test - public final void whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { + public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final FooDto dtoObject = new FooDto(); dtoObject.setBooleanValue(true); - final String fooDtoAsString = mapper.writeValueAsString(dtoObject); - System.out.println(fooDtoAsString); + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final BarDto dtoObject = new BarDto(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + // tests - multiple entities to json + + @Test + public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + + final ObjectMapper mapper = new ObjectMapper(); + final String dtosAsString = mapper.writeValueAsString(listOfDtos); + + System.out.println(dtosAsString); } + // tests - json to single entity + + @Test + public final void whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDto readValue = mapper.readValue(jsonAsString, MyDto.class); + + assertNotNull(readValue); + assertThat(readValue.getStringValue(), equalTo("a")); + } + + @Test(expected = UnrecognizedPropertyException.class) + public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenExceptionIsThrown() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDto readValue = mapper.readValue(jsonAsString, MyDto.class); + + assertNotNull(readValue); + assertThat(readValue.getStringValue(), equalTo("a")); + assertThat(readValue.isBooleanValue(), equalTo(true)); + assertThat(readValue.getIntValue(), equalTo(1)); + } + + @Test + public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + final MyDto readValue = mapper.readValue(jsonAsString, MyDto.class); + + assertNotNull(readValue); + assertThat(readValue.getStringValue(), equalTo("a")); + assertThat(readValue.isBooleanValue(), equalTo(true)); + assertThat(readValue.getIntValue(), equalTo(1)); + } + + @Test + public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + final MyDtoIgnoreUnkown readValue = mapper.readValue(jsonAsString, MyDtoIgnoreUnkown.class); + + assertNotNull(readValue); + assertThat(readValue.getStringValue(), equalTo("a")); + assertThat(readValue.isBooleanValue(), equalTo(true)); + assertThat(readValue.getIntValue(), equalTo(1)); + } + + // tests - json to multiple entities + } /* Article Ideas: - Deserializing with a custom JsonParser - +- Jackson Ignore: ignore specific fields at field level, at class level, */ diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDto.java b/jackson/src/test/java/org/baeldung/jackson/MyDto.java new file mode 100644 index 000000000000..9334f2a0ed4c --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/MyDto.java @@ -0,0 +1,47 @@ +package org.baeldung.jackson; + +public class MyDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDto() { + super(); + } + + public MyDto(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java new file mode 100644 index 000000000000..b83dc9957d8a --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MyDtoIgnoreUnkown { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoIgnoreUnkown() { + super(); + } + + public MyDtoIgnoreUnkown(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} From 134248ac94b927ee8e0723edfde0e075766bcf43 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 16:49:46 +0200 Subject: [PATCH 349/796] jackson work --- ...va => JacksonDeserializationUnitTest.java} | 73 ++++--------------- .../jackson/JacksonSerializationUnitTest.java | 66 +++++++++++++++++ 2 files changed, 79 insertions(+), 60 deletions(-) rename jackson/src/test/java/org/baeldung/jackson/{JacksonUnitTest.java => JacksonDeserializationUnitTest.java} (59%) create mode 100644 jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java diff --git a/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java similarity index 59% rename from jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java rename to jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java index 3bb2041a176f..1bbdbeb07545 100644 --- a/jackson/src/test/java/org/baeldung/jackson/JacksonUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java @@ -1,72 +1,25 @@ package org.baeldung.jackson; -import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import java.io.IOException; -import java.util.List; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import com.google.common.collect.Lists; -public class JacksonUnitTest { - - // tests - single entity to json - - @Test - public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new FooDto()); - - assertThat(dtoAsString, not(containsString("intValue"))); - System.out.println(dtoAsString); - } - - @Test - public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final FooDto dtoObject = new FooDto(); - dtoObject.setBooleanValue(true); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); - - assertThat(dtoAsString, containsString("booleanValue")); - System.out.println(dtoAsString); - } - - @Test - public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final BarDto dtoObject = new BarDto(); - dtoObject.setBooleanValue(true); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); - - assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); - System.out.println(dtoAsString); - } - - // tests - multiple entities to json - - @Test - public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); - - final ObjectMapper mapper = new ObjectMapper(); - final String dtosAsString = mapper.writeValueAsString(listOfDtos); - - System.out.println(dtosAsString); - } +public class JacksonDeserializationUnitTest { // tests - json to single entity @@ -120,14 +73,14 @@ public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenD assertThat(readValue.getStringValue(), equalTo("a")); assertThat(readValue.isBooleanValue(), equalTo(true)); assertThat(readValue.getIntValue(), equalTo(1)); - } - // tests - json to multiple entities + mapper.addHandler(new DeserializationProblemHandler() { + @Override + public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp, final JsonDeserializer deserializer, final Object beanOrClass, final String propertyName) throws IOException, JsonProcessingException { + return super.handleUnknownProperty(ctxt, jp, deserializer, beanOrClass, propertyName); + } + }); + } } -/* -Article Ideas: -- Deserializing with a custom JsonParser -- Jackson Ignore: ignore specific fields at field level, at class level, - */ diff --git a/jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java new file mode 100644 index 000000000000..46bdff06fb41 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java @@ -0,0 +1,66 @@ +package org.baeldung.jackson; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Lists; + +public class JacksonSerializationUnitTest { + + // tests - single entity to json + + @Test + public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new FooDto()); + + assertThat(dtoAsString, not(containsString("intValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final FooDto dtoObject = new FooDto(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final BarDto dtoObject = new BarDto(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + // tests - multiple entities to json + + @Test + public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + + final ObjectMapper mapper = new ObjectMapper(); + final String dtosAsString = mapper.writeValueAsString(listOfDtos); + + System.out.println(dtosAsString); + } + +} From 62e0386a9d231d34de6a05a46ea98f6a2f61fac6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 22:28:51 +0200 Subject: [PATCH 350/796] further jackson examples --- .../org/baeldung/jackson/MyBooleanMixIn.java | 8 +++ ...arDto.java => MyDtoIgnoreFieldByName.java} | 4 +- .../org/baeldung/jackson/MyDtoIgnoreType.java | 50 +++++++++++++++++++ ...ooDto.java => MyDtoIncludeNonDefault.java} | 4 +- .../JacksonDeserializationUnitTest.java | 4 +- .../JacksonSerializationUnitTest.java | 27 ++++++++-- 6 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java rename jackson/src/test/java/org/baeldung/jackson/{BarDto.java => MyDtoIgnoreFieldByName.java} (91%) create mode 100644 jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java rename jackson/src/test/java/org/baeldung/jackson/{FooDto.java => MyDtoIncludeNonDefault.java} (91%) rename jackson/src/test/java/org/baeldung/jackson/{ => test}/JacksonDeserializationUnitTest.java (97%) rename jackson/src/test/java/org/baeldung/jackson/{ => test}/JacksonSerializationUnitTest.java (67%) diff --git a/jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java b/jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java new file mode 100644 index 000000000000..feb19f1144e0 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java @@ -0,0 +1,8 @@ +package org.baeldung.jackson; + +import com.fasterxml.jackson.annotation.JsonIgnoreType; + +@JsonIgnoreType +public class MyBooleanMixIn { + // +} diff --git a/jackson/src/test/java/org/baeldung/jackson/BarDto.java b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java similarity index 91% rename from jackson/src/test/java/org/baeldung/jackson/BarDto.java rename to jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java index 0318dd06169a..20d13153635a 100644 --- a/jackson/src/test/java/org/baeldung/jackson/BarDto.java +++ b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java @@ -3,13 +3,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(value = { "intValue" }) -public class BarDto { +public class MyDtoIgnoreFieldByName { private String stringValue; private int intValue; private boolean booleanValue; - public BarDto() { + public MyDtoIgnoreFieldByName() { super(); } diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java new file mode 100644 index 000000000000..b9d776292a5a --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MyDtoIgnoreType { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoIgnoreType() { + super(); + } + + public MyDtoIgnoreType(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/FooDto.java b/jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java similarity index 91% rename from jackson/src/test/java/org/baeldung/jackson/FooDto.java rename to jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java index b5315b0d7ea0..451d22eb9af3 100644 --- a/jackson/src/test/java/org/baeldung/jackson/FooDto.java +++ b/jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java @@ -4,13 +4,13 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; @JsonInclude(Include.NON_DEFAULT) -public class FooDto { +public class MyDtoIncludeNonDefault { private String stringValue; private int intValue; private boolean booleanValue; - public FooDto() { + public MyDtoIncludeNonDefault() { super(); } diff --git a/jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java similarity index 97% rename from jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java rename to jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 1bbdbeb07545..aeadf3fad1f1 100644 --- a/jackson/src/test/java/org/baeldung/jackson/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.test; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertNotNull; @@ -6,6 +6,8 @@ import java.io.IOException; +import org.baeldung.jackson.MyDto; +import org.baeldung.jackson.MyDtoIgnoreUnkown; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; diff --git a/jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java similarity index 67% rename from jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java rename to jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 46bdff06fb41..4765669a60d5 100644 --- a/jackson/src/test/java/org/baeldung/jackson/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.test; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -7,6 +7,10 @@ import java.io.IOException; import java.util.List; +import org.baeldung.jackson.MyBooleanMixIn; +import org.baeldung.jackson.MyDto; +import org.baeldung.jackson.MyDtoIgnoreFieldByName; +import org.baeldung.jackson.MyDtoIncludeNonDefault; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; @@ -20,7 +24,7 @@ public class JacksonSerializationUnitTest { @Test public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new FooDto()); + final String dtoAsString = mapper.writeValueAsString(new MyDtoIncludeNonDefault()); assertThat(dtoAsString, not(containsString("intValue"))); System.out.println(dtoAsString); @@ -29,7 +33,7 @@ public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultVa @Test public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final FooDto dtoObject = new FooDto(); + final MyDtoIncludeNonDefault dtoObject = new MyDtoIncludeNonDefault(); dtoObject.setBooleanValue(true); final String dtoAsString = mapper.writeValueAsString(dtoObject); @@ -41,7 +45,7 @@ public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultVal @Test public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final BarDto dtoObject = new BarDto(); + final MyDtoIgnoreFieldByName dtoObject = new MyDtoIgnoreFieldByName(); dtoObject.setBooleanValue(true); final String dtoAsString = mapper.writeValueAsString(dtoObject); @@ -51,6 +55,21 @@ public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws J System.out.println(dtoAsString); } + @Test + public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.addMixInAnnotations(String.class, MyBooleanMixIn.class); + final MyDto dtoObject = new MyDto(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + // tests - multiple entities to json @Test From e088098c50108d0e0de76f97dd568a49a1ee433f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 23:04:01 +0200 Subject: [PATCH 351/796] further jackson work --- .../baeldung/jackson/MyDtoIgnoreField.java | 42 +++++++++++++++++++ ...ooleanMixIn.java => MyMixInForString.java} | 2 +- .../test/JacksonSerializationUnitTest.java | 19 +++++++-- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java rename jackson/src/test/java/org/baeldung/jackson/{MyBooleanMixIn.java => MyMixInForString.java} (77%) diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java new file mode 100644 index 000000000000..6a580eab3f89 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java @@ -0,0 +1,42 @@ +package org.baeldung.jackson; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class MyDtoIgnoreField { + + private String stringValue; + @JsonIgnore + private int intValue; + private boolean booleanValue; + + public MyDtoIgnoreField() { + super(); + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java b/jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java similarity index 77% rename from jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java rename to jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java index feb19f1144e0..a215559a8459 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyBooleanMixIn.java +++ b/jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java @@ -3,6 +3,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreType; @JsonIgnoreType -public class MyBooleanMixIn { +public class MyMixInForString { // } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 4765669a60d5..a7c54a620d27 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -7,8 +7,9 @@ import java.io.IOException; import java.util.List; -import org.baeldung.jackson.MyBooleanMixIn; +import org.baeldung.jackson.MyMixInForString; import org.baeldung.jackson.MyDto; +import org.baeldung.jackson.MyDtoIgnoreField; import org.baeldung.jackson.MyDtoIgnoreFieldByName; import org.baeldung.jackson.MyDtoIncludeNonDefault; import org.junit.Test; @@ -43,7 +44,7 @@ public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultVal } @Test - public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + public final void givenFieldIsIgnoredByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoIgnoreFieldByName dtoObject = new MyDtoIgnoreFieldByName(); dtoObject.setBooleanValue(true); @@ -55,10 +56,22 @@ public final void givenFieldIsIgnored_whenDtoIsSerialized_thenCorrect() throws J System.out.println(dtoAsString); } + @Test + public final void givenFieldIsIgnoredDirectly_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIgnoreField dtoObject = new MyDtoIgnoreField(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + @Test public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - mapper.addMixInAnnotations(String.class, MyBooleanMixIn.class); + mapper.addMixInAnnotations(String.class, MyMixInForString.class); final MyDto dtoObject = new MyDto(); dtoObject.setBooleanValue(true); From ca3e353165d21c794ff867b3b0bd63d56b69bed7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 23:14:43 +0200 Subject: [PATCH 352/796] cleanup work --- jackson/README.md | 1 + .../java/org/baeldung/jackson/{ => ignore}/MyDto.java | 2 +- .../jackson/{ => ignore}/MyDtoIgnoreField.java | 2 +- .../jackson/{ => ignore}/MyDtoIgnoreFieldByName.java | 2 +- .../baeldung/jackson/{ => ignore}/MyDtoIgnoreType.java | 2 +- .../jackson/{ => ignore}/MyDtoIgnoreUnkown.java | 2 +- .../jackson/{ => ignore}/MyDtoIncludeNonDefault.java | 2 +- .../jackson/{ => ignore}/MyMixInForString.java | 2 +- .../jackson/test/JacksonDeserializationUnitTest.java | 4 ++-- .../jackson/test/JacksonSerializationUnitTest.java | 10 +++++----- spring-security-rest/README.md | 2 +- 11 files changed, 16 insertions(+), 15 deletions(-) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDto.java (96%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDtoIgnoreField.java (95%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDtoIgnoreFieldByName.java (95%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDtoIgnoreType.java (96%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDtoIgnoreUnkown.java (96%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyDtoIncludeNonDefault.java (95%) rename jackson/src/test/java/org/baeldung/jackson/{ => ignore}/MyMixInForString.java (75%) diff --git a/jackson/README.md b/jackson/README.md index e11f1b53efb9..3601f99efe54 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -3,3 +3,4 @@ ## Jackson Cookbooks and Examples ### Relevant Articles: +- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDto.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/MyDto.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java index 9334f2a0ed4c..32fcfd4ba639 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDto.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; public class MyDto { diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java index 6a580eab3f89..bdbc694207ac 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreField.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java index 20d13153635a..0b4378db7581 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreFieldByName.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java index b9d776292a5a..a159015f08cc 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreType.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java index b83dc9957d8a..5f0de0c7fe34 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDtoIgnoreUnkown.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java index 451d22eb9af3..6d1b76a39dff 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyDtoIncludeNonDefault.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java similarity index 75% rename from jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java rename to jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java index a215559a8459..1439cca793fe 100644 --- a/jackson/src/test/java/org/baeldung/jackson/MyMixInForString.java +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson; +package org.baeldung.jackson.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreType; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index aeadf3fad1f1..07c960ba6691 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -6,8 +6,8 @@ import java.io.IOException; -import org.baeldung.jackson.MyDto; -import org.baeldung.jackson.MyDtoIgnoreUnkown; +import org.baeldung.jackson.ignore.MyDto; +import org.baeldung.jackson.ignore.MyDtoIgnoreUnkown; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index a7c54a620d27..bbabdb33145b 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -7,11 +7,11 @@ import java.io.IOException; import java.util.List; -import org.baeldung.jackson.MyMixInForString; -import org.baeldung.jackson.MyDto; -import org.baeldung.jackson.MyDtoIgnoreField; -import org.baeldung.jackson.MyDtoIgnoreFieldByName; -import org.baeldung.jackson.MyDtoIncludeNonDefault; +import org.baeldung.jackson.ignore.MyDto; +import org.baeldung.jackson.ignore.MyDtoIgnoreField; +import org.baeldung.jackson.ignore.MyDtoIgnoreFieldByName; +import org.baeldung.jackson.ignore.MyDtoIncludeNonDefault; +import org.baeldung.jackson.ignore.MyMixInForString; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index 11522e362f47..a3fce32a9cbb 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: -- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file +- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) From ca5d33bb9a15634dfb8ce2cd927798e0f69e51b8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Dec 2013 23:46:51 +0200 Subject: [PATCH 353/796] minor jackson upgrade, using jackson filters --- jackson/pom.xml | 2 +- .../jackson/ignore/MyDtoWithFilter.java | 50 +++++++++++++++++++ .../test/JacksonSerializationUnitTest.java | 21 ++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java diff --git a/jackson/pom.xml b/jackson/pom.xml index 5e72eb5cf135..348e1b8ef224 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -104,7 +104,7 @@ 5.1.27 - 2.2.3 + 2.3.0 1.7.5 diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java new file mode 100644 index 000000000000..2492cb82cbc1 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson.ignore; + +import com.fasterxml.jackson.annotation.JsonFilter; + +@JsonFilter("myFilter") +public class MyDtoWithFilter { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoWithFilter() { + super(); + } + + public MyDtoWithFilter(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index bbabdb33145b..0561b84a1361 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -11,11 +11,15 @@ import org.baeldung.jackson.ignore.MyDtoIgnoreField; import org.baeldung.jackson.ignore.MyDtoIgnoreFieldByName; import org.baeldung.jackson.ignore.MyDtoIncludeNonDefault; +import org.baeldung.jackson.ignore.MyDtoWithFilter; import org.baeldung.jackson.ignore.MyMixInForString; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ser.FilterProvider; +import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; +import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import com.google.common.collect.Lists; public class JacksonSerializationUnitTest { @@ -83,6 +87,23 @@ public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() thro System.out.println(dtoAsString); } + @Test + public final void givenTypeHasFilterThatIgnoresIntsOver10_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("intValue"); + final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); + + final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); + dtoObject.setIntValue(12); + + final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, containsString("stringValue")); + System.out.println(dtoAsString); + } + // tests - multiple entities to json @Test From 78abeaf83895fcb573e01c740a542463ba8b2ba4 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 00:17:17 +0200 Subject: [PATCH 354/796] custom jackson serialization --- .../test/JacksonSerializationUnitTest.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 0561b84a1361..4a25f33b8716 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -15,9 +15,14 @@ import org.baeldung.jackson.ignore.MyMixInForString; import org.junit.Test; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; import com.fasterxml.jackson.databind.ser.FilterProvider; +import com.fasterxml.jackson.databind.ser.PropertyFilter; +import com.fasterxml.jackson.databind.ser.PropertyWriter; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import com.google.common.collect.Lists; @@ -88,7 +93,7 @@ public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() thro } @Test - public final void givenTypeHasFilterThatIgnoresIntsOver10_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("intValue"); final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); @@ -104,6 +109,49 @@ public final void givenTypeHasFilterThatIgnoresIntsOver10_whenDtoIsSerialized_th System.out.println(dtoAsString); } + @Test + public final void givenTypeHasFilterThatIgnoresIntsOver10_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final PropertyFilter theFilter = new SimpleBeanPropertyFilter() { + @Override + public final void serializeAsField(final Object pojo, final JsonGenerator jgen, final SerializerProvider provider, final PropertyWriter writer) throws Exception { + if (include(writer)) { + if (writer.getName().equals("intValue")) { + final int intValue = ((MyDtoWithFilter) pojo).getIntValue(); + if (intValue < 10) { + writer.serializeAsField(pojo, jgen, provider); + } + } else { + writer.serializeAsField(pojo, jgen, provider); + } + } else if (!jgen.canOmitFields()) { // since 2.3 + writer.serializeAsOmittedField(pojo, jgen, provider); + } + } + + @Override + protected final boolean include(final BeanPropertyWriter writer) { + return true; + } + + @Override + protected final boolean include(final PropertyWriter writer) { + return true; + } + }; + final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); + + final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); + dtoObject.setIntValue(12); + + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, containsString("stringValue")); + System.out.println(dtoAsString); + } + // tests - multiple entities to json @Test From 5e462746e24171187ced73b1dbc35da58e850a51 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 00:41:51 +0200 Subject: [PATCH 355/796] minor fix for spring config --- .../main/java/org/baeldung/spring/PersistenceJPAConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java index dac41e182b23..3b36b47438e7 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -2,6 +2,7 @@ import java.util.Properties; +import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; @@ -58,10 +59,9 @@ public DataSource dataSource() { } @Bean - public PlatformTransactionManager transactionManager() { + public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) { final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactoryBean().getObject()); - + transactionManager.setEntityManagerFactory(emf); return transactionManager; } From 502e405fc73ef3599120b02d5d5c7e3c6ce06c7d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 11:44:54 +0200 Subject: [PATCH 356/796] jackson work --- .../jackson/ignore/MyDtoFieldNameChanged.java | 50 +++++++++++++++++++ .../test/JacksonDeserializationUnitTest.java | 12 ++++- .../test/JacksonSerializationUnitTest.java | 37 ++++++++++---- 3 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java new file mode 100644 index 000000000000..5b98547ae340 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson.ignore; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class MyDtoFieldNameChanged { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoFieldNameChanged() { + super(); + } + + public MyDtoFieldNameChanged(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + @JsonProperty("strVal") + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 07c960ba6691..a0df4056af5f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -36,6 +36,17 @@ public final void whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseE assertThat(readValue.getStringValue(), equalTo("a")); } + @Test + public final void givenNotAllFieldsHaveValuesInJson_whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"a\",\"booleanValue\":true}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDto readValue = mapper.readValue(jsonAsString, MyDto.class); + + assertNotNull(readValue); + assertThat(readValue.getStringValue(), equalTo("a")); + } + @Test(expected = UnrecognizedPropertyException.class) public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenExceptionIsThrown() throws JsonParseException, JsonMappingException, IOException { final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; @@ -85,4 +96,3 @@ public boolean handleUnknownProperty(final DeserializationContext ctxt, final Js } } - diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 4a25f33b8716..04f1cf066b59 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -8,6 +8,7 @@ import java.util.List; import org.baeldung.jackson.ignore.MyDto; +import org.baeldung.jackson.ignore.MyDtoFieldNameChanged; import org.baeldung.jackson.ignore.MyDtoIgnoreField; import org.baeldung.jackson.ignore.MyDtoIgnoreFieldByName; import org.baeldung.jackson.ignore.MyDtoIncludeNonDefault; @@ -32,7 +33,7 @@ public class JacksonSerializationUnitTest { // tests - single entity to json @Test - public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultValues_thenCorrect() throws JsonParseException, IOException { + public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasOnlyDefaultValues_whenSerializing_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final String dtoAsString = mapper.writeValueAsString(new MyDtoIncludeNonDefault()); @@ -41,7 +42,7 @@ public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasOnlyDefaultVa } @Test - public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultValue_thenCorrect() throws JsonParseException, IOException { + public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasNonDefaultValue_whenSerializing_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoIncludeNonDefault dtoObject = new MyDtoIncludeNonDefault(); dtoObject.setBooleanValue(true); @@ -52,6 +53,21 @@ public final void givenOnlyNonDefaultValuesAreSerialized_whenDtoHasNonDefaultVal System.out.println(dtoAsString); } + @Test + public final void givenNameOfFieldIsChanged_whenSerializing_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoFieldNameChanged dtoObject = new MyDtoFieldNameChanged(); + dtoObject.setStringValue("a"); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("stringValue"))); + assertThat(dtoAsString, containsString("strVal")); + System.out.println(dtoAsString); + } + + // ignore + @Test public final void givenFieldIsIgnoredByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); @@ -110,17 +126,18 @@ public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_t } @Test - public final void givenTypeHasFilterThatIgnoresIntsOver10_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + public final void givenTypeHasFilterThatIgnoresNegativeInt_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { final PropertyFilter theFilter = new SimpleBeanPropertyFilter() { @Override public final void serializeAsField(final Object pojo, final JsonGenerator jgen, final SerializerProvider provider, final PropertyWriter writer) throws Exception { if (include(writer)) { - if (writer.getName().equals("intValue")) { - final int intValue = ((MyDtoWithFilter) pojo).getIntValue(); - if (intValue < 10) { - writer.serializeAsField(pojo, jgen, provider); - } - } else { + if (!writer.getName().equals("intValue")) { + writer.serializeAsField(pojo, jgen, provider); + return; + } + + final int intValue = ((MyDtoWithFilter) pojo).getIntValue(); + if (intValue >= 0) { writer.serializeAsField(pojo, jgen, provider); } } else if (!jgen.canOmitFields()) { // since 2.3 @@ -141,7 +158,7 @@ protected final boolean include(final PropertyWriter writer) { final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); - dtoObject.setIntValue(12); + dtoObject.setIntValue(-1); final ObjectMapper mapper = new ObjectMapper(); final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); From 9d954b0f4281eb61a82b838e635a74502a646e6b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 14:44:43 +0200 Subject: [PATCH 357/796] minor jackson testing and cleanup work --- httpclient/pom.xml | 2 +- .../test/JacksonDeserializationUnitTest.java | 30 ++++++++----------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 6185838d2b2c..f98735d8762d 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -14,7 +14,7 @@ com.google.guava guava - 15.0 + ${guava.version} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index a0df4056af5f..2965b732c216 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -11,14 +11,9 @@ import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; public class JacksonDeserializationUnitTest { @@ -45,6 +40,7 @@ public final void givenNotAllFieldsHaveValuesInJson_whenDeserializingAJsonToACla assertNotNull(readValue); assertThat(readValue.getStringValue(), equalTo("a")); + assertThat(readValue.isBooleanValue(), equalTo(true)); } @Test(expected = UnrecognizedPropertyException.class) @@ -61,8 +57,12 @@ public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenEx } @Test - public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; + public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString =// @formatter:off + "{\"stringValue\":\"a\"," + + "\"intValue\":1," + + "\"booleanValue\":true," + + "\"stringValue2\":\"something\"}"; // @formatter:on final ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -75,10 +75,13 @@ public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenD } @Test - public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; + public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString =// @formatter:off + "{\"stringValue\":\"a\"," + + "\"intValue\":1," + + "\"booleanValue\":true," + + "\"stringValue2\":\"something\"}"; // @formatter:on final ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); final MyDtoIgnoreUnkown readValue = mapper.readValue(jsonAsString, MyDtoIgnoreUnkown.class); @@ -86,13 +89,6 @@ public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenD assertThat(readValue.getStringValue(), equalTo("a")); assertThat(readValue.isBooleanValue(), equalTo(true)); assertThat(readValue.getIntValue(), equalTo(1)); - - mapper.addHandler(new DeserializationProblemHandler() { - @Override - public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp, final JsonDeserializer deserializer, final Object beanOrClass, final String propertyName) throws IOException, JsonProcessingException { - return super.handleUnknownProperty(ctxt, jp, deserializer, beanOrClass, propertyName); - } - }); } } From e597d29ca3394518946986ac64879e5a71a608ca Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 14:45:14 +0200 Subject: [PATCH 358/796] cleanup work --- .../baeldung/{mockito => httpclient}/HttpClientLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename httpclient/src/test/java/org/baeldung/{mockito => httpclient}/HttpClientLiveTest.java (99%) diff --git a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index 064ace1d2c03..3c2e17027269 100644 --- a/httpclient/src/test/java/org/baeldung/mockito/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package org.baeldung.httpclient; import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.equalTo; From ccb9c4a046bd8fe73723b384f9a5e66ab1e5f3a2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 17:19:45 +0200 Subject: [PATCH 359/796] cleanup and further http client examples --- .../httpclient/HttpClientLiveTest.java | 30 ++-- .../HttpClientRedirectLiveTest.java | 130 ++++++++++++++++++ 2 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index 3c2e17027269..cebc3a8b265e 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -8,7 +8,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.SocketTimeoutException; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -18,8 +17,10 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.apache.http.util.EntityUtils; @@ -29,7 +30,7 @@ public class HttpClientLiveTest { - private static final String SAMPLE_URL = "http://www.google.com"; + private static final String SAMPLE_URL = "http://www.github.com"; private CloseableHttpClient instance; @@ -88,9 +89,9 @@ public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBo assertThat(bodyAsString, notNullValue()); } - @Test(expected = SocketTimeoutException.class) + @Test(expected = ConnectTimeoutException.class) public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws ClientProtocolException, IOException { - final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(50).build(); + final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(20).build(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setConfig(requestConfig); response = instance.execute(request); @@ -111,13 +112,6 @@ public final void givenHttpClientIsConfiguredWithCustomConnectionManager_whenExe response = instance.execute(new HttpGet(SAMPLE_URL)); } - @Test - public final void givenRedirectsAreDisabled_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { - instance = HttpClientBuilder.create().disableRedirectHandling().build(); - response = instance.execute(new HttpGet("http://t.co/I5YYd9tddw")); - assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); - } - @Test public final void givenCustomHeaderIsSet_whenSendingRequest_thenNoExceptions() throws ClientProtocolException, IOException { final HttpGet request = new HttpGet(SAMPLE_URL); @@ -133,4 +127,18 @@ public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCo assertThat(headers, not(emptyArray())); } + // tests - headers + + @SuppressWarnings("deprecation") + @Test + public final void givenDeprecatedApi_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + instance = new DefaultHttpClient(); + final HttpGet request = new HttpGet(SAMPLE_URL); + request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); + + response = instance.execute(request); + + System.out.println(response); + } + } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java new file mode 100644 index 000000000000..3d01a02fbb87 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java @@ -0,0 +1,130 @@ +package org.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpHead; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.params.ClientPNames; +import org.apache.http.client.params.HttpClientParams; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.DefaultRedirectStrategy; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.LaxRedirectStrategy; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientRedirectLiveTest { + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + @SuppressWarnings("deprecation") + @Test + public final void givenRedirectsAreDisabledViaDeprecatedApi_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + instance = new DefaultHttpClient(); + + final HttpParams params = new BasicHttpParams(); + params.setParameter(ClientPNames.HANDLE_REDIRECTS, false); + HttpClientParams.setRedirecting(params, false); + + final HttpGet httpGet = new HttpGet("http://t.co/I5YYd9tddw"); + httpGet.setParams(params); + response = instance.execute(httpGet); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); + } + + @Test + public final void givenRedirectsAreDisabled_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().disableRedirectHandling().build(); + response = instance.execute(new HttpGet("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); + } + + // redirect with POST + + @Test + public final void givenPostRequest_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().build(); + response = instance.execute(new HttpPost("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); + } + + @SuppressWarnings("deprecation") + @Test + public final void givenRedirectingPOSTViaPre4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + final DefaultHttpClient client = new DefaultHttpClient(); + client.setRedirectStrategy(new DefaultRedirectStrategy() { + /** Redirectable methods. */ + private final String[] REDIRECT_METHODS = new String[] { HttpGet.METHOD_NAME, HttpPost.METHOD_NAME, HttpHead.METHOD_NAME }; + + @Override + protected boolean isRedirectable(final String method) { + for (final String m : REDIRECT_METHODS) { + if (m.equalsIgnoreCase(method)) { + return true; + } + } + return false; + } + }); + + response = client.execute(new HttpPost("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @SuppressWarnings("deprecation") + @Test + public final void givenRedirectingPOSTVia4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + final DefaultHttpClient client = new DefaultHttpClient(); + client.setRedirectStrategy(new LaxRedirectStrategy()); + + response = client.execute(new HttpPost("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @Test + public final void givenRedirectingPOST_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(); + response = instance.execute(new HttpPost("http://t.co/I5YYd9tddw")); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + +} From 799e702a734ea82d4ef69bdd7118cdd772abd01b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 17:35:15 +0200 Subject: [PATCH 360/796] logging work and http client usage --- httpclient/pom.xml | 27 ++++++++++++++++++- httpclient/src/main/resources/logback.xml | 25 ++++++++--------- .../httpclient/HttpClientLiveTest.java | 25 ++++++++++++++--- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index f98735d8762d..8047d56cd490 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -30,7 +30,32 @@ httpclient ${httpclient.version} - + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/httpclient/src/main/resources/logback.xml b/httpclient/src/main/resources/logback.xml index 1146dade632e..aa1e9cd52209 100644 --- a/httpclient/src/main/resources/logback.xml +++ b/httpclient/src/main/resources/logback.xml @@ -1,20 +1,17 @@ - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + - - + + - - - - - - + + + \ No newline at end of file diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index cebc3a8b265e..1088bf3c4ad1 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -22,7 +22,10 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpProtocolParams; import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; @@ -129,16 +132,30 @@ public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCo // tests - headers + @SuppressWarnings("deprecation") + @Test + public final void givenDeprecatedApi_whenClientUsesCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + final DefaultHttpClient client = new DefaultHttpClient(); + client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); + HttpProtocolParams.setUserAgent(client.getParams(), "Mozilla/5.0 Firefox/26.0"); + + final HttpGet request = new HttpGet(SAMPLE_URL); + response = client.execute(request); + } + @SuppressWarnings("deprecation") @Test public final void givenDeprecatedApi_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { - instance = new DefaultHttpClient(); + final DefaultHttpClient client = new DefaultHttpClient(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); + response = client.execute(request); + } - response = instance.execute(request); - - System.out.println(response); + @Test + public final void whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + instance = HttpClients.custom().setUserAgent("Mozilla/5.0 Firefox/26.0").build(); + response = instance.execute(new HttpGet(SAMPLE_URL)); } } From 858e786f156c3e4612ee3ebea3d2eaea488214c0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 17:52:06 +0200 Subject: [PATCH 361/796] sending a custom User-Agent --- .../java/org/baeldung/httpclient/HttpClientLiveTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index 1088bf3c4ad1..ad49fb4c414c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -143,13 +143,12 @@ public final void givenDeprecatedApi_whenClientUsesCustomUserAgent_thenCorrect() response = client.execute(request); } - @SuppressWarnings("deprecation") @Test public final void givenDeprecatedApi_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { - final DefaultHttpClient client = new DefaultHttpClient(); + instance = HttpClients.custom().build(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); - response = client.execute(request); + response = instance.execute(request); } @Test From e4df951d1b80d77ff9a8e7a5dd55debafaa3b694 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 22 Dec 2013 20:19:29 +0200 Subject: [PATCH 362/796] new cookie tests --- .../httpclient/HttpClientCookieLiveTest.java | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java new file mode 100644 index 000000000000..1ed91bebc401 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java @@ -0,0 +1,115 @@ +package org.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.cookie.BasicClientCookie; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientCookieLiveTest { + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + @Test + public final void whenSettingCookiesOnARequest_thenCorrect() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().build(); + final HttpGet request = new HttpGet("http://www.github.com"); + request.setHeader("Cookie", "JSESSIONID=1234"); + + response = instance.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @SuppressWarnings("deprecation") + @Test + public final void givenUsingDeprecatedApi_whenSettingCookiesOnTheHttpClient_thenCorrect() throws ClientProtocolException, IOException { + final BasicCookieStore cookieStore = new BasicCookieStore(); + final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); + cookie.setDomain(".github.com"); + cookieStore.addCookie(cookie); + final DefaultHttpClient client = new DefaultHttpClient(); + client.setCookieStore(cookieStore); + + final HttpGet request = new HttpGet("http://www.github.com"); + + response = client.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @Test + public final void whenSettingCookiesOnTheHttpClient_thenCookieSentCorrectly() throws ClientProtocolException, IOException { + final BasicCookieStore cookieStore = new BasicCookieStore(); + final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); + cookie.setDomain(".github.com"); + cookieStore.addCookie(cookie); + instance = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build(); + + final HttpGet request = new HttpGet("http://www.github.com"); + + response = instance.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + + @Test + public final void whenSettingCookiesOnTheRequest_thenCookieSentCorrectly() throws ClientProtocolException, IOException { + final BasicCookieStore cookieStore = new BasicCookieStore(); + final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); + cookie.setDomain(".github.com"); + cookieStore.addCookie(cookie); + instance = HttpClientBuilder.create().build(); + + final HttpGet request = new HttpGet("http://www.github.com"); + + final HttpContext localContext = new BasicHttpContext(); + localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore); + response = instance.execute(request, localContext); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + +} From c4b0cfcb43560641aefd52b3f412d356ed3cdc46 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 23 Dec 2013 15:24:05 +0200 Subject: [PATCH 363/796] further jackson work - ignroing new fields, and some httpclient cookie work --- .../httpclient/HttpClientCookieLiveTest.java | 4 + .../httpclient/HttpClientLiveTest.java | 26 +++++++ .../jackson/ignore/MyDtoIgnoreNull.java | 51 +++++++++++++ ...ksonCollectionDeserializationUnitTest.java | 75 +++++++++++++++++++ .../test/JacksonSerializationUnitTest.java | 30 ++++++++ 5 files changed, 186 insertions(+) create mode 100644 jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java index 1ed91bebc401..3cca95b7bc45 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java @@ -69,6 +69,7 @@ public final void givenUsingDeprecatedApi_whenSettingCookiesOnTheHttpClient_then final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); + cookie.setPath("/"); cookieStore.addCookie(cookie); final DefaultHttpClient client = new DefaultHttpClient(); client.setCookieStore(cookieStore); @@ -85,6 +86,7 @@ public final void whenSettingCookiesOnTheHttpClient_thenCookieSentCorrectly() th final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); + cookie.setPath("/"); cookieStore.addCookie(cookie); instance = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build(); @@ -100,6 +102,7 @@ public final void whenSettingCookiesOnTheRequest_thenCookieSentCorrectly() throw final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); + cookie.setPath("/"); cookieStore.addCookie(cookie); instance = HttpClientBuilder.create().build(); @@ -107,6 +110,7 @@ public final void whenSettingCookiesOnTheRequest_thenCookieSentCorrectly() throw final HttpContext localContext = new BasicHttpContext(); localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore); + // localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); // before 4.3 response = instance.execute(request, localContext); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index ad49fb4c414c..3356ba92c3e5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -157,4 +157,30 @@ public final void whenRequestHasCustomUserAgent_thenCorrect() throws ClientProto response = instance.execute(new HttpGet(SAMPLE_URL)); } + // tests - cancel request + + @Test + public final void whenRequestIsCanceled_thenCorrect() throws ClientProtocolException, IOException { + instance = HttpClients.custom().build(); + final HttpGet request = new HttpGet(SAMPLE_URL); + response = instance.execute(request); + + try { + final HttpEntity entity = response.getEntity(); + + System.out.println("----------------------------------------"); + System.out.println(response.getStatusLine()); + if (entity != null) { + System.out.println("Response content length: " + entity.getContentLength()); + } + System.out.println("----------------------------------------"); + + // Do not feel like reading the response body + // Call abort on the request object + request.abort(); + } finally { + response.close(); + } + } + } diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java new file mode 100644 index 000000000000..db041cde104c --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java @@ -0,0 +1,51 @@ +package org.baeldung.jackson.ignore; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(Include.NON_NULL) +public class MyDtoIgnoreNull { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoIgnoreNull() { + super(); + } + + public MyDtoIgnoreNull(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java new file mode 100644 index 000000000000..f3063e9ebfeb --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java @@ -0,0 +1,75 @@ +package org.baeldung.jackson.test; + +import static org.hamcrest.Matchers.instanceOf; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; + +import org.baeldung.jackson.ignore.MyDto; +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.CollectionType; +import com.google.common.collect.Lists; + +public class JacksonCollectionDeserializationUnitTest { + + // tests - json to multiple entity + + @Test + public final void givenJsonArray_whenDeserializingAsArray_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + final String jsonArray = mapper.writeValueAsString(listOfDtos); + // [{"stringValue":"a","intValue":1,"booleanValue":true},{"stringValue":"bc","intValue":3,"booleanValue":false}] + + final MyDto[] asArray = mapper.readValue(jsonArray, MyDto[].class); + assertThat(asArray[0], instanceOf(MyDto.class)); + } + + @Test + public final void givenJsonArray_whenDeserializingAsListWithNoTypeInfo_thenNotCorrect() throws JsonParseException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + final String jsonArray = mapper.writeValueAsString(listOfDtos); + // [{"stringValue":"a","intValue":1,"booleanValue":true},{"stringValue":"bc","intValue":3,"booleanValue":false}] + + final List asList = mapper.readValue(jsonArray, List.class); + assertThat((Object) asList.get(0), instanceOf(LinkedHashMap.class)); + } + + @Test + public final void givenJsonArray_whenDeserializingAsListWithTypeReferenceHelp_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + final String jsonArray = mapper.writeValueAsString(listOfDtos); + // [{"stringValue":"a","intValue":1,"booleanValue":true},{"stringValue":"bc","intValue":3,"booleanValue":false}] + + final List asList = mapper.readValue(jsonArray, new TypeReference>() { + }); + assertThat(asList.get(0), instanceOf(MyDto.class)); + } + + @Test + public final void givenJsonArray_whenDeserializingAsListWithJavaTypeHelp_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + final String jsonArray = mapper.writeValueAsString(listOfDtos); + // [{"stringValue":"a","intValue":1,"booleanValue":true},{"stringValue":"bc","intValue":3,"booleanValue":false}] + + final CollectionType javaType = mapper.getTypeFactory().constructCollectionType(List.class, MyDto.class); + final List asList = mapper.readValue(jsonArray, javaType); + assertThat(asList.get(0), instanceOf(MyDto.class)); + } + +} +// a (private) no-args constructor is required (simulate without) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 04f1cf066b59..8b26aee90515 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -11,13 +11,16 @@ import org.baeldung.jackson.ignore.MyDtoFieldNameChanged; import org.baeldung.jackson.ignore.MyDtoIgnoreField; import org.baeldung.jackson.ignore.MyDtoIgnoreFieldByName; +import org.baeldung.jackson.ignore.MyDtoIgnoreNull; import org.baeldung.jackson.ignore.MyDtoIncludeNonDefault; import org.baeldung.jackson.ignore.MyDtoWithFilter; import org.baeldung.jackson.ignore.MyMixInForString; import org.junit.Test; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; @@ -169,6 +172,33 @@ protected final boolean include(final PropertyWriter writer) { System.out.println(dtoAsString); } + @Test + public final void givenIgnoringNullFieldsOnClass_whenSerializingObjectWithNullField_thenFieldIsIgnroed() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenIgnoringNullFieldsGlobally_whenSerializingObjectWithNullField_thenFieldIsIgnroed() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + final MyDto dtoObject = new MyDto(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + // tests - multiple entities to json @Test From 666f17e02c829336a95cfe807c033889a4b445fb Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 23 Dec 2013 15:43:05 +0200 Subject: [PATCH 364/796] jackson examples --- .../org/baeldung/jackson/test/JacksonSerializationUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 8b26aee90515..f144be5e6ad2 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -173,7 +173,7 @@ protected final boolean include(final PropertyWriter writer) { } @Test - public final void givenIgnoringNullFieldsOnClass_whenSerializingObjectWithNullField_thenFieldIsIgnroed() throws JsonProcessingException { + public final void givenIgnoringNullFieldsOnClass_whenSerializingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull(); From 8118dd3c65b1f5140501ed92e18c4bdb3f513dea Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 00:19:43 +0200 Subject: [PATCH 365/796] jackson work --- .../jackson/ignore => dtos}/MyDto.java | 2 +- .../MyDtoFieldNameChanged.java | 2 +- .../ignore => dtos}/MyDtoIgnoreField.java | 2 +- .../MyDtoIgnoreFieldByName.java | 2 +- .../ignore => dtos}/MyDtoIgnoreNull.java | 2 +- .../ignore => dtos}/MyDtoIgnoreType.java | 2 +- .../ignore => dtos}/MyDtoIgnoreUnkown.java | 2 +- .../MyDtoIncludeNonDefault.java | 2 +- .../src/test/java/dtos/MyDtoNoAccessors.java | 21 +++++++++ .../ignore => dtos}/MyDtoWithFilter.java | 2 +- .../ignore => dtos}/MyMixInForString.java | 2 +- ...ksonCollectionDeserializationUnitTest.java | 3 +- .../test/JacksonDeserializationUnitTest.java | 47 +++++++++++++++++-- .../test/JacksonSerializationUnitTest.java | 21 +++++---- 14 files changed, 87 insertions(+), 25 deletions(-) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDto.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoFieldNameChanged.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIgnoreField.java (95%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIgnoreFieldByName.java (95%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIgnoreNull.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIgnoreType.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIgnoreUnkown.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoIncludeNonDefault.java (95%) create mode 100644 jackson/src/test/java/dtos/MyDtoNoAccessors.java rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyDtoWithFilter.java (96%) rename jackson/src/test/java/{org/baeldung/jackson/ignore => dtos}/MyMixInForString.java (75%) diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java b/jackson/src/test/java/dtos/MyDto.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java rename to jackson/src/test/java/dtos/MyDto.java index 32fcfd4ba639..bf140f93d82f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDto.java +++ b/jackson/src/test/java/dtos/MyDto.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; public class MyDto { diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java b/jackson/src/test/java/dtos/MyDtoFieldNameChanged.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java rename to jackson/src/test/java/dtos/MyDtoFieldNameChanged.java index 5b98547ae340..f9537e5ad0b9 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoFieldNameChanged.java +++ b/jackson/src/test/java/dtos/MyDtoFieldNameChanged.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java b/jackson/src/test/java/dtos/MyDtoIgnoreField.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java rename to jackson/src/test/java/dtos/MyDtoIgnoreField.java index bdbc694207ac..34cccc630c0c 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreField.java +++ b/jackson/src/test/java/dtos/MyDtoIgnoreField.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java b/jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java rename to jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java index 0b4378db7581..affb9330d16e 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreFieldByName.java +++ b/jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java b/jackson/src/test/java/dtos/MyDtoIgnoreNull.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java rename to jackson/src/test/java/dtos/MyDtoIgnoreNull.java index db041cde104c..33ec5877116d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreNull.java +++ b/jackson/src/test/java/dtos/MyDtoIgnoreNull.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java b/jackson/src/test/java/dtos/MyDtoIgnoreType.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java rename to jackson/src/test/java/dtos/MyDtoIgnoreType.java index a159015f08cc..08ca86766acf 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreType.java +++ b/jackson/src/test/java/dtos/MyDtoIgnoreType.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java b/jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java rename to jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java index 5f0de0c7fe34..d1f9960c8335 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIgnoreUnkown.java +++ b/jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java b/jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java rename to jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java index 6d1b76a39dff..1d5494389433 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoIncludeNonDefault.java +++ b/jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/dtos/MyDtoNoAccessors.java b/jackson/src/test/java/dtos/MyDtoNoAccessors.java new file mode 100644 index 000000000000..3988f714b256 --- /dev/null +++ b/jackson/src/test/java/dtos/MyDtoNoAccessors.java @@ -0,0 +1,21 @@ +package dtos; + +public class MyDtoNoAccessors { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDtoNoAccessors() { + super(); + } + + public MyDtoNoAccessors(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java b/jackson/src/test/java/dtos/MyDtoWithFilter.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java rename to jackson/src/test/java/dtos/MyDtoWithFilter.java index 2492cb82cbc1..fe40c86728b4 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyDtoWithFilter.java +++ b/jackson/src/test/java/dtos/MyDtoWithFilter.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonFilter; diff --git a/jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java b/jackson/src/test/java/dtos/MyMixInForString.java similarity index 75% rename from jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java rename to jackson/src/test/java/dtos/MyMixInForString.java index 1439cca793fe..0c93b44d794b 100644 --- a/jackson/src/test/java/org/baeldung/jackson/ignore/MyMixInForString.java +++ b/jackson/src/test/java/dtos/MyMixInForString.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.ignore; +package dtos; import com.fasterxml.jackson.annotation.JsonIgnoreType; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java index f3063e9ebfeb..6a0c846696e7 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java @@ -7,7 +7,6 @@ import java.util.LinkedHashMap; import java.util.List; -import org.baeldung.jackson.ignore.MyDto; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; @@ -17,6 +16,8 @@ import com.fasterxml.jackson.databind.type.CollectionType; import com.google.common.collect.Lists; +import dtos.MyDto; + public class JacksonCollectionDeserializationUnitTest { // tests - json to multiple entity diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 2965b732c216..44de65e09e4d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -6,19 +6,21 @@ import java.io.IOException; -import org.baeldung.jackson.ignore.MyDto; -import org.baeldung.jackson.ignore.MyDtoIgnoreUnkown; import org.junit.Test; +import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -public class JacksonDeserializationUnitTest { +import dtos.MyDto; +import dtos.MyDtoIgnoreUnkown; - // tests - json to single entity +public class JacksonDeserializationUnitTest { @Test public final void whenDeserializingAJsonToAClass_thenCorrect() throws JsonParseException, JsonMappingException, IOException { @@ -43,6 +45,8 @@ public final void givenNotAllFieldsHaveValuesInJson_whenDeserializingAJsonToACla assertThat(readValue.isBooleanValue(), equalTo(true)); } + // tests - json with unknown fields + @Test(expected = UnrecognizedPropertyException.class) public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenExceptionIsThrown() throws JsonParseException, JsonMappingException, IOException { final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; @@ -91,4 +95,39 @@ public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenD assertThat(readValue.getIntValue(), equalTo(1)); } + // to JsonNode + + @Test + public final void whenParsingJsonStringIntoJsonNode_thenCorrect() throws JsonParseException, IOException { + final String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\"}"; + + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode actualObj = mapper.readTree(jsonString); + + assertNotNull(actualObj); + } + + @Test + public final void givenUsingLowLevelDetails_whenParsingJsonStringIntoJsonNode_thenCorrect() throws JsonParseException, IOException { + final String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\"}"; + + final ObjectMapper mapper = new ObjectMapper(); + final JsonFactory factory = mapper.getFactory(); + final JsonParser parser = factory.createParser(jsonString); + final JsonNode actualObj = mapper.readTree(parser); + + assertNotNull(actualObj); + } + + @Test + public final void givenTheJsonNode_whenRetrievingDataFromId_thenCorrect() throws JsonParseException, IOException { + final String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\"}"; + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode actualObj = mapper.readTree(jsonString); + + // When + final JsonNode jsonNode1 = actualObj.get("k1"); + assertThat(jsonNode1.textValue(), equalTo("v1")); + } + } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index f144be5e6ad2..177ef19afe68 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -7,14 +7,6 @@ import java.io.IOException; import java.util.List; -import org.baeldung.jackson.ignore.MyDto; -import org.baeldung.jackson.ignore.MyDtoFieldNameChanged; -import org.baeldung.jackson.ignore.MyDtoIgnoreField; -import org.baeldung.jackson.ignore.MyDtoIgnoreFieldByName; -import org.baeldung.jackson.ignore.MyDtoIgnoreNull; -import org.baeldung.jackson.ignore.MyDtoIncludeNonDefault; -import org.baeldung.jackson.ignore.MyDtoWithFilter; -import org.baeldung.jackson.ignore.MyMixInForString; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -31,6 +23,15 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import com.google.common.collect.Lists; +import dtos.MyDto; +import dtos.MyDtoFieldNameChanged; +import dtos.MyDtoIgnoreField; +import dtos.MyDtoIgnoreFieldByName; +import dtos.MyDtoIgnoreNull; +import dtos.MyDtoIncludeNonDefault; +import dtos.MyDtoWithFilter; +import dtos.MyMixInForString; + public class JacksonSerializationUnitTest { // tests - single entity to json @@ -173,7 +174,7 @@ protected final boolean include(final PropertyWriter writer) { } @Test - public final void givenIgnoringNullFieldsOnClass_whenSerializingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException { + public final void givenIgnoringNullFieldsOnClass_whenWritingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull(); @@ -186,7 +187,7 @@ public final void givenIgnoringNullFieldsOnClass_whenSerializingObjectWithNullFi } @Test - public final void givenIgnoringNullFieldsGlobally_whenSerializingObjectWithNullField_thenFieldIsIgnroed() throws JsonProcessingException { + public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); final MyDto dtoObject = new MyDto(); From aa0030d546860eedc3d540a9f00c101eefc7e90b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 01:38:09 +0200 Subject: [PATCH 366/796] mapping work --- .../src/test/java/dtos/MyDtoNoAccessors.java | 6 +- .../MyDtoNoAccessorsAndFieldVisibility.java | 25 +++ .../JacksonSerializationIgnoreUnitTest.java | 187 ++++++++++++++++++ .../test/JacksonSerializationUnitTest.java | 167 +++------------- 4 files changed, 237 insertions(+), 148 deletions(-) create mode 100644 jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java diff --git a/jackson/src/test/java/dtos/MyDtoNoAccessors.java b/jackson/src/test/java/dtos/MyDtoNoAccessors.java index 3988f714b256..4b3b9799b3b2 100644 --- a/jackson/src/test/java/dtos/MyDtoNoAccessors.java +++ b/jackson/src/test/java/dtos/MyDtoNoAccessors.java @@ -2,9 +2,9 @@ public class MyDtoNoAccessors { - private String stringValue; - private int intValue; - private boolean booleanValue; + String stringValue; + int intValue; + boolean booleanValue; public MyDtoNoAccessors() { super(); diff --git a/jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java b/jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java new file mode 100644 index 000000000000..74fdbae58f3d --- /dev/null +++ b/jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java @@ -0,0 +1,25 @@ +package dtos; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; + +@JsonAutoDetect(fieldVisibility = Visibility.ANY) +public class MyDtoNoAccessorsAndFieldVisibility { + + String stringValue; + int intValue; + boolean booleanValue; + + public MyDtoNoAccessorsAndFieldVisibility() { + super(); + } + + public MyDtoNoAccessorsAndFieldVisibility(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java new file mode 100644 index 000000000000..ec692f5bcd8a --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -0,0 +1,187 @@ +package org.baeldung.jackson.test; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.io.IOException; + +import org.junit.Test; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; +import com.fasterxml.jackson.databind.ser.FilterProvider; +import com.fasterxml.jackson.databind.ser.PropertyFilter; +import com.fasterxml.jackson.databind.ser.PropertyWriter; +import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; +import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; + +import dtos.MyDto; +import dtos.MyDtoIgnoreField; +import dtos.MyDtoIgnoreFieldByName; +import dtos.MyDtoIgnoreNull; +import dtos.MyDtoIncludeNonDefault; +import dtos.MyDtoWithFilter; +import dtos.MyMixInForString; + +public class JacksonSerializationIgnoreUnitTest { + + // tests - single entity to json + + // ignore + + @Test + public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasOnlyDefaultValues_whenSerializing_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoIncludeNonDefault()); + + assertThat(dtoAsString, not(containsString("intValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasNonDefaultValue_whenSerializing_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIncludeNonDefault dtoObject = new MyDtoIncludeNonDefault(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenFieldIsIgnoredByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIgnoreFieldByName dtoObject = new MyDtoIgnoreFieldByName(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenFieldIsIgnoredDirectly_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIgnoreField dtoObject = new MyDtoIgnoreField(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.addMixInAnnotations(String.class, MyMixInForString.class); + final MyDto dtoObject = new MyDto(); + dtoObject.setBooleanValue(true); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("intValue"); + final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); + + final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); + dtoObject.setIntValue(12); + + final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, containsString("stringValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenTypeHasFilterThatIgnoresNegativeInt_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final PropertyFilter theFilter = new SimpleBeanPropertyFilter() { + @Override + public final void serializeAsField(final Object pojo, final JsonGenerator jgen, final SerializerProvider provider, final PropertyWriter writer) throws Exception { + if (include(writer)) { + if (!writer.getName().equals("intValue")) { + writer.serializeAsField(pojo, jgen, provider); + return; + } + + final int intValue = ((MyDtoWithFilter) pojo).getIntValue(); + if (intValue >= 0) { + writer.serializeAsField(pojo, jgen, provider); + } + } else if (!jgen.canOmitFields()) { // since 2.3 + writer.serializeAsOmittedField(pojo, jgen, provider); + } + } + + @Override + protected final boolean include(final BeanPropertyWriter writer) { + return true; + } + + @Override + protected final boolean include(final PropertyWriter writer) { + return true; + } + }; + final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); + + final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); + dtoObject.setIntValue(-1); + + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); + + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, containsString("stringValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenIgnoringNullFieldsOnClass_whenWritingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + final MyDto dtoObject = new MyDto(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("booleanValue")); + assertThat(dtoAsString, not(containsString("stringValue"))); + System.out.println(dtoAsString); + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 177ef19afe68..3ead8184266f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; import java.io.IOException; @@ -9,52 +10,30 @@ import org.junit.Test; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; -import com.fasterxml.jackson.databind.ser.FilterProvider; -import com.fasterxml.jackson.databind.ser.PropertyFilter; -import com.fasterxml.jackson.databind.ser.PropertyWriter; -import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; -import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import com.google.common.collect.Lists; import dtos.MyDto; import dtos.MyDtoFieldNameChanged; -import dtos.MyDtoIgnoreField; -import dtos.MyDtoIgnoreFieldByName; -import dtos.MyDtoIgnoreNull; -import dtos.MyDtoIncludeNonDefault; -import dtos.MyDtoWithFilter; -import dtos.MyMixInForString; +import dtos.MyDtoNoAccessors; +import dtos.MyDtoNoAccessorsAndFieldVisibility; public class JacksonSerializationUnitTest { // tests - single entity to json @Test - public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasOnlyDefaultValues_whenSerializing_thenCorrect() throws JsonParseException, IOException { + public final void whenSerializing_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoIncludeNonDefault()); - - assertThat(dtoAsString, not(containsString("intValue"))); - System.out.println(dtoAsString); - } - - @Test - public final void givenOnlyNonDefaultValuesAreSerializedAndDtoHasNonDefaultValue_whenSerializing_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final MyDtoIncludeNonDefault dtoObject = new MyDtoIncludeNonDefault(); - dtoObject.setBooleanValue(true); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); + final String dtoAsString = mapper.writeValueAsString(new MyDto()); + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, containsString("booleanValue")); - System.out.println(dtoAsString); } @Test @@ -70,134 +49,32 @@ public final void givenNameOfFieldIsChanged_whenSerializing_thenCorrect() throws System.out.println(dtoAsString); } - // ignore - - @Test - public final void givenFieldIsIgnoredByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final MyDtoIgnoreFieldByName dtoObject = new MyDtoIgnoreFieldByName(); - dtoObject.setBooleanValue(true); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); - - assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); - System.out.println(dtoAsString); - } - - @Test - public final void givenFieldIsIgnoredDirectly_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final MyDtoIgnoreField dtoObject = new MyDtoIgnoreField(); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); + @Test(expected = JsonMappingException.class) + public final void givenObjectHasNoAccessors_whenSerializing_thenException() throws JsonParseException, IOException { + final String dtoAsString = new ObjectMapper().writeValueAsString(new MyDtoNoAccessors()); - assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); - System.out.println(dtoAsString); + assertThat(dtoAsString, notNullValue()); } @Test - public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - mapper.addMixInAnnotations(String.class, MyMixInForString.class); - final MyDto dtoObject = new MyDto(); - dtoObject.setBooleanValue(true); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); + public final void givenObjectHasNoAccessors_whenSerializingWithPrivateFieldsVisibility_thenNoException() throws JsonParseException, IOException { + final ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); + final String dtoAsString = objectMapper.writeValueAsString(new MyDtoNoAccessors()); assertThat(dtoAsString, containsString("intValue")); - assertThat(dtoAsString, containsString("booleanValue")); - assertThat(dtoAsString, not(containsString("stringValue"))); - System.out.println(dtoAsString); - } - - @Test - public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("intValue"); - final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); - - final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); - dtoObject.setIntValue(12); - - final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); - - assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); assertThat(dtoAsString, containsString("stringValue")); - System.out.println(dtoAsString); - } - - @Test - public final void givenTypeHasFilterThatIgnoresNegativeInt_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final PropertyFilter theFilter = new SimpleBeanPropertyFilter() { - @Override - public final void serializeAsField(final Object pojo, final JsonGenerator jgen, final SerializerProvider provider, final PropertyWriter writer) throws Exception { - if (include(writer)) { - if (!writer.getName().equals("intValue")) { - writer.serializeAsField(pojo, jgen, provider); - return; - } - - final int intValue = ((MyDtoWithFilter) pojo).getIntValue(); - if (intValue >= 0) { - writer.serializeAsField(pojo, jgen, provider); - } - } else if (!jgen.canOmitFields()) { // since 2.3 - writer.serializeAsOmittedField(pojo, jgen, provider); - } - } - - @Override - protected final boolean include(final BeanPropertyWriter writer) { - return true; - } - - @Override - protected final boolean include(final PropertyWriter writer) { - return true; - } - }; - final FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter); - - final MyDtoWithFilter dtoObject = new MyDtoWithFilter(); - dtoObject.setIntValue(-1); - - final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writer(filters).writeValueAsString(dtoObject); - - assertThat(dtoAsString, not(containsString("intValue"))); assertThat(dtoAsString, containsString("booleanValue")); - assertThat(dtoAsString, containsString("stringValue")); - System.out.println(dtoAsString); } @Test - public final void givenIgnoringNullFieldsOnClass_whenWritingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull(); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); - - assertThat(dtoAsString, containsString("intValue")); - assertThat(dtoAsString, containsString("booleanValue")); - assertThat(dtoAsString, not(containsString("stringValue"))); - System.out.println(dtoAsString); - } - - @Test - public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - final MyDto dtoObject = new MyDto(); - - final String dtoAsString = mapper.writeValueAsString(dtoObject); + public final void givenObjectHasNoAccessorsButHasVisibleFields_whenSerializing_thenNoException() throws JsonParseException, IOException { + final ObjectMapper objectMapper = new ObjectMapper(); + final String dtoAsString = objectMapper.writeValueAsString(new MyDtoNoAccessorsAndFieldVisibility()); assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, containsString("booleanValue")); - assertThat(dtoAsString, not(containsString("stringValue"))); - System.out.println(dtoAsString); } // tests - multiple entities to json From d9b9c30aa210db763f8f86ccfd917aba8188df1a Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 15:11:18 +0200 Subject: [PATCH 367/796] general cleanup and initial new project --- core-java/.classpath | 36 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + core-java/.gitignore | 13 ++ core-java/.project | 36 +++++ core-java/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++++++ core-java/.settings/org.eclipse.jdt.ui.prefs | 55 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + core-java/.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + core-java/.springBeans | 14 ++ core-java/README.md | 6 + core-java/pom.xml | 139 ++++++++++++++++++ core-java/src/main/resources/logback.xml | 16 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + core-java/src/main/webapp/WEB-INF/web.xml | 42 ++++++ .../org/baeldung/java/CoreJavaUnitTest.java | 7 + core-java/src/test/resources/.gitignore | 13 ++ .../baeldung/jackson}/dtos/MyDto.java | 2 +- .../jackson}/dtos/MyDtoFieldNameChanged.java | 2 +- .../jackson}/dtos/MyDtoIgnoreField.java | 2 +- .../jackson}/dtos/MyDtoIgnoreFieldByName.java | 2 +- .../jackson}/dtos/MyDtoIgnoreNull.java | 2 +- .../jackson}/dtos/MyDtoIgnoreType.java | 2 +- .../jackson}/dtos/MyDtoIgnoreUnkown.java | 2 +- .../jackson}/dtos/MyDtoIncludeNonDefault.java | 2 +- .../jackson}/dtos/MyDtoNoAccessors.java | 2 +- .../MyDtoNoAccessorsAndFieldVisibility.java | 2 +- .../jackson}/dtos/MyDtoWithFilter.java | 2 +- .../jackson}/dtos/MyMixInForString.java | 2 +- ...ksonCollectionDeserializationUnitTest.java | 2 +- .../test/JacksonDeserializationUnitTest.java | 4 +- .../JacksonSerializationIgnoreUnitTest.java | 14 +- .../test/JacksonSerializationUnitTest.java | 8 +- 39 files changed, 552 insertions(+), 26 deletions(-) create mode 100644 core-java/.classpath create mode 100644 core-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 core-java/.gitignore create mode 100644 core-java/.project create mode 100644 core-java/.settings/.jsdtscope create mode 100644 core-java/.settings/org.eclipse.jdt.core.prefs create mode 100644 core-java/.settings/org.eclipse.jdt.ui.prefs create mode 100644 core-java/.settings/org.eclipse.m2e.core.prefs create mode 100644 core-java/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 core-java/.settings/org.eclipse.wst.common.component create mode 100644 core-java/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 core-java/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 core-java/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 core-java/.settings/org.eclipse.wst.validation.prefs create mode 100644 core-java/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 core-java/.springBeans create mode 100644 core-java/README.md create mode 100644 core-java/pom.xml create mode 100644 core-java/src/main/resources/logback.xml create mode 100644 core-java/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 core-java/src/main/webapp/WEB-INF/web.xml create mode 100644 core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java create mode 100644 core-java/src/test/resources/.gitignore rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDto.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoFieldNameChanged.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIgnoreField.java (95%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIgnoreFieldByName.java (95%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIgnoreNull.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIgnoreType.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIgnoreUnkown.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoIncludeNonDefault.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoNoAccessors.java (92%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoNoAccessorsAndFieldVisibility.java (94%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyDtoWithFilter.java (96%) rename jackson/src/test/java/{ => org/baeldung/jackson}/dtos/MyMixInForString.java (76%) diff --git a/core-java/.classpath b/core-java/.classpath new file mode 100644 index 000000000000..0720e4851bd7 --- /dev/null +++ b/core-java/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/core-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/core-java/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/core-java/.gitignore b/core-java/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/core-java/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/core-java/.project b/core-java/.project new file mode 100644 index 000000000000..12bfa7d869b5 --- /dev/null +++ b/core-java/.project @@ -0,0 +1,36 @@ + + + core-java + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/core-java/.settings/.jsdtscope b/core-java/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/core-java/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/core-java/.settings/org.eclipse.jdt.core.prefs b/core-java/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/core-java/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/core-java/.settings/org.eclipse.jdt.ui.prefs b/core-java/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/core-java/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/core-java/.settings/org.eclipse.m2e.core.prefs b/core-java/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/core-java/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/core-java/.settings/org.eclipse.m2e.wtp.prefs b/core-java/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/core-java/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/core-java/.settings/org.eclipse.wst.common.component b/core-java/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/core-java/.settings/org.eclipse.wst.common.project.facet.core.xml b/core-java/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.container b/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.name b/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/core-java/.settings/org.eclipse.wst.validation.prefs b/core-java/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/core-java/.settings/org.eclipse.wst.ws.service.policy.prefs b/core-java/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/core-java/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/core-java/.springBeans b/core-java/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/core-java/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/core-java/README.md b/core-java/README.md new file mode 100644 index 000000000000..a78f99a41669 --- /dev/null +++ b/core-java/README.md @@ -0,0 +1,6 @@ +========= + +## Core Java Cookbooks and Examples + +### Relevant Articles: +// - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) diff --git a/core-java/pom.xml b/core-java/pom.xml new file mode 100644 index 000000000000..348e1b8ef224 --- /dev/null +++ b/core-java/pom.xml @@ -0,0 +1,139 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + jackson + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 2.3.0 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + + + \ No newline at end of file diff --git a/core-java/src/main/resources/logback.xml b/core-java/src/main/resources/logback.xml new file mode 100644 index 000000000000..62d0ea5037b2 --- /dev/null +++ b/core-java/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/src/main/webapp/WEB-INF/api-servlet.xml b/core-java/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/core-java/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/core-java/src/main/webapp/WEB-INF/web.xml b/core-java/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/core-java/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java new file mode 100644 index 000000000000..89e8554cd317 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java @@ -0,0 +1,7 @@ +package org.baeldung.java; + +public class CoreJavaUnitTest { + + // tests - + +} diff --git a/core-java/src/test/resources/.gitignore b/core-java/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/core-java/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/jackson/src/test/java/dtos/MyDto.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDto.java similarity index 96% rename from jackson/src/test/java/dtos/MyDto.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDto.java index bf140f93d82f..d9bfe6f8f6ad 100644 --- a/jackson/src/test/java/dtos/MyDto.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDto.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; public class MyDto { diff --git a/jackson/src/test/java/dtos/MyDtoFieldNameChanged.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoFieldNameChanged.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoFieldNameChanged.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoFieldNameChanged.java index f9537e5ad0b9..9c4086a965a9 100644 --- a/jackson/src/test/java/dtos/MyDtoFieldNameChanged.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoFieldNameChanged.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/jackson/src/test/java/dtos/MyDtoIgnoreField.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java similarity index 95% rename from jackson/src/test/java/dtos/MyDtoIgnoreField.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java index 34cccc630c0c..78d493ae60d3 100644 --- a/jackson/src/test/java/dtos/MyDtoIgnoreField.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java similarity index 95% rename from jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java index affb9330d16e..7902214571d9 100644 --- a/jackson/src/test/java/dtos/MyDtoIgnoreFieldByName.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/dtos/MyDtoIgnoreNull.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoIgnoreNull.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java index 33ec5877116d..239df1318701 100644 --- a/jackson/src/test/java/dtos/MyDtoIgnoreNull.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/dtos/MyDtoIgnoreType.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoIgnoreType.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java index 08ca86766acf..fc77ec6d02c9 100644 --- a/jackson/src/test/java/dtos/MyDtoIgnoreType.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java index d1f9960c8335..57ae6e86ba52 100644 --- a/jackson/src/test/java/dtos/MyDtoIgnoreUnkown.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java index 1d5494389433..b99d793363a1 100644 --- a/jackson/src/test/java/dtos/MyDtoIncludeNonDefault.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/dtos/MyDtoNoAccessors.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessors.java similarity index 92% rename from jackson/src/test/java/dtos/MyDtoNoAccessors.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessors.java index 4b3b9799b3b2..6e88f5a2db82 100644 --- a/jackson/src/test/java/dtos/MyDtoNoAccessors.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessors.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; public class MyDtoNoAccessors { diff --git a/jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java similarity index 94% rename from jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java index 74fdbae58f3d..1723a71230f5 100644 --- a/jackson/src/test/java/dtos/MyDtoNoAccessorsAndFieldVisibility.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; diff --git a/jackson/src/test/java/dtos/MyDtoWithFilter.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithFilter.java similarity index 96% rename from jackson/src/test/java/dtos/MyDtoWithFilter.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithFilter.java index fe40c86728b4..03d7edf9851d 100644 --- a/jackson/src/test/java/dtos/MyDtoWithFilter.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithFilter.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonFilter; diff --git a/jackson/src/test/java/dtos/MyMixInForString.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyMixInForString.java similarity index 76% rename from jackson/src/test/java/dtos/MyMixInForString.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyMixInForString.java index 0c93b44d794b..3d5228139e94 100644 --- a/jackson/src/test/java/dtos/MyMixInForString.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyMixInForString.java @@ -1,4 +1,4 @@ -package dtos; +package org.baeldung.jackson.dtos; import com.fasterxml.jackson.annotation.JsonIgnoreType; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java index 6a0c846696e7..e2b3b35d72db 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java @@ -7,6 +7,7 @@ import java.util.LinkedHashMap; import java.util.List; +import org.baeldung.jackson.dtos.MyDto; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; @@ -16,7 +17,6 @@ import com.fasterxml.jackson.databind.type.CollectionType; import com.google.common.collect.Lists; -import dtos.MyDto; public class JacksonCollectionDeserializationUnitTest { diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 44de65e09e4d..858c83acbe9a 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -6,6 +6,8 @@ import java.io.IOException; +import org.baeldung.jackson.dtos.MyDto; +import org.baeldung.jackson.dtos.MyDtoIgnoreUnkown; import org.junit.Test; import com.fasterxml.jackson.core.JsonFactory; @@ -17,8 +19,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import dtos.MyDto; -import dtos.MyDtoIgnoreUnkown; public class JacksonDeserializationUnitTest { diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java index ec692f5bcd8a..81881fb699b5 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -6,6 +6,13 @@ import java.io.IOException; +import org.baeldung.jackson.dtos.MyDto; +import org.baeldung.jackson.dtos.MyDtoIgnoreField; +import org.baeldung.jackson.dtos.MyDtoIgnoreFieldByName; +import org.baeldung.jackson.dtos.MyDtoIgnoreNull; +import org.baeldung.jackson.dtos.MyDtoIncludeNonDefault; +import org.baeldung.jackson.dtos.MyDtoWithFilter; +import org.baeldung.jackson.dtos.MyMixInForString; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -21,13 +28,6 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import dtos.MyDto; -import dtos.MyDtoIgnoreField; -import dtos.MyDtoIgnoreFieldByName; -import dtos.MyDtoIgnoreNull; -import dtos.MyDtoIncludeNonDefault; -import dtos.MyDtoWithFilter; -import dtos.MyMixInForString; public class JacksonSerializationIgnoreUnitTest { diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 3ead8184266f..2c1b9e78fa07 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -8,6 +8,10 @@ import java.io.IOException; import java.util.List; +import org.baeldung.jackson.dtos.MyDto; +import org.baeldung.jackson.dtos.MyDtoFieldNameChanged; +import org.baeldung.jackson.dtos.MyDtoNoAccessors; +import org.baeldung.jackson.dtos.MyDtoNoAccessorsAndFieldVisibility; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; @@ -17,10 +21,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; -import dtos.MyDto; -import dtos.MyDtoFieldNameChanged; -import dtos.MyDtoNoAccessors; -import dtos.MyDtoNoAccessorsAndFieldVisibility; public class JacksonSerializationUnitTest { From 22ebf4a21815ecaf867422fe19f812894ba6f642 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 16:46:15 +0200 Subject: [PATCH 368/796] collections work --- core-java/pom.xml | 6 +-- .../org/baeldung/java/CoreJavaUnitTest.java | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 348e1b8ef224..ff5f8b40dfc1 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -64,7 +64,7 @@ - jackson + core-java src/main/resources @@ -102,10 +102,10 @@ 4.3.0.Final 5.1.27 - + 2.3.0 - + 1.7.5 1.0.11 diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java index 89e8554cd317..b2aff87aae42 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java @@ -1,7 +1,45 @@ package org.baeldung.java; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; + +import com.google.common.collect.ImmutableList; + public class CoreJavaUnitTest { // tests - + @Test + public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List synchronizedList = Collections.synchronizedList(list); + System.out.println("Synchronized List is: " + synchronizedList); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingTheJdk_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = Collections.unmodifiableList(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ImmutableList.copyOf(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ListUtils.unmodifiableList(list); + unmodifiableList.add("four"); + } + } From 62fd8f897806c02a6593fe0b1598f852849e1a0f Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 16:59:03 +0200 Subject: [PATCH 369/796] minor java collections work --- .../src/test/java/org/baeldung/java/CoreJavaUnitTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java index b2aff87aae42..fb6e39f7680b 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java @@ -35,6 +35,13 @@ public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_then unmodifiableList.add("four"); } + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); + unmodifiableList.add("four"); + } + @Test(expected = UnsupportedOperationException.class) public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { final List list = new ArrayList(Arrays.asList("one", "two", "three")); From b76928dcf554d25a49fc9c2dc729b047fb662792 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 18:09:27 +0200 Subject: [PATCH 370/796] cleanup and testing work --- .../httpclient/HttpClientBasicLiveTest.java | 93 +++++++++++++++++++ .../httpclient/HttpClientLiveTest.java | 41 -------- 2 files changed, 93 insertions(+), 41 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java new file mode 100644 index 000000000000..d11af39d34fe --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java @@ -0,0 +1,93 @@ +package org.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientBasicLiveTest { + + private static final String SAMPLE_URL = "http://www.github.com"; + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + // simple request - response + + @Test + public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); + + assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBody() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final String bodyAsString = EntityUtils.toString(response.getEntity()); + + assertThat(bodyAsString, notNullValue()); + } + + // tests - non-GET + + @Test + public final void whenExecutingBasicRequest_thenNoExceptions() throws ClientProtocolException, IOException { + instance.execute(new HttpPost(SAMPLE_URL)); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index 3356ba92c3e5..e2c7a139f550 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -1,9 +1,7 @@ package org.baeldung.httpclient; import static org.hamcrest.Matchers.emptyArray; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; import java.io.IOException; @@ -16,9 +14,7 @@ import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; @@ -26,7 +22,6 @@ import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.apache.http.params.CoreProtocolPNames; import org.apache.http.params.HttpProtocolParams; -import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -63,35 +58,6 @@ public final void after() throws IllegalStateException, IOException { // tests - // simple request - response - - @Test - public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); - - assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBody() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - final String bodyAsString = EntityUtils.toString(response.getEntity()); - - assertThat(bodyAsString, notNullValue()); - } - @Test(expected = ConnectTimeoutException.class) public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws ClientProtocolException, IOException { final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(20).build(); @@ -100,13 +66,6 @@ public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException( response = instance.execute(request); } - // tests - non-GET - - @Test - public final void whenExecutingBasicRequest_thenNoExceptions() throws ClientProtocolException, IOException { - instance.execute(new HttpPost(SAMPLE_URL)); - } - // tests - configs @Test From ee37eb8a31350f755927cfe79dce608f49fd5990 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 18:37:39 +0200 Subject: [PATCH 371/796] enum work --- .../baeldung/jackson/dtos/MyDtoWithEnum.java | 57 +++++++++++++++++++ .../jackson/dtos/MyDtoWithEnumCustom.java | 57 +++++++++++++++++++ .../org/baeldung/jackson/dtos/TypeEnum.java | 35 ++++++++++++ .../dtos/TypeEnumWithCustomSerializer.java | 35 ++++++++++++ .../baeldung/jackson/dtos/TypeSerializer.java | 22 +++++++ .../test/JacksonSerializationUnitTest.java | 43 +++++++++++++- 6 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java new file mode 100644 index 000000000000..015e2863075f --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java @@ -0,0 +1,57 @@ +package org.baeldung.jackson.dtos; + +public class MyDtoWithEnum { + + private String stringValue; + private int intValue; + private boolean booleanValue; + private TypeEnum type; + + public MyDtoWithEnum() { + super(); + } + + public MyDtoWithEnum(final String stringValue, final int intValue, final boolean booleanValue, final TypeEnum type) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + this.type = type; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + + public TypeEnum getType() { + return type; + } + + public void setType(final TypeEnum type) { + this.type = type; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java new file mode 100644 index 000000000000..825dbb257715 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java @@ -0,0 +1,57 @@ +package org.baeldung.jackson.dtos; + +public class MyDtoWithEnumCustom { + + private String stringValue; + private int intValue; + private boolean booleanValue; + private TypeEnumWithCustomSerializer type; + + public MyDtoWithEnumCustom() { + super(); + } + + public MyDtoWithEnumCustom(final String stringValue, final int intValue, final boolean booleanValue, final TypeEnumWithCustomSerializer type) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + this.type = type; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + + public TypeEnumWithCustomSerializer getType() { + return type; + } + + public void setType(final TypeEnumWithCustomSerializer type) { + this.type = type; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java new file mode 100644 index 000000000000..8d2358666aa2 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java @@ -0,0 +1,35 @@ +package org.baeldung.jackson.dtos; + +import com.fasterxml.jackson.annotation.JsonFormat; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum TypeEnum { + TYPE1(1, "Type A"), TYPE2(2, "Type 2"); + + private Integer id; + private String name; + + private TypeEnum(final Integer id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java new file mode 100644 index 000000000000..479c1ba46e14 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java @@ -0,0 +1,35 @@ +package org.baeldung.jackson.dtos; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(using = TypeSerializer.class) +public enum TypeEnumWithCustomSerializer { + TYPE1(1, "Type A"), TYPE2(2, "Type 2"); + + private Integer id; + private String name; + + private TypeEnumWithCustomSerializer(final Integer id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java new file mode 100644 index 000000000000..da1fc4e4a9ab --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java @@ -0,0 +1,22 @@ +package org.baeldung.jackson.dtos; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class TypeSerializer extends JsonSerializer { + + @Override + public void serialize(final TypeEnumWithCustomSerializer value, final JsonGenerator generator, final SerializerProvider provider) throws IOException, JsonProcessingException { + generator.writeStartObject(); + generator.writeFieldName("id"); + generator.writeNumber(value.getId()); + generator.writeFieldName("name"); + generator.writeString(value.getName()); + generator.writeEndObject(); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 2c1b9e78fa07..1a6014c0e7cf 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -12,6 +12,10 @@ import org.baeldung.jackson.dtos.MyDtoFieldNameChanged; import org.baeldung.jackson.dtos.MyDtoNoAccessors; import org.baeldung.jackson.dtos.MyDtoNoAccessorsAndFieldVisibility; +import org.baeldung.jackson.dtos.MyDtoWithEnum; +import org.baeldung.jackson.dtos.MyDtoWithEnumCustom; +import org.baeldung.jackson.dtos.TypeEnum; +import org.baeldung.jackson.dtos.TypeEnumWithCustomSerializer; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; @@ -21,7 +25,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; - public class JacksonSerializationUnitTest { // tests - single entity to json @@ -77,6 +80,44 @@ public final void givenObjectHasNoAccessorsButHasVisibleFields_whenSerializing_t assertThat(dtoAsString, containsString("booleanValue")); } + // tests - enums + + @Test + public final void whenSerializingSimpleEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String json = mapper.writeValueAsString(new TypeEnum[] { TypeEnum.TYPE1, TypeEnum.TYPE2 }); + + System.out.println(json); + assertThat(json, containsString("\"name\":\"Type A\"")); + } + // tests - multiple entities to json @Test From eae3624d28df73386f4872b8b7e828865ba90062 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 24 Dec 2013 18:38:24 +0200 Subject: [PATCH 372/796] cleanup work --- .../jackson/dtos/{ => withEnum}/MyDtoWithEnum.java | 2 +- .../jackson/dtos/{ => withEnum}/MyDtoWithEnumCustom.java | 2 +- .../baeldung/jackson/dtos/{ => withEnum}/TypeEnum.java | 2 +- .../dtos/{ => withEnum}/TypeEnumWithCustomSerializer.java | 2 +- .../jackson/dtos/{ => withEnum}/TypeSerializer.java | 2 +- .../jackson/test/JacksonSerializationUnitTest.java | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => withEnum}/MyDtoWithEnum.java (96%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => withEnum}/MyDtoWithEnumCustom.java (96%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => withEnum}/TypeEnum.java (93%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => withEnum}/TypeEnumWithCustomSerializer.java (93%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => withEnum}/TypeSerializer.java (94%) diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnum.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnum.java index 015e2863075f..aa05539b891e 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnum.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnum.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.withEnum; public class MyDtoWithEnum { diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java index 825dbb257715..b58ea4bd15f7 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoWithEnumCustom.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.withEnum; public class MyDtoWithEnumCustom { diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnum.java similarity index 93% rename from jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnum.java index 8d2358666aa2..316fdb12e781 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnum.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnum.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.withEnum; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithCustomSerializer.java similarity index 93% rename from jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithCustomSerializer.java index 479c1ba46e14..7e004d2d7df6 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeEnumWithCustomSerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithCustomSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.withEnum; import com.fasterxml.jackson.databind.annotation.JsonSerialize; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeSerializer.java similarity index 94% rename from jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeSerializer.java index da1fc4e4a9ab..8aa7e5c55152 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/TypeSerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.withEnum; import java.io.IOException; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index 1a6014c0e7cf..e348e60de3fc 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -12,10 +12,10 @@ import org.baeldung.jackson.dtos.MyDtoFieldNameChanged; import org.baeldung.jackson.dtos.MyDtoNoAccessors; import org.baeldung.jackson.dtos.MyDtoNoAccessorsAndFieldVisibility; -import org.baeldung.jackson.dtos.MyDtoWithEnum; -import org.baeldung.jackson.dtos.MyDtoWithEnumCustom; -import org.baeldung.jackson.dtos.TypeEnum; -import org.baeldung.jackson.dtos.TypeEnumWithCustomSerializer; +import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnum; +import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom; +import org.baeldung.jackson.dtos.withEnum.TypeEnum; +import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; From 2d61b547379d7730eada2d82587397c38987aaff Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:06:55 +0200 Subject: [PATCH 373/796] new testing project --- core-java-8/.classpath | 36 +++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + core-java-8/.gitignore | 13 ++ core-java-8/.project | 36 +++++ core-java-8/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + core-java-8/.springBeans | 14 ++ core-java-8/README.md | 6 + core-java-8/pom.xml | 139 ++++++++++++++++++ core-java-8/src/main/resources/logback.xml | 16 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + core-java-8/src/main/webapp/WEB-INF/web.xml | 42 ++++++ .../org/baeldung/java/CoreJavaUnitTest.java | 52 +++++++ core-java-8/src/test/resources/.gitignore | 13 ++ 23 files changed, 571 insertions(+) create mode 100644 core-java-8/.classpath create mode 100644 core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 core-java-8/.gitignore create mode 100644 core-java-8/.project create mode 100644 core-java-8/.settings/.jsdtscope create mode 100644 core-java-8/.settings/org.eclipse.jdt.core.prefs create mode 100644 core-java-8/.settings/org.eclipse.jdt.ui.prefs create mode 100644 core-java-8/.settings/org.eclipse.m2e.core.prefs create mode 100644 core-java-8/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 core-java-8/.settings/org.eclipse.wst.common.component create mode 100644 core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 core-java-8/.settings/org.eclipse.wst.validation.prefs create mode 100644 core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 core-java-8/.springBeans create mode 100644 core-java-8/README.md create mode 100644 core-java-8/pom.xml create mode 100644 core-java-8/src/main/resources/logback.xml create mode 100644 core-java-8/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 core-java-8/src/main/webapp/WEB-INF/web.xml create mode 100644 core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java create mode 100644 core-java-8/src/test/resources/.gitignore diff --git a/core-java-8/.classpath b/core-java-8/.classpath new file mode 100644 index 000000000000..0720e4851bd7 --- /dev/null +++ b/core-java-8/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/core-java-8/.gitignore b/core-java-8/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/core-java-8/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/core-java-8/.project b/core-java-8/.project new file mode 100644 index 000000000000..9aac6b80bdca --- /dev/null +++ b/core-java-8/.project @@ -0,0 +1,36 @@ + + + core-java-8 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/core-java-8/.settings/.jsdtscope b/core-java-8/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/core-java-8/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/core-java-8/.settings/org.eclipse.jdt.core.prefs b/core-java-8/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/core-java-8/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/core-java-8/.settings/org.eclipse.jdt.ui.prefs b/core-java-8/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/core-java-8/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/core-java-8/.settings/org.eclipse.m2e.core.prefs b/core-java-8/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/core-java-8/.settings/org.eclipse.m2e.wtp.prefs b/core-java-8/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/core-java-8/.settings/org.eclipse.wst.common.component b/core-java-8/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml b/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/core-java-8/.settings/org.eclipse.wst.validation.prefs b/core-java-8/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs b/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/core-java-8/.springBeans b/core-java-8/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/core-java-8/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/core-java-8/README.md b/core-java-8/README.md new file mode 100644 index 000000000000..a78f99a41669 --- /dev/null +++ b/core-java-8/README.md @@ -0,0 +1,6 @@ +========= + +## Core Java Cookbooks and Examples + +### Relevant Articles: +// - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml new file mode 100644 index 000000000000..782e9a7da976 --- /dev/null +++ b/core-java-8/pom.xml @@ -0,0 +1,139 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + core-java-8 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 2.3.0 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + + + \ No newline at end of file diff --git a/core-java-8/src/main/resources/logback.xml b/core-java-8/src/main/resources/logback.xml new file mode 100644 index 000000000000..62d0ea5037b2 --- /dev/null +++ b/core-java-8/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml b/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..5463820874c8 --- /dev/null +++ b/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/core-java-8/src/main/webapp/WEB-INF/web.xml b/core-java-8/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/core-java-8/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java new file mode 100644 index 000000000000..fb6e39f7680b --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java @@ -0,0 +1,52 @@ +package org.baeldung.java; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; + +import com.google.common.collect.ImmutableList; + +public class CoreJavaUnitTest { + + // tests - + + @Test + public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List synchronizedList = Collections.synchronizedList(list); + System.out.println("Synchronized List is: " + synchronizedList); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingTheJdk_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = Collections.unmodifiableList(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ImmutableList.copyOf(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { + final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ListUtils.unmodifiableList(list); + unmodifiableList.add("four"); + } + +} diff --git a/core-java-8/src/test/resources/.gitignore b/core-java-8/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/core-java-8/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 60b3ea14dc6a47be5104e65eb524f2f5a26ff45a Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:10:47 +0200 Subject: [PATCH 374/796] eclipse work --- ...clipse.wst.jsdt.core.javascriptValidator.launch | 7 ------- core-java-8/.project | 12 ------------ core-java-8/.settings/org.eclipse.m2e.wtp.prefs | 2 -- .../.settings/org.eclipse.wst.common.component | 8 -------- .../org.eclipse.wst.common.project.facet.core.xml | 4 ---- .../org.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .../.settings/org.eclipse.wst.validation.prefs | 14 -------------- .../org.eclipse.wst.ws.service.policy.prefs | 2 -- 9 files changed, 51 deletions(-) delete mode 100644 core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch delete mode 100644 core-java-8/.settings/org.eclipse.m2e.wtp.prefs delete mode 100644 core-java-8/.settings/org.eclipse.wst.common.component delete mode 100644 core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 core-java-8/.settings/org.eclipse.wst.validation.prefs delete mode 100644 core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs diff --git a/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch deleted file mode 100644 index 627021fb9640..000000000000 --- a/core-java-8/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/core-java-8/.project b/core-java-8/.project index 9aac6b80bdca..235c555abb75 100644 --- a/core-java-8/.project +++ b/core-java-8/.project @@ -10,16 +10,6 @@ - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - org.eclipse.m2e.core.maven2Builder @@ -28,9 +18,7 @@ org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature diff --git a/core-java-8/.settings/org.eclipse.m2e.wtp.prefs b/core-java-8/.settings/org.eclipse.m2e.wtp.prefs deleted file mode 100644 index ef8608962237..000000000000 --- a/core-java-8/.settings/org.eclipse.m2e.wtp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/core-java-8/.settings/org.eclipse.wst.common.component b/core-java-8/.settings/org.eclipse.wst.common.component deleted file mode 100644 index e98377cb0f7c..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml b/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index bc0009a45587..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a48039..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name b/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6ec2c..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/core-java-8/.settings/org.eclipse.wst.validation.prefs b/core-java-8/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index cacf5451aef7..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,14 +0,0 @@ -DELEGATES_PREFERENCE=delegateValidatorList -USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 -eclipse.preferences.version=1 -override=true -suspend=false -vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 -vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 -vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 -vf.version=3 diff --git a/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs b/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs deleted file mode 100644 index 9cfcabe16f73..000000000000 --- a/core-java-8/.settings/org.eclipse.wst.ws.service.policy.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.wst.ws.service.policy.projectEnabled=false From 1a12a44cb1c0bb6258e00573100984da3c0fad16 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:14:22 +0200 Subject: [PATCH 375/796] initial java 8 sample --- core-java-8/.classpath | 2 +- core-java-8/.settings/org.eclipse.jdt.core.prefs | 7 ++++--- core-java-8/src/main/java/.gitignore | 13 +++++++++++++ .../java/org/baeldung/java/CoreJava8UnitTest.java | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 core-java-8/src/main/java/.gitignore create mode 100644 core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java diff --git a/core-java-8/.classpath b/core-java-8/.classpath index 0720e4851bd7..5efa587d72eb 100644 --- a/core-java-8/.classpath +++ b/core-java-8/.classpath @@ -27,7 +27,7 @@ - + diff --git a/core-java-8/.settings/org.eclipse.jdt.core.prefs b/core-java-8/.settings/org.eclipse.jdt.core.prefs index 723e5b12451a..c57289fc0970 100644 --- a/core-java-8/.settings/org.eclipse.jdt.core.prefs +++ b/core-java-8/.settings/org.eclipse.jdt.core.prefs @@ -5,9 +5,10 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,4 +93,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/core-java-8/src/main/java/.gitignore b/core-java-8/src/main/java/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/core-java-8/src/main/java/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java b/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java new file mode 100644 index 000000000000..9e7c00b4ebe5 --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java @@ -0,0 +1,15 @@ +package org.baeldung.java; + +import org.junit.Test; + +public class CoreJava8UnitTest { + + // tests - + + @Test + public final void when_thenCorrect() { + final Runnable r2 = () -> System.out.println("Hello world two!"); + r2.run(); + } + +} From 9543f1f067443d87b2d3923cbbed76b0dc26199e Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:22:15 +0200 Subject: [PATCH 376/796] lambda example --- .../.settings/org.eclipse.jdt.ui.prefs | 6 +- core-java-8/pom.xml | 281 +++++++++--------- .../org/baeldung/java/CoreJava8UnitTest.java | 15 - .../org/baeldung/java/CoreJavaUnitTest.java | 52 ---- .../java8/Java8ComparatorUnitTest.java | 24 ++ .../java/org/baeldung/java8/entity/Human.java | 64 ++++ 6 files changed, 236 insertions(+), 206 deletions(-) delete mode 100644 core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java delete mode 100644 core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java create mode 100644 core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java create mode 100644 core-java-8/src/test/java/org/baeldung/java8/entity/Human.java diff --git a/core-java-8/.settings/org.eclipse.jdt.ui.prefs b/core-java-8/.settings/org.eclipse.jdt.ui.prefs index 471e9b0d81fc..d84d2a7f8cd1 100644 --- a/core-java-8/.settings/org.eclipse.jdt.ui.prefs +++ b/core-java-8/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ -#Sat Jan 21 23:04:06 EET 2012 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true sp_cleanup.add_default_serial_version_id=true @@ -14,6 +13,7 @@ sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=true sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false sp_cleanup.convert_to_enhanced_for_loop=true sp_cleanup.correct_indentation=true sp_cleanup.format_source_code=true @@ -46,8 +46,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=true sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=true sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index 782e9a7da976..cd690f1e71bd 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -1,139 +1,146 @@ - - 4.0.0 - org.baeldung - spring-rest - 0.1-SNAPSHOT - - spring-rest - - - - - - - com.google.guava - guava - 15.0 - - - - org.apache.commons - commons-collections4 - 4.0 - - - - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - core-java-8 - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - 4.0.0.RELEASE - 3.2.0.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 2.3.0 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - - - 3.1 - 2.4 - 2.16 - 2.6 - 1.4.5 - - + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 16.0-rc1 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + org.apache.commons + commons-lang3 + 3.1 + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + core-java-8 + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 2.3.0 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java b/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java deleted file mode 100644 index 9e7c00b4ebe5..000000000000 --- a/core-java-8/src/test/java/org/baeldung/java/CoreJava8UnitTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.baeldung.java; - -import org.junit.Test; - -public class CoreJava8UnitTest { - - // tests - - - @Test - public final void when_thenCorrect() { - final Runnable r2 = () -> System.out.println("Hello world two!"); - r2.run(); - } - -} diff --git a/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java deleted file mode 100644 index fb6e39f7680b..000000000000 --- a/core-java-8/src/test/java/org/baeldung/java/CoreJavaUnitTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.baeldung.java; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.collections4.ListUtils; -import org.junit.Test; - -import com.google.common.collect.ImmutableList; - -public class CoreJavaUnitTest { - - // tests - - - @Test - public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List synchronizedList = Collections.synchronizedList(list); - System.out.println("Synchronized List is: " + synchronizedList); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingTheJdk_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = Collections.unmodifiableList(list); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = ImmutableList.copyOf(list); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = ListUtils.unmodifiableList(list); - unmodifiableList.add("four"); - } - -} diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java new file mode 100644 index 000000000000..8a2a2cd3d861 --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java @@ -0,0 +1,24 @@ +package org.baeldung.java8; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import java.util.Collections; +import java.util.List; + +import org.baeldung.java8.entity.Human; +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class Java8ComparatorUnitTest { + + // tests - + + @Test + public final void when_thenCorrect() { + final List humans = Lists.newArrayList(new Human(randomAlphabetic(5)), new Human(randomAlphabetic(5))); + Collections.sort(humans, (final Human h1, final Human h2) -> h1.getName().compareTo(h2.getName())); + System.out.println(humans); + } + +} diff --git a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java new file mode 100644 index 000000000000..e5d96262bf5b --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java @@ -0,0 +1,64 @@ +package org.baeldung.java8.entity; + +public class Human { + private String name; + + public Human() { + super(); + } + + public Human(final String name) { + super(); + + this.name = name; + } + + // API + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Human other = (Human) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Human [name=").append(name).append("]"); + return builder.toString(); + } + +} From 82995423dca0726f46e29700032b64fb354fdbf9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:37:06 +0200 Subject: [PATCH 377/796] eclipse and cleanup work --- core-java-8/pom.xml | 4 ++-- ...orUnitTest.java => Java8SortUnitTest.java} | 10 ++++------ .../java/org/baeldung/java8/entity/Human.java | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 10 deletions(-) rename core-java-8/src/test/java/org/baeldung/java8/{Java8ComparatorUnitTest.java => Java8SortUnitTest.java} (61%) diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index cd690f1e71bd..aacc12ec67a6 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -86,8 +86,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java similarity index 61% rename from core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java rename to core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java index 8a2a2cd3d861..cc068e68ee60 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8ComparatorUnitTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java @@ -1,7 +1,5 @@ package org.baeldung.java8; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - import java.util.Collections; import java.util.List; @@ -10,15 +8,15 @@ import com.google.common.collect.Lists; -public class Java8ComparatorUnitTest { +public class Java8SortUnitTest { // tests - @Test - public final void when_thenCorrect() { - final List humans = Lists.newArrayList(new Human(randomAlphabetic(5)), new Human(randomAlphabetic(5))); + public final void whenSortingEntitiesByName_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); Collections.sort(humans, (final Human h1, final Human h2) -> h1.getName().compareTo(h2.getName())); - System.out.println(humans); + // Assert.assertThat(actual, matcher); } } diff --git a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java index e5d96262bf5b..09688412d0de 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java +++ b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java @@ -2,15 +2,17 @@ public class Human { private String name; + private int age; public Human() { super(); } - public Human(final String name) { + public Human(final String name, final int age) { super(); this.name = name; + this.age = age; } // API @@ -23,11 +25,21 @@ public void setName(final String name) { this.name = name; } + public int getAge() { + return age; + } + + public void setAge(final int age) { + this.age = age; + } + // + @Override public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + age; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } @@ -44,6 +56,9 @@ public boolean equals(final Object obj) { return false; } final Human other = (Human) obj; + if (age != other.age) { + return false; + } if (name == null) { if (other.name != null) { return false; @@ -57,7 +72,7 @@ public boolean equals(final Object obj) { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("Human [name=").append(name).append("]"); + builder.append("Human [name=").append(name).append(", age=").append(age).append("]"); return builder.toString(); } From ba8559ab5057184c512291f7a8d79b4089b79f09 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 14:52:29 +0200 Subject: [PATCH 378/796] java 8 work --- .../java/org/baeldung/java8/Java8SortUnitTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java index cc068e68ee60..d4cf6e4aa6b0 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java @@ -1,12 +1,16 @@ package org.baeldung.java8; +import static org.hamcrest.Matchers.equalTo; + import java.util.Collections; import java.util.List; import org.baeldung.java8.entity.Human; +import org.junit.Assert; import org.junit.Test; import com.google.common.collect.Lists; +import com.google.common.primitives.Ints; public class Java8SortUnitTest { @@ -16,7 +20,14 @@ public class Java8SortUnitTest { public final void whenSortingEntitiesByName_thenCorrectlySorted() { final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); Collections.sort(humans, (final Human h1, final Human h2) -> h1.getName().compareTo(h2.getName())); - // Assert.assertThat(actual, matcher); + Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); + } + + @Test + public final void whenSortingEntitiesByAge_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + Collections.sort(humans, (final Human h1, final Human h2) -> Ints.compare(h1.getAge(), h2.getAge())); + Assert.assertThat(humans.get(0), equalTo(new Human("Sarah", 10))); } } From 6633f5b9a01c7325392158a030243c7488b857ac Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Dec 2013 23:41:29 +0200 Subject: [PATCH 379/796] new tests --- .../org/baeldung/java8/Java8SortUnitTest.java | 67 ++++++++++++++++++- .../java/org/baeldung/java8/entity/Human.java | 10 +++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java index d4cf6e4aa6b0..5398198a7b9d 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java @@ -1,8 +1,10 @@ package org.baeldung.java8; +import static org.baeldung.java8.entity.Human.compareByNameThenAge; import static org.hamcrest.Matchers.equalTo; import java.util.Collections; +import java.util.Comparator; import java.util.List; import org.baeldung.java8.entity.Human; @@ -16,6 +18,18 @@ public class Java8SortUnitTest { // tests - + @Test + public final void givenPreLambda_whenSortingEntitiesByName_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + Collections.sort(humans, new Comparator() { + @Override + public final int compare(final Human h1, final Human h2) { + return h1.getName().compareTo(h2.getName()); + } + }); + Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); + } + @Test public final void whenSortingEntitiesByName_thenCorrectlySorted() { final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); @@ -23,11 +37,62 @@ public final void whenSortingEntitiesByName_thenCorrectlySorted() { Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); } + @Test + public final void givenLambdaShortForm_whenSortingEntitiesByName_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + Collections.sort(humans, (h1, h2) -> h1.getName().compareTo(h2.getName())); + Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); + } + + @Test + public final void whenSortingEntitiesByNameThenAge_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 12), new Human("Sarah", 10), new Human("Zack", 12)); + Collections.sort(humans, (lhs, rhs) -> { + if (lhs.getName().equals(rhs.getName())) { + return lhs.getAge() - rhs.getAge(); + } else { + return lhs.getName().compareTo(rhs.getName()); + } + }); + Assert.assertThat(humans.get(0), equalTo(new Human("Sarah", 10))); + } + + @Test + public final void givenComposition_whenSortingEntitiesByNameThenAge_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 12), new Human("Sarah", 10), new Human("Zack", 12)); + final Comparator byName = (h1, h2) -> h1.getName().compareTo(h2.getName()); + final Comparator byAge = (h1, h2) -> Ints.compare(h1.getAge(), h2.getAge()); + Collections.sort(humans, byName.thenComparing(byAge)); + Assert.assertThat(humans.get(0), equalTo(new Human("Sarah", 10))); + } + @Test public final void whenSortingEntitiesByAge_thenCorrectlySorted() { final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); - Collections.sort(humans, (final Human h1, final Human h2) -> Ints.compare(h1.getAge(), h2.getAge())); + Collections.sort(humans, (h1, h2) -> Ints.compare(h1.getAge(), h2.getAge())); + Assert.assertThat(humans.get(0), equalTo(new Human("Sarah", 10))); + } + + @Test + public final void whenSortingEntitiesByNameReversed_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + final Comparator comparator = (h1, h2) -> h1.getName().compareTo(h2.getName()); + Collections.sort(humans, comparator.reversed()); Assert.assertThat(humans.get(0), equalTo(new Human("Sarah", 10))); } + @Test + public final void givenMethodDefinition_whenSortingEntitiesByNameThenAge_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + Collections.sort(humans, Human::compareByNameThenAge); + Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); + } + + @Test + public final void givenInstanceMethod_whenSortingEntitiesByName_thenCorrectlySorted() { + final List humans = Lists.newArrayList(new Human("Sarah", 10), new Human("Jack", 12)); + Collections.sort(humans, Comparator.comparing(Human::getName)); + Assert.assertThat(humans.get(0), equalTo(new Human("Jack", 12))); + } + } diff --git a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java index 09688412d0de..ac58b301b7f3 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java +++ b/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java @@ -33,6 +33,16 @@ public void setAge(final int age) { this.age = age; } + // compare + + public static int compareByNameThenAge(final Human lhs, final Human rhs) { + if (lhs.name.equals(rhs.name)) { + return lhs.age - rhs.age; + } else { + return lhs.name.compareTo(rhs.name); + } + } + // @Override From cfafcc57b75a79270fd22ccdb9ba9895b8bb68e6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 26 Dec 2013 19:52:19 +0200 Subject: [PATCH 380/796] cleanup work --- ....java => CoreJavaCollectionsUnitTest.java} | 2 +- .../org/baeldung/java/CoreJavaIoUnitTest.java | 14 ++++ .../httpclient/HttpClientBasicLiveTest.java | 10 +-- .../HttpClientBasicPostLiveTest.java | 73 +++++++++++++++++++ 4 files changed, 89 insertions(+), 10 deletions(-) rename core-java/src/test/java/org/baeldung/java/{CoreJavaUnitTest.java => CoreJavaCollectionsUnitTest.java} (98%) create mode 100644 core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java similarity index 98% rename from core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java rename to core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java index fb6e39f7680b..7dc6b7aab04b 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java @@ -10,7 +10,7 @@ import com.google.common.collect.ImmutableList; -public class CoreJavaUnitTest { +public class CoreJavaCollectionsUnitTest { // tests - diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java new file mode 100644 index 000000000000..60bf6ee9a066 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -0,0 +1,14 @@ +package org.baeldung.java; + +import org.junit.Test; + +public class CoreJavaIoUnitTest { + + // tests - + + @Test + public final void whenIteratingAFile_thenCorrect() { + // + } + +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java index d11af39d34fe..10f0b9e149da 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java @@ -12,7 +12,6 @@ import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; @@ -63,7 +62,7 @@ public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientP @Test public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { response = instance.execute(new HttpGet(SAMPLE_URL)); - int statusCode = response.getStatusLine().getStatusCode(); + final int statusCode = response.getStatusLine().getStatusCode(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); } @@ -83,11 +82,4 @@ public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBo assertThat(bodyAsString, notNullValue()); } - // tests - non-GET - - @Test - public final void whenExecutingBasicRequest_thenNoExceptions() throws ClientProtocolException, IOException { - instance.execute(new HttpPost(SAMPLE_URL)); - } - } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java new file mode 100644 index 000000000000..3dd4a988b04a --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java @@ -0,0 +1,73 @@ +package org.baeldung.httpclient; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.auth.AuthenticationException; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientBasicPostLiveTest { + + private static final String SAMPLE_URL = "http://www.github.com"; + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests - non-GET + + @Test + public final void whenExecutingPostRequest_thenNoExceptions() throws ClientProtocolException, IOException { + instance.execute(new HttpPost(SAMPLE_URL)); + } + + @Test + public final void whenExecutingPostRequestWithBody_thenNoExceptions() throws ClientProtocolException, IOException { + final HttpPost request = new HttpPost(SAMPLE_URL); + request.setEntity(new StringEntity("in the body of the POST")); + instance.execute(request); + } + + @Test + public final void givenAuth_whenExecutingPostRequestWithBody_thenNoExceptions() throws ClientProtocolException, IOException, AuthenticationException { + final HttpPost request = new HttpPost(SAMPLE_URL); + request.setEntity(new StringEntity("in the body of the POST")); + final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("username", "password"); + request.addHeader(new BasicScheme().authenticate(creds, request, null)); + instance.execute(request); + } + +} From a4a6fcf5692d7438708ac6a7cdf3fcf0c1b19b48 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 26 Dec 2013 22:08:32 +0200 Subject: [PATCH 381/796] mostly doc and minor cleanup work --- core-java-8/README.md | 4 +- core-java/README.md | 3 +- core-java/pom.xml | 33 ++++++++- .../org/baeldung/java/CoreJavaIoUnitTest.java | 72 ++++++++++++++++++- httpclient/README.md | 6 ++ 5 files changed, 112 insertions(+), 6 deletions(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index a78f99a41669..9bb6bb811c97 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -1,6 +1,6 @@ ========= -## Core Java Cookbooks and Examples +## Core Java 8 Cookbooks and Examples ### Relevant Articles: -// - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) +// - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) diff --git a/core-java/README.md b/core-java/README.md index a78f99a41669..717008f507f8 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -3,4 +3,5 @@ ## Core Java Cookbooks and Examples ### Relevant Articles: -// - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) +- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) +- [Java - Reading a Large File Efficiently](http://www.baeldung.com/java-read-lines-large-file) diff --git a/core-java/pom.xml b/core-java/pom.xml index ff5f8b40dfc1..ed3cb6ce435c 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -22,6 +22,12 @@ 4.0 + + commons-io + commons-io + 2.4 + + @@ -32,6 +38,31 @@ ${jackson.version} + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + @@ -101,7 +132,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 2.3.0 diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java index 60bf6ee9a066..424621bc5953 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -1,14 +1,82 @@ package org.baeldung.java; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Scanner; + +import org.apache.commons.io.FileUtils; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; public class CoreJavaIoUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); // tests - @Test - public final void whenIteratingAFile_thenCorrect() { - // + public final void givenUsingGuava_whenIteratingAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + Files.readLines(new File(path), Charsets.UTF_8); + logMemory(); + } + + @Test + public final void givenUsingCommonsIo_whenIteratingAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + FileUtils.readLines(new File(path)); + logMemory(); + } + + @Test + public final void whenStreamingThroughAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + + FileInputStream inputStream = null; + Scanner sc = null; + try { + inputStream = new FileInputStream(path); + sc = new Scanner(inputStream, "UTF-8"); + while (sc.hasNextLine()) { + final String line = sc.nextLine(); + // System.out.println(line); + } + // note that Scanner suppresses exceptions + if (sc.ioException() != null) { + throw sc.ioException(); + } + } finally { + if (inputStream != null) { + inputStream.close(); + } + if (sc != null) { + sc.close(); + } + } + + logMemory(); + } + + // + + private final void logMemory() { + logger.info("Max Memory: {} Mb", Runtime.getRuntime().maxMemory() / 1048576); + logger.info("Total Memory: {} Mb", Runtime.getRuntime().totalMemory() / 1048576); + logger.info("Free Memory: {} Mb", Runtime.getRuntime().freeMemory() / 1048576); } } +// \ No newline at end of file diff --git a/httpclient/README.md b/httpclient/README.md index 907630299207..70e44b56cf05 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -4,4 +4,10 @@ ### Relevant Articles: + +- [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) +- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) +- [HttpClient 4 – Cancel / Abort Request](http://www.baeldung.com/httpclient-cancel-request) - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) +- [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) +- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) From bde8a4b73bd56042019bc6388fb70c86c3ea387a Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 30 Dec 2013 17:17:49 +0200 Subject: [PATCH 382/796] new jackson sandboxed work --- jackson/pom.xml | 11 +++++-- jackson/src/main/resources/example1.json | 12 +++++++ jackson/src/main/resources/example2.json | 10 ++++++ .../org/baeldung/jackson/try1/COrder.java | 32 +++++++++++++++++++ .../jackson/try1/JacksonTryUnitTest.java | 31 ++++++++++++++++++ 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 jackson/src/main/resources/example1.json create mode 100644 jackson/src/main/resources/example2.json create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/COrder.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java diff --git a/jackson/pom.xml b/jackson/pom.xml index 348e1b8ef224..b5d16d26fcc0 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -13,7 +13,12 @@ com.google.guava guava - 15.0 + 16.0-rc1 + + + commons-io + commons-io + 2.4 @@ -102,10 +107,10 @@ 4.3.0.Final 5.1.27 - + 2.3.0 - + 1.7.5 1.0.11 diff --git a/jackson/src/main/resources/example1.json b/jackson/src/main/resources/example1.json new file mode 100644 index 000000000000..46d2982cecdd --- /dev/null +++ b/jackson/src/main/resources/example1.json @@ -0,0 +1,12 @@ +{ + "collection": [ + { + "name": "Test order1", + "detail": "ahk ks" + }, + { + "name": "Test order2", + "detail": "Fisteku" + } + ] +} \ No newline at end of file diff --git a/jackson/src/main/resources/example2.json b/jackson/src/main/resources/example2.json new file mode 100644 index 000000000000..f4433731e612 --- /dev/null +++ b/jackson/src/main/resources/example2.json @@ -0,0 +1,10 @@ +[ + { + "name": "Test order1", + "detail": "ahk ks" + }, + { + "name": "Test order2", + "detail": "Fisteku" + } +] \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java b/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java new file mode 100644 index 000000000000..f20bccbee2be --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java @@ -0,0 +1,32 @@ +package org.baeldung.jackson.try1; + +public class COrder { + private String name; + private String detail; + + // + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getDetail() { + return detail; + } + + public void setDetail(final String detail) { + this.detail = detail; + } + + // + + @Override + public String toString() { + return "COrder [name=" + name + ", detail=" + detail + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]"; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java new file mode 100644 index 000000000000..ce221044758e --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java @@ -0,0 +1,31 @@ +package org.baeldung.jackson.try1; + +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.net.URL; +import java.util.Collection; + +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Charsets; +import com.google.common.io.Resources; + +public class JacksonTryUnitTest { + + @Test + public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final URL url = Resources.getResource("example2.json"); + final String jsonAsString = Resources.toString(url, Charsets.UTF_8); + + final Collection readValues = new ObjectMapper().readValue(jsonAsString, new TypeReference>() { + }); + + assertNotNull(readValues); + } + +} From fcf3e693f5c8e8f5b4cad78c30dc630baec63c38 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 31 Dec 2013 19:12:12 +0200 Subject: [PATCH 383/796] upgrading all xsds to spring 4 --- core-java/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- experiments/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- guava/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- httpclient/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- jackson/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- mockito/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- spring-all/src/main/resources/configForProperties.xml | 6 +++--- spring-all/src/main/resources/configForPropertiesOne.xml | 6 +++--- spring-all/src/main/resources/configForPropertiesTwo.xml | 6 +++--- spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/beancreationexception_cause4.xml | 6 +++--- .../src/main/resources/beancreationexception_cause6.xml | 6 +++--- .../src/main/resources/beancreationexception_cause7.xml | 6 +++--- .../src/main/resources/beancreationexception_cause9.xml | 6 +++--- .../src/main/resources/configForProperties.xml | 6 +++--- .../src/main/resources/configForPropertiesOne.xml | 6 +++--- .../src/main/resources/configForPropertiesTwo.xml | 6 +++--- spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/persistenceConfig.xml | 4 ++-- spring-hibernate4/src/main/resources/hibernate4Config.xml | 4 ++-- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-jpa/src/main/resources/jpaConfig.xml | 6 +++--- spring-jpa/src/main/resources/webSecurityConfig.xml | 2 +- spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- spring-mvc-xml/src/main/resources/webSecurityConfig.xml | 2 +- spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- spring-rest/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 8 ++++---- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/springDataPersistenceConfig.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- 51 files changed, 78 insertions(+), 78 deletions(-) diff --git a/core-java/src/main/webapp/WEB-INF/api-servlet.xml b/core-java/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/core-java/src/main/webapp/WEB-INF/api-servlet.xml +++ b/core-java/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/experiments/src/main/webapp/WEB-INF/api-servlet.xml b/experiments/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/experiments/src/main/webapp/WEB-INF/api-servlet.xml +++ b/experiments/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/guava/src/main/webapp/WEB-INF/api-servlet.xml b/guava/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/guava/src/main/webapp/WEB-INF/api-servlet.xml +++ b/guava/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml +++ b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/jackson/src/main/webapp/WEB-INF/api-servlet.xml b/jackson/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/jackson/src/main/webapp/WEB-INF/api-servlet.xml +++ b/jackson/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/mockito/src/main/webapp/WEB-INF/api-servlet.xml b/mockito/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/mockito/src/main/webapp/WEB-INF/api-servlet.xml +++ b/mockito/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index 20a40a319559..ca7e269c67e0 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-all/src/main/resources/configForPropertiesOne.xml b/spring-all/src/main/resources/configForPropertiesOne.xml index ad9716fada18..fc20d9a99a23 100644 --- a/spring-all/src/main/resources/configForPropertiesOne.xml +++ b/spring-all/src/main/resources/configForPropertiesOne.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-all/src/main/resources/configForPropertiesTwo.xml b/spring-all/src/main/resources/configForPropertiesTwo.xml index b9d5e86c95d9..25983530ad40 100644 --- a/spring-all/src/main/resources/configForPropertiesTwo.xml +++ b/spring-all/src/main/resources/configForPropertiesTwo.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml index 2899a6e35817..67c0ffca0d0d 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml index 9f66aafa10fd..6510edd176a8 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml index f9b95960ec5f..e04c096678cc 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml index 74878a62da09..59e30c3ede2b 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/configForProperties.xml b/spring-exceptions/src/main/resources/configForProperties.xml index 20a40a319559..ca7e269c67e0 100644 --- a/spring-exceptions/src/main/resources/configForProperties.xml +++ b/spring-exceptions/src/main/resources/configForProperties.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/configForPropertiesOne.xml b/spring-exceptions/src/main/resources/configForPropertiesOne.xml index ad9716fada18..fc20d9a99a23 100644 --- a/spring-exceptions/src/main/resources/configForPropertiesOne.xml +++ b/spring-exceptions/src/main/resources/configForPropertiesOne.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/resources/configForPropertiesTwo.xml b/spring-exceptions/src/main/resources/configForPropertiesTwo.xml index b9d5e86c95d9..25983530ad40 100644 --- a/spring-exceptions/src/main/resources/configForPropertiesTwo.xml +++ b/spring-exceptions/src/main/resources/configForPropertiesTwo.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-hibernate3/src/main/resources/persistenceConfig.xml b/spring-hibernate3/src/main/resources/persistenceConfig.xml index 62bccc1f2252..91efa15be17e 100644 --- a/spring-hibernate3/src/main/resources/persistenceConfig.xml +++ b/spring-hibernate3/src/main/resources/persistenceConfig.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml index fc4965255460..223d75c2db13 100644 --- a/spring-hibernate4/src/main/resources/hibernate4Config.xml +++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/spring-hibernate4/src/main/resources/webSecurityConfig.xml index 3012a337af54..35dcb9c1ef53 100644 --- a/spring-hibernate4/src/main/resources/webSecurityConfig.xml +++ b/spring-hibernate4/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-jpa/src/main/resources/jpaConfig.xml b/spring-jpa/src/main/resources/jpaConfig.xml index 31df8d69dacd..a291786a5ce1 100644 --- a/spring-jpa/src/main/resources/jpaConfig.xml +++ b/spring-jpa/src/main/resources/jpaConfig.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> diff --git a/spring-jpa/src/main/resources/webSecurityConfig.xml b/spring-jpa/src/main/resources/webSecurityConfig.xml index 3012a337af54..35dcb9c1ef53 100644 --- a/spring-jpa/src/main/resources/webSecurityConfig.xml +++ b/spring-jpa/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml index 3012a337af54..35dcb9c1ef53 100644 --- a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml +++ b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml index 3012a337af54..35dcb9c1ef53 100644 --- a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml +++ b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml b/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml index 5c56b26ddda2..e5310da18704 100644 --- a/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-basic-auth/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index 9bce45af78ae..0d87cc747e69 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> @@ -14,9 +14,9 @@ - - - + + + diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml index bb13271adb21..c8fb708c0b59 100644 --- a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml index 89d7bd3f569d..ea424e5e7887 100644 --- a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index b2dc8572e606..22409c67ee16 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml index 470ea8d44a28..de4a235b1e48 100644 --- a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml index e36bcd3a25fb..db4f4051031d 100644 --- a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 38321aeea15b..802167c3ebad 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml index a42410a49ef0..f9116a31abc1 100644 --- a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml +++ b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml @@ -1,7 +1,7 @@ diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index ce48352f3e28..b159881360bd 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index 841e609d4975..cefa3cd4efa9 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml index 5463820874c8..a675fc6d954f 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" > \ No newline at end of file From ca62e14784fb6391b33afcb5926834da9509cdd3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 31 Dec 2013 19:14:28 +0200 Subject: [PATCH 384/796] package cleanup --- .../src/main/java/org/baeldung/spring/PersistenceXmlConfig.java | 2 +- spring-hibernate4/src/main/resources/hibernate4Config.xml | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 2 +- .../service/ParentServicePersistenceIntegrationTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename spring-hibernate4/src/test/java/org/baeldung/{spring => }/persistence/service/FooServicePersistenceIntegrationTest.java (97%) rename spring-hibernate4/src/test/java/org/baeldung/{spring => }/persistence/service/ParentServicePersistenceIntegrationTest.java (98%) diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java index f7b11b19a225..f5857ec42535 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java @@ -7,7 +7,7 @@ @Configuration @EnableTransactionManagement -@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) +@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) @ImportResource({ "classpath:hibernate4Config.xml" }) public class PersistenceXmlConfig { diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml index 223d75c2db13..bef5a012be61 100644 --- a/spring-hibernate4/src/main/resources/hibernate4Config.xml +++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml @@ -10,7 +10,7 @@ - + ${hibernate.hbm2ddl.auto} diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 97% rename from spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 4c0413a01a66..5b45d65e579d 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; diff --git a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java similarity index 98% rename from spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java index 1c219ac2fad5..aeeb810258ea 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/spring/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; import org.baeldung.persistence.model.Child; import org.baeldung.persistence.model.Parent; From 951a83c64d06d7e33115f0df7ba0044328fb02df Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 31 Dec 2013 19:19:16 +0200 Subject: [PATCH 385/796] package cleanup --- spring-hibernate3/src/main/resources/persistenceConfig.xml | 2 +- .../service/FooServicePersistenceIntegrationTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename spring-hibernate3/src/test/java/org/baeldung/{spring => }/persistence/service/FooServicePersistenceIntegrationTest.java (97%) diff --git a/spring-hibernate3/src/main/resources/persistenceConfig.xml b/spring-hibernate3/src/main/resources/persistenceConfig.xml index 91efa15be17e..f05f05eb1f94 100644 --- a/spring-hibernate3/src/main/resources/persistenceConfig.xml +++ b/spring-hibernate3/src/main/resources/persistenceConfig.xml @@ -10,7 +10,7 @@ - + ${hibernate.hbm2ddl.auto} diff --git a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 97% rename from spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java rename to spring-hibernate3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index aaf0dd23e6aa..b6e4a5592ffc 100644 --- a/spring-hibernate3/src/test/java/org/baeldung/spring/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.persistence.service; +package org.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; From 42b09f3490fad34f76a7b38c5eaea76d3e2fbbf2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 31 Dec 2013 19:24:05 +0200 Subject: [PATCH 386/796] minor fix --- ...{MyDtoIgnoreUnkown.java => MyDtoIgnoreUnknown.java} | 6 +++--- .../jackson/test/JacksonDeserializationUnitTest.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) rename jackson/src/test/java/org/baeldung/jackson/dtos/{MyDtoIgnoreUnkown.java => MyDtoIgnoreUnknown.java} (84%) diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java similarity index 84% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java index 57ae6e86ba52..fb4fa2f72447 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnkown.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java @@ -3,17 +3,17 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) -public class MyDtoIgnoreUnkown { +public class MyDtoIgnoreUnknown { private String stringValue; private int intValue; private boolean booleanValue; - public MyDtoIgnoreUnkown() { + public MyDtoIgnoreUnknown() { super(); } - public MyDtoIgnoreUnkown(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoIgnoreUnknown(final String stringValue, final int intValue, final boolean booleanValue) { super(); this.stringValue = stringValue; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 858c83acbe9a..6938c0c2762f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -7,7 +7,7 @@ import java.io.IOException; import org.baeldung.jackson.dtos.MyDto; -import org.baeldung.jackson.dtos.MyDtoIgnoreUnkown; +import org.baeldung.jackson.dtos.MyDtoIgnoreUnknown; import org.junit.Test; import com.fasterxml.jackson.core.JsonFactory; @@ -48,7 +48,7 @@ public final void givenNotAllFieldsHaveValuesInJson_whenDeserializingAJsonToACla // tests - json with unknown fields @Test(expected = UnrecognizedPropertyException.class) - public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenExceptionIsThrown() throws JsonParseException, JsonMappingException, IOException { + public final void givenJsonHasUnknownValues_whenDeserializingAJsonToAClass_thenExceptionIsThrown() throws JsonParseException, JsonMappingException, IOException { final String jsonAsString = "{\"stringValue\":\"a\",\"intValue\":1,\"booleanValue\":true,\"stringValue2\":\"something\"}"; final ObjectMapper mapper = new ObjectMapper(); @@ -61,7 +61,7 @@ public final void givenJsonHasUnkownValues_whenDeserializingAJsonToAClass_thenEx } @Test - public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + public final void givenJsonHasUnknownValuesButJacksonIsIgnoringUnknownFields_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { final String jsonAsString =// @formatter:off "{\"stringValue\":\"a\"," + "\"intValue\":1," + @@ -79,7 +79,7 @@ public final void givenJsonHasUnkownValuesButJacksonIsIgnoringUnkownFields_whenD } @Test - public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + public final void givenJsonHasUnknownValuesButUnknownFieldsAreIgnoredOnClass_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { final String jsonAsString =// @formatter:off "{\"stringValue\":\"a\"," + "\"intValue\":1," + @@ -87,7 +87,7 @@ public final void givenJsonHasUnkownValuesButUnkownFieldsAreIgnoredOnClass_whenD "\"stringValue2\":\"something\"}"; // @formatter:on final ObjectMapper mapper = new ObjectMapper(); - final MyDtoIgnoreUnkown readValue = mapper.readValue(jsonAsString, MyDtoIgnoreUnkown.class); + final MyDtoIgnoreUnknown readValue = mapper.readValue(jsonAsString, MyDtoIgnoreUnknown.class); assertNotNull(readValue); assertThat(readValue.getStringValue(), equalTo("a")); From b3fbba5aba053bc0be1ba873f95c080be011d6e2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 31 Dec 2013 21:01:40 +0200 Subject: [PATCH 387/796] new httpclient timeout examples - old api and new api --- httpclient/pom.xml | 272 +++++++++--------- .../httpclient/HttpClientTimeoutLiveTest.java | 95 ++++++ spring-security-rest-basic-auth/pom.xml | 2 +- .../baeldung/client/RestTemplateFactory.java | 6 + 4 files changed, 240 insertions(+), 135 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 8047d56cd490..d3ef5e6d69cc 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -1,36 +1,40 @@ - - 4.0.0 - org.baeldung - httpclient - 0.1-SNAPSHOT - - httpclient - - - - - - - com.google.guava - guava - ${guava.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - + + 4.0.0 + org.baeldung + httpclient + 0.1-SNAPSHOT + + httpclient + + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + @@ -55,106 +59,106 @@ log4j-over-slf4j ${org.slf4j.version} - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - httpclient - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - 4.0.0.RELEASE - 3.2.0.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - - - 3.1 - 2.4 - 2.16 - 2.6 - 1.4.5 - - + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + httpclient + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.1 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java new file mode 100644 index 000000000000..d603d3414b74 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -0,0 +1,95 @@ +package org.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.params.CoreConnectionPNames; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.junit.After; +import org.junit.Test; + +public class HttpClientTimeoutLiveTest { + + private CloseableHttpResponse response; + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + @SuppressWarnings("deprecation") + @Test + public final void givenUsingDeprecatedApi_whenSettingTimeoutViaRawParams_thenCorrect() throws ClientProtocolException, IOException { + final int timeout = 2; + final DefaultHttpClient client = new DefaultHttpClient(); + final HttpGet request = new HttpGet("http://www.github.com"); + + final HttpParams httpParams = client.getParams(); + httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); + httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); + // httpParams.setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); // https://issues.apache.org/jira/browse/HTTPCLIENT-1418 + + response = client.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + client.close(); + } + + @SuppressWarnings("deprecation") + @Test + public final void givenUsingDeprecatedApi_whenSettingTimeoutViaHigherLevelApi_thenCorrect() throws ClientProtocolException, IOException { + final int timeout = 2; + final DefaultHttpClient client = new DefaultHttpClient(); + final HttpGet request = new HttpGet("http://www.github.com"); + + final HttpParams httpParams = client.getParams(); + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout + HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + + response = client.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + client.close(); + } + + @Test + public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect() throws ClientProtocolException, IOException { + final int timeout = 5; + + final RequestConfig.Builder requestBuilder = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000); + final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build()).build(); + + final HttpGet request = new HttpGet("http://www.github.com"); + + response = client.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + +} diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 08038ba23ec8..27e3404cffe2 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -294,7 +294,7 @@ 5.1.27 - 4.3 + 4.3.1 4.3.1 diff --git a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java index e8df87524c89..3eaa9e64eca0 100644 --- a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -2,6 +2,8 @@ import org.apache.http.HttpHost; import org.apache.http.client.HttpClient; +import org.apache.http.client.params.ClientPNames; +import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.springframework.beans.factory.FactoryBean; @@ -51,6 +53,10 @@ public void afterPropertiesSet() { // - note: timeout via the API final HttpParams httpParams = httpClient.getParams(); + httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); + httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); + httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); + HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout } From 3b8ee2351258fb01173a44a428265aee9de0cf56 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 02:48:17 +0200 Subject: [PATCH 388/796] minor example work --- .../org/baeldung/jackson/try1/COrder.java | 32 ----------------- .../jackson/try1/JacksonTryUnitTest.java | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 44 deletions(-) delete mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/COrder.java diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java b/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java deleted file mode 100644 index f20bccbee2be..000000000000 --- a/jackson/src/test/java/org/baeldung/jackson/try1/COrder.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.jackson.try1; - -public class COrder { - private String name; - private String detail; - - // - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - public String getDetail() { - return detail; - } - - public void setDetail(final String detail) { - this.detail = detail; - } - - // - - @Override - public String toString() { - return "COrder [name=" + name + ", detail=" + detail + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]"; - } - -} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java index ce221044758e..50e470dc298b 100644 --- a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java @@ -1,31 +1,42 @@ package org.baeldung.jackson.try1; -import static org.junit.Assert.assertNotNull; - import java.io.IOException; -import java.net.URL; -import java.util.Collection; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; -import com.google.common.io.Resources; public class JacksonTryUnitTest { @Test public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { - final URL url = Resources.getResource("example2.json"); - final String jsonAsString = Resources.toString(url, Charsets.UTF_8); + printJsonFromFile("/opt/git/github/eugenp/tutorials/jackson/src/main/resources/example1.json"); + } - final Collection readValues = new ObjectMapper().readValue(jsonAsString, new TypeReference>() { - }); + // + + public static void printJsonFromFile(final String fileName) { + System.out.println("-----------------"); + final ObjectMapper mapper = new ObjectMapper(); + try { + final Object json = mapper.readValue(readFile(fileName, StandardCharsets.UTF_8), Object.class); + System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json)); + } catch (final IOException e) { + e.printStackTrace(); + } + System.out.println("-----------------"); + } - assertNotNull(readValues); + static String readFile(final String path, final Charset encoding) throws IOException { + final byte[] encoded = Files.readAllBytes(Paths.get(path)); + return encoding.decode(ByteBuffer.wrap(encoded)).toString(); } } From 0480ef734eff2de25592255c5ac2cf8bbf216efa Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 13:19:44 +0200 Subject: [PATCH 389/796] cleanup work --- .../org/baeldung/httpclient/HttpClientTimeoutLiveTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java index d603d3414b74..16c1be1550ee 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -82,8 +82,8 @@ public final void givenUsingDeprecatedApi_whenSettingTimeoutViaHigherLevelApi_th public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect() throws ClientProtocolException, IOException { final int timeout = 5; - final RequestConfig.Builder requestBuilder = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000); - final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build()).build(); + final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); + final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); final HttpGet request = new HttpGet("http://www.github.com"); From afbb4c6005563fcdad92475fe33aca686f3daaa5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 15:58:46 +0200 Subject: [PATCH 390/796] new project --- rest-testing/.classpath | 36 ++++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + rest-testing/.gitignore | 13 ++ rest-testing/.project | 36 ++++ rest-testing/.settings/.jsdtscope | 5 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + rest-testing/.springBeans | 14 ++ rest-testing/README.md | 6 + rest-testing/pom.xml | 164 ++++++++++++++++++ rest-testing/src/main/resources/logback.xml | 17 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + rest-testing/src/main/webapp/WEB-INF/web.xml | 42 +++++ .../rest/HttpClientBasicLiveTest.java | 85 +++++++++ rest-testing/src/test/resources/.gitignore | 13 ++ 23 files changed, 630 insertions(+) create mode 100644 rest-testing/.classpath create mode 100644 rest-testing/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 rest-testing/.gitignore create mode 100644 rest-testing/.project create mode 100644 rest-testing/.settings/.jsdtscope create mode 100644 rest-testing/.settings/org.eclipse.jdt.core.prefs create mode 100644 rest-testing/.settings/org.eclipse.jdt.ui.prefs create mode 100644 rest-testing/.settings/org.eclipse.m2e.core.prefs create mode 100644 rest-testing/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 rest-testing/.settings/org.eclipse.wst.common.component create mode 100644 rest-testing/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 rest-testing/.settings/org.eclipse.wst.validation.prefs create mode 100644 rest-testing/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 rest-testing/.springBeans create mode 100644 rest-testing/README.md create mode 100644 rest-testing/pom.xml create mode 100644 rest-testing/src/main/resources/logback.xml create mode 100644 rest-testing/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 rest-testing/src/main/webapp/WEB-INF/web.xml create mode 100644 rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java create mode 100644 rest-testing/src/test/resources/.gitignore diff --git a/rest-testing/.classpath b/rest-testing/.classpath new file mode 100644 index 000000000000..0720e4851bd7 --- /dev/null +++ b/rest-testing/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rest-testing/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/rest-testing/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/rest-testing/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rest-testing/.gitignore b/rest-testing/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/rest-testing/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/rest-testing/.project b/rest-testing/.project new file mode 100644 index 000000000000..1dc9ce93fe0a --- /dev/null +++ b/rest-testing/.project @@ -0,0 +1,36 @@ + + + rest-testing + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/rest-testing/.settings/.jsdtscope b/rest-testing/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/rest-testing/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/rest-testing/.settings/org.eclipse.jdt.core.prefs b/rest-testing/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/rest-testing/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/rest-testing/.settings/org.eclipse.jdt.ui.prefs b/rest-testing/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/rest-testing/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/rest-testing/.settings/org.eclipse.m2e.core.prefs b/rest-testing/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/rest-testing/.settings/org.eclipse.m2e.wtp.prefs b/rest-testing/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/rest-testing/.settings/org.eclipse.wst.common.component b/rest-testing/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/rest-testing/.settings/org.eclipse.wst.common.project.facet.core.xml b/rest-testing/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.container b/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.name b/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/rest-testing/.settings/org.eclipse.wst.validation.prefs b/rest-testing/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/rest-testing/.settings/org.eclipse.wst.ws.service.policy.prefs b/rest-testing/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/rest-testing/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/rest-testing/.springBeans b/rest-testing/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/rest-testing/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/rest-testing/README.md b/rest-testing/README.md new file mode 100644 index 000000000000..cc476d097b2b --- /dev/null +++ b/rest-testing/README.md @@ -0,0 +1,6 @@ +========= + +## REST Testing and Examples + + +### Relevant Articles: diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml new file mode 100644 index 000000000000..bd3133df3b6a --- /dev/null +++ b/rest-testing/pom.xml @@ -0,0 +1,164 @@ + + 4.0.0 + org.baeldung + rest-testing + 0.1-SNAPSHOT + + rest-testing + + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + rest-testing + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.1 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + + + \ No newline at end of file diff --git a/rest-testing/src/main/resources/logback.xml b/rest-testing/src/main/resources/logback.xml new file mode 100644 index 000000000000..aa1e9cd52209 --- /dev/null +++ b/rest-testing/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + \ No newline at end of file diff --git a/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml b/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..a675fc6d954f --- /dev/null +++ b/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/rest-testing/src/main/webapp/WEB-INF/web.xml b/rest-testing/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/rest-testing/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java b/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java new file mode 100644 index 000000000000..bc0702118dc9 --- /dev/null +++ b/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java @@ -0,0 +1,85 @@ +package org.baeldung.rest; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientBasicLiveTest { + + private static final String SAMPLE_URL = "http://www.github.com"; + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + // simple request - response + + @Test + public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); + + assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); + } + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBody() throws ClientProtocolException, IOException { + response = instance.execute(new HttpGet(SAMPLE_URL)); + final String bodyAsString = EntityUtils.toString(response.getEntity()); + + assertThat(bodyAsString, notNullValue()); + } + +} diff --git a/rest-testing/src/test/resources/.gitignore b/rest-testing/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/rest-testing/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 3130bcdcd3082aa226c1ba8feeed0c8e69c8b99d Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 16:12:53 +0200 Subject: [PATCH 391/796] testing work --- rest-testing/pom.xml | 22 +++-- .../java/org/baeldung/rest/ConvertUtil.java | 23 +++++ .../java/org/baeldung/rest/GitHubUser.java | 21 +++++ .../baeldung/rest/GithubBasicLiveTest.java | 64 ++++++++++++++ .../rest/HttpClientBasicLiveTest.java | 85 ------------------- .../java/org/baeldung/rest/RetrieveUtil.java | 26 ++++++ 6 files changed, 151 insertions(+), 90 deletions(-) create mode 100644 rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java create mode 100644 rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java create mode 100644 rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java delete mode 100644 rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java create mode 100644 rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index bd3133df3b6a..a789c5781606 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -15,7 +15,13 @@ guava ${guava.version} - + + + commons-io + commons-io + 2.4 + + org.apache.commons commons-lang3 @@ -35,6 +41,14 @@ ${httpcore.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + @@ -125,11 +139,9 @@ 4.0.0.RELEASE - 3.2.0.RELEASE - - 4.3.0.Final - 5.1.27 + + 2.3.0 1.7.5 diff --git a/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java b/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java new file mode 100644 index 000000000000..a8b325d9a0c5 --- /dev/null +++ b/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java @@ -0,0 +1,23 @@ +package org.baeldung.rest; + +import java.io.IOException; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Preconditions; + +public class ConvertUtil { + + public static String convertResourceToJson(final T resource) throws IOException { + Preconditions.checkNotNull(resource); + + return new ObjectMapper().writeValueAsString(resource); + } + + public static T convertJsonToResource(final String json, final Class clazzOfResource) throws IOException { + Preconditions.checkNotNull(json); + Preconditions.checkNotNull(clazzOfResource); + + return new ObjectMapper().readValue(json, clazzOfResource); + } + +} diff --git a/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java b/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java new file mode 100644 index 000000000000..73c9677377eb --- /dev/null +++ b/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java @@ -0,0 +1,21 @@ +package org.baeldung.rest; + +public class GitHubUser { + + private String login; + + public GitHubUser() { + super(); + } + + // API + + public String getLogin() { + return login; + } + + public void setLogin(final String login) { + this.login = login; + } + +} diff --git a/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java b/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java new file mode 100644 index 000000000000..acac82c8f47f --- /dev/null +++ b/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java @@ -0,0 +1,64 @@ +package org.baeldung.rest; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.HttpClientBuilder; +import org.hamcrest.Matchers; +import org.junit.Test; + +public class GithubBasicLiveTest { + + // simple request - response + + @Test + public void givenUserDoesNotExists_whenUserInfoIsRetrieved_then404IsReceived() throws ClientProtocolException, IOException { + // Given + final String name = randomAlphabetic(8); + final HttpUriRequest request = new HttpGet("https://api.github.com/users/" + name); + + // When + final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request); + + // Then + assertThat(httpResponse.getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_NOT_FOUND)); + } + + @Test + public void givenRequestWithNoAcceptHeader_whenRequestIsExecuted_thenDefaultResponseContentTypeIsJson() throws ClientProtocolException, IOException { + // Given + final String jsonMimeType = "application/json"; + final HttpUriRequest request = new HttpGet("https://api.github.com/users/eugenp"); + + // When + final HttpResponse response = HttpClientBuilder.create().build().execute(request); + + // Then + final String mimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); + assertEquals(jsonMimeType, mimeType); + } + + @Test + public void givenUserExists_whenUserInformationIsRetrieved_thenRetrievedResourceIsCorrect() throws ClientProtocolException, IOException { + // Given + final HttpUriRequest request = new HttpGet("https://api.github.com/users/eugenp"); + + // When + final HttpResponse response = HttpClientBuilder.create().build().execute(request); + + // Then + final GitHubUser resource = RetrieveUtil.retrieveResourceFromResponse(response, GitHubUser.class); + assertThat("eugenp", Matchers.is(resource.getLogin())); + } + +} diff --git a/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java b/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java deleted file mode 100644 index bc0702118dc9..000000000000 --- a/rest-testing/src/test/java/org/baeldung/rest/HttpClientBasicLiveTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.baeldung.rest; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.entity.ContentType; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class HttpClientBasicLiveTest { - - private static final String SAMPLE_URL = "http://www.github.com"; - - private CloseableHttpClient instance; - - private CloseableHttpResponse response; - - @Before - public final void before() { - instance = HttpClientBuilder.create().build(); - } - - @After - public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } - } - - // tests - - // simple request - response - - @Test - public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - final int statusCode = response.getStatusLine().getStatusCode(); - assertThat(statusCode, equalTo(HttpStatus.SC_OK)); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectMimeType() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - final String contentMimeType = ContentType.getOrDefault(response.getEntity()).getMimeType(); - - assertThat(contentMimeType, equalTo(ContentType.TEXT_HTML.getMimeType())); - } - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectBody() throws ClientProtocolException, IOException { - response = instance.execute(new HttpGet(SAMPLE_URL)); - final String bodyAsString = EntityUtils.toString(response.getEntity()); - - assertThat(bodyAsString, notNullValue()); - } - -} diff --git a/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java b/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java new file mode 100644 index 000000000000..61506d4ba4a5 --- /dev/null +++ b/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java @@ -0,0 +1,26 @@ +package org.baeldung.rest; + +import java.io.IOException; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpResponse; + +import com.google.common.base.Preconditions; + +public class RetrieveUtil { + + public static String retrieveJsonFromResponse(final HttpResponse response) throws IOException { + Preconditions.checkNotNull(response); + + return IOUtils.toString(response.getEntity().getContent()); + } + + public static T retrieveResourceFromResponse(final HttpResponse response, final Class clazz) throws IOException { + Preconditions.checkNotNull(response); + Preconditions.checkNotNull(clazz); + + final String jsonFromResponse = retrieveJsonFromResponse(response); + return ConvertUtil.convertJsonToResource(jsonFromResponse, clazz); + } + +} From b08f53ce48345954137cf5fca5166672b541ff57 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 16:45:51 +0200 Subject: [PATCH 392/796] testing work and minor doc cleanup --- rest-testing/README.md | 1 + .../java/org/baeldung/rest/ConvertUtil.java | 23 ------------------- .../java/org/baeldung/rest/RetrieveUtil.java | 19 ++++++--------- 3 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java diff --git a/rest-testing/README.md b/rest-testing/README.md index cc476d097b2b..db7f0c8a86dd 100644 --- a/rest-testing/README.md +++ b/rest-testing/README.md @@ -4,3 +4,4 @@ ### Relevant Articles: +- [Test a REST API with Java](http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/) diff --git a/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java b/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java deleted file mode 100644 index a8b325d9a0c5..000000000000 --- a/rest-testing/src/test/java/org/baeldung/rest/ConvertUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.rest; - -import java.io.IOException; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Preconditions; - -public class ConvertUtil { - - public static String convertResourceToJson(final T resource) throws IOException { - Preconditions.checkNotNull(resource); - - return new ObjectMapper().writeValueAsString(resource); - } - - public static T convertJsonToResource(final String json, final Class clazzOfResource) throws IOException { - Preconditions.checkNotNull(json); - Preconditions.checkNotNull(clazzOfResource); - - return new ObjectMapper().readValue(json, clazzOfResource); - } - -} diff --git a/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java b/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java index 61506d4ba4a5..75ec3c842cde 100644 --- a/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java +++ b/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java @@ -2,25 +2,20 @@ import java.io.IOException; -import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; -import com.google.common.base.Preconditions; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; public class RetrieveUtil { - public static String retrieveJsonFromResponse(final HttpResponse response) throws IOException { - Preconditions.checkNotNull(response); - - return IOUtils.toString(response.getEntity().getContent()); - } + // API public static T retrieveResourceFromResponse(final HttpResponse response, final Class clazz) throws IOException { - Preconditions.checkNotNull(response); - Preconditions.checkNotNull(clazz); - - final String jsonFromResponse = retrieveJsonFromResponse(response); - return ConvertUtil.convertJsonToResource(jsonFromResponse, clazz); + final String jsonFromResponse = EntityUtils.toString(response.getEntity()); + final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return mapper.readValue(jsonFromResponse, clazz); } } From 361343211be805e69746cdb860370999eeef2d95 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Jan 2014 17:33:10 +0200 Subject: [PATCH 393/796] quick updates and cleanup --- .../main/java/org/baeldung/spring/PersistenceConfig.java | 6 ++++-- spring-hibernate4/pom.xml | 2 +- .../main/java/org/baeldung/spring/PersistenceConfig.java | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java index 4bfc6233d497..a6373f10ec2d 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -5,6 +5,7 @@ import javax.sql.DataSource; import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -53,9 +54,10 @@ public DataSource dataSource() { } @Bean - public HibernateTransactionManager transactionManager() { + @Autowired + public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) { final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); + txManager.setSessionFactory(sessionFactory); return txManager; } diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 45f6dbbe8e9c..fbb4059f1cfe 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -188,7 +188,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 7.0.42 diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index f66e5543169f..aad79bea000d 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -5,6 +5,7 @@ import javax.sql.DataSource; import org.apache.tomcat.dbcp.dbcp.BasicDataSource; +import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -53,9 +54,10 @@ public DataSource restDataSource() { } @Bean - public HibernateTransactionManager transactionManager() { + @Autowired + public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) { final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory().getObject()); + txManager.setSessionFactory(sessionFactory); return txManager; } From 3dcf53244c81c9b913f24e3fcbd0ecf50fb024d7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 3 Jan 2014 01:49:40 +0200 Subject: [PATCH 394/796] new formatter --- eclipse/formatter.xml | 291 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 eclipse/formatter.xml diff --git a/eclipse/formatter.xml b/eclipse/formatter.xml new file mode 100644 index 000000000000..f9bccca6f648 --- /dev/null +++ b/eclipse/formatter.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c0cc59ee4832b8447c7876f529fe53db66a5a7a2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 4 Jan 2014 17:03:29 +0200 Subject: [PATCH 395/796] additional examples --- .../httpclient/HttpClientAuthLiveTest.java | 72 +++++++++++++++++++ .../JacksonPrettyPrintUnitTest.java} | 4 +- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java rename jackson/src/test/java/org/baeldung/jackson/{try1/JacksonTryUnitTest.java => sandbox/JacksonPrettyPrintUnitTest.java} (94%) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java new file mode 100644 index 000000000000..beb5abbeead4 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java @@ -0,0 +1,72 @@ +package org.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientAuthLiveTest { + + private CloseableHttpClient instance; + + private CloseableHttpResponse response; + + @Before + public final void before() { + instance = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + // simple request - response + + @Test + public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { + final CredentialsProvider provider = new BasicCredentialsProvider(); + final AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user1", "user1Pass"); + + provider.setCredentials(scope, credentials); + + instance = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); + + response = instance.execute(new HttpGet("http://localhost:8080/spring-security-mvc-basic-auth/homepage.html")); + + final int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java similarity index 94% rename from jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java rename to jackson/src/test/java/org/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java index 50e470dc298b..a2bff8932095 100644 --- a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonTryUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.try1; +package org.baeldung.jackson.sandbox; import java.io.IOException; import java.nio.ByteBuffer; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -public class JacksonTryUnitTest { +public class JacksonPrettyPrintUnitTest { @Test public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { From 1af3eb4b1f094bc70838858748d03fc7da23d224 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 13:34:53 +0200 Subject: [PATCH 396/796] pagination work --- .../org/baeldung/persistence/IOperations.java | 10 ++++ .../service/common/AbstractService.java | 13 +++++ .../web/controller/FooController.java | 30 ++++++++---- .../RestResponseEntityExceptionHandler.java | 3 +- .../MyResourceNotFoundException.java | 21 +++++++++ .../baeldung/web/util/RestPreconditions.java | 47 +++++++++++++++++++ 6 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java index 3c6f86a78bd7..d4f3f0982cdf 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/IOperations.java @@ -3,12 +3,22 @@ import java.io.Serializable; import java.util.List; +import org.springframework.data.domain.Page; + public interface IOperations { + // read - one + T findOne(final long id); + // read - all + List findAll(); + Page findPaginated(int page, int size); + + // write + T create(final T entity); T update(final T entity); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 406a958eec24..5987bbae5f8a 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -4,6 +4,8 @@ import java.util.List; import org.baeldung.persistence.IOperations; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.transaction.annotation.Transactional; @@ -12,18 +14,29 @@ @Transactional public abstract class AbstractService implements IOperations { + // read - one + @Override @Transactional(readOnly = true) public T findOne(final long id) { return getDao().findOne(id); } + // read - all + @Override @Transactional(readOnly = true) public List findAll() { return Lists.newArrayList(getDao().findAll()); } + @Override + public Page findPaginated(final int page, final int size) { + return getDao().findAll(new PageRequest(page, size)); + } + + // write + @Override public T create(final T entity) { return getDao().save(entity); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index dd87dffc4c2e..62306ab80849 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -8,17 +8,21 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; +import org.baeldung.web.exception.MyResourceNotFoundException; import org.baeldung.web.util.LinkUtil; import org.baeldung.web.util.ResourceCreated; +import org.baeldung.web.util.RestPreconditions; import org.baeldung.web.util.SingleResourceRetrieved; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.util.UriComponentsBuilder; @@ -42,29 +46,39 @@ public FooController() { // API - // read + // read - one @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - return service.findOne(id); + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; } + // read - all + @RequestMapping(method = RequestMethod.GET) @ResponseBody public List findAll() { return service.findAll(); } - @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) @ResponseBody - public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.findOne(id)); + public List findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); - return resourceById; + final Page resultPage = service.findPaginated(page, size); + if (page > resultPage.getTotalPages()) { + throw new MyResourceNotFoundException(); + } + // eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, page, resultPage.getTotalPages(), size)); + + return resultPage.getContent(); } + // discover + @RequestMapping(value = "admin", method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java index 95e8bcb677d1..be2d4331c1df 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -2,6 +2,7 @@ import javax.persistence.EntityNotFoundException; +import org.baeldung.web.exception.MyResourceNotFoundException; import org.hibernate.exception.ConstraintViolationException; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; @@ -50,7 +51,7 @@ protected ResponseEntity handleMethodArgumentNotValid(final MethodArgume // 404 - @ExceptionHandler(value = { EntityNotFoundException.class }) + @ExceptionHandler(value = { EntityNotFoundException.class, MyResourceNotFoundException.class }) protected ResponseEntity handleBadRequest(final EntityNotFoundException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-security-rest-full/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java new file mode 100644 index 000000000000..14b61f9832e3 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java @@ -0,0 +1,21 @@ +package org.baeldung.web.exception; + +public final class MyResourceNotFoundException extends RuntimeException { + + public MyResourceNotFoundException() { + super(); + } + + public MyResourceNotFoundException(final String message, final Throwable cause) { + super(message, cause); + } + + public MyResourceNotFoundException(final String message) { + super(message); + } + + public MyResourceNotFoundException(final Throwable cause) { + super(cause); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java new file mode 100644 index 000000000000..18cb8219ec08 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java @@ -0,0 +1,47 @@ +package org.baeldung.web.util; + +import org.baeldung.web.exception.MyResourceNotFoundException; +import org.springframework.http.HttpStatus; + +/** + * Simple static methods to be called at the start of your own methods to verify correct arguments and state. If the Precondition fails, an {@link HttpStatus} code is thrown + */ +public final class RestPreconditions { + + private RestPreconditions() { + throw new AssertionError(); + } + + // API + + /** + * Check if some value was found, otherwise throw exception. + * + * @param expression + * has value true if found, otherwise false + * @throws MyResourceNotFoundException + * if expression is false, means value not found. + */ + public static void checkFound(final boolean expression) { + if (!expression) { + throw new MyResourceNotFoundException(); + } + } + + /** + * Check if some value was found, otherwise throw exception. + * + * @param expression + * has value true if found, otherwise false + * @throws MyResourceNotFoundException + * if expression is false, means value not found. + */ + public static T checkFound(final T resource) { + if (resource == null) { + throw new MyResourceNotFoundException(); + } + + return resource; + } + +} From 33fee76a329a09c276454c199bb24a9e07876b86 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 14:17:38 +0200 Subject: [PATCH 397/796] pagination work --- .../web/controller/FooController.java | 3 +- ...sultsRetrievedDiscoverabilityListener.java | 107 ++++++++++++++++++ .../PaginatedResultsRetrievedEvent.java | 67 +++++++++++ .../java/org/baeldung/web/util/LinkUtil.java | 6 + 4 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 62306ab80849..167f2549d045 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -9,6 +9,7 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.web.exception.MyResourceNotFoundException; +import org.baeldung.web.hateoas.PaginatedResultsRetrievedEvent; import org.baeldung.web.util.LinkUtil; import org.baeldung.web.util.ResourceCreated; import org.baeldung.web.util.RestPreconditions; @@ -72,7 +73,7 @@ public List findPaginated(@RequestParam("page") final int page, @RequestPar if (page > resultPage.getTotalPages()) { throw new MyResourceNotFoundException(); } - // eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, page, resultPage.getTotalPages(), size)); + eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, page, resultPage.getTotalPages(), size)); return resultPage.getContent(); } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..5d24a38ccbb2 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -0,0 +1,107 @@ +package org.baeldung.web.hateoas; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.web.util.LinkUtil; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriComponentsBuilder; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@SuppressWarnings({ "rawtypes" }) +@Component +class PaginatedResultsRetrievedDiscoverabilityListener implements ApplicationListener { + + private static final String PAGE = "page"; + + public PaginatedResultsRetrievedDiscoverabilityListener() { + super(); + } + + // API + + @Override + public final void onApplicationEvent(final PaginatedResultsRetrievedEvent ev) { + Preconditions.checkNotNull(ev); + + addLinkHeaderOnPagedResourceRetrieval(ev.getUriBuilder(), ev.getResponse(), ev.getClazz(), ev.getPage(), ev.getTotalPages(), ev.getPageSize()); + } + + // - note: at this point, the URI is transformed into plural (added `s`) in a hardcoded way - this will change in the future + final void addLinkHeaderOnPagedResourceRetrieval(final UriComponentsBuilder uriBuilder, final HttpServletResponse response, final Class clazz, final int page, final int totalPages, final int pageSize) { + plural(uriBuilder, clazz); + + final StringBuilder linkHeader = new StringBuilder(); + if (hasNextPage(page, totalPages)) { + final String uriForNextPage = constructNextPageUri(uriBuilder, page, pageSize); + linkHeader.append(LinkUtil.createLinkHeader(uriForNextPage, LinkUtil.REL_NEXT)); + } + if (hasPreviousPage(page)) { + final String uriForPrevPage = constructPrevPageUri(uriBuilder, page, pageSize); + appendCommaIfNecessary(linkHeader); + linkHeader.append(LinkUtil.createLinkHeader(uriForPrevPage, LinkUtil.REL_PREV)); + } + if (hasFirstPage(page)) { + final String uriForFirstPage = constructFirstPageUri(uriBuilder, pageSize); + appendCommaIfNecessary(linkHeader); + linkHeader.append(LinkUtil.createLinkHeader(uriForFirstPage, LinkUtil.REL_FIRST)); + } + if (hasLastPage(page, totalPages)) { + final String uriForLastPage = constructLastPageUri(uriBuilder, totalPages, pageSize); + appendCommaIfNecessary(linkHeader); + linkHeader.append(LinkUtil.createLinkHeader(uriForLastPage, LinkUtil.REL_LAST)); + } + + if (linkHeader.length() > 0) { + response.addHeader(HttpHeaders.LINK, linkHeader.toString()); + } + } + + final String constructNextPageUri(final UriComponentsBuilder uriBuilder, final int page, final int size) { + return uriBuilder.replaceQueryParam(PAGE, page + 1).replaceQueryParam("size", size).build().encode().toUriString(); + } + + final String constructPrevPageUri(final UriComponentsBuilder uriBuilder, final int page, final int size) { + return uriBuilder.replaceQueryParam(PAGE, page - 1).replaceQueryParam("size", size).build().encode().toUriString(); + } + + final String constructFirstPageUri(final UriComponentsBuilder uriBuilder, final int size) { + return uriBuilder.replaceQueryParam(PAGE, 0).replaceQueryParam("size", size).build().encode().toUriString(); + } + + final String constructLastPageUri(final UriComponentsBuilder uriBuilder, final int totalPages, final int size) { + return uriBuilder.replaceQueryParam(PAGE, totalPages).replaceQueryParam("size", size).build().encode().toUriString(); + } + + final boolean hasNextPage(final int page, final int totalPages) { + return page < totalPages - 1; + } + + final boolean hasPreviousPage(final int page) { + return page > 0; + } + + final boolean hasFirstPage(final int page) { + return hasPreviousPage(page); + } + + final boolean hasLastPage(final int page, final int totalPages) { + return totalPages > 1 && hasNextPage(page, totalPages); + } + + final void appendCommaIfNecessary(final StringBuilder linkHeader) { + if (linkHeader.length() > 0) { + linkHeader.append(", "); + } + } + + // template + + protected void plural(final UriComponentsBuilder uriBuilder, final Class clazz) { + final String resourceName = clazz.getSimpleName() + "s"; + uriBuilder.path("/" + resourceName); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java new file mode 100644 index 000000000000..a9fe55ed3f1a --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java @@ -0,0 +1,67 @@ +package org.baeldung.web.hateoas; + +import java.io.Serializable; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; +import org.springframework.web.util.UriComponentsBuilder; + +/** + * Event that is fired when a paginated search is performed. + *

+ * This event object contains all the information needed to create the URL for the paginated results + * + * @param + * Type of the result that is being handled (commonly Entities). + */ +public final class PaginatedResultsRetrievedEvent extends ApplicationEvent { + private final UriComponentsBuilder uriBuilder; + private final HttpServletResponse response; + private final int page; + private final int totalPages; + private final int pageSize; + + public PaginatedResultsRetrievedEvent(final Class clazz, final UriComponentsBuilder uriBuilderToSet, final HttpServletResponse responseToSet, final int pageToSet, final int totalPagesToSet, final int pageSizeToSet) { + super(clazz); + + uriBuilder = uriBuilderToSet; + response = responseToSet; + page = pageToSet; + totalPages = totalPagesToSet; + pageSize = pageSizeToSet; + } + + // API + + public final UriComponentsBuilder getUriBuilder() { + return uriBuilder; + } + + public final HttpServletResponse getResponse() { + return response; + } + + public final int getPage() { + return page; + } + + public final int getTotalPages() { + return totalPages; + } + + public final int getPageSize() { + return pageSize; + } + + /** + * The object on which the Event initially occurred. + * + * @return The object on which the Event initially occurred. + */ + @SuppressWarnings("unchecked") + public final Class getClazz() { + return (Class) getSource(); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java index 9e8979e4bded..b2137aeeff08 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/LinkUtil.java @@ -7,6 +7,12 @@ */ public final class LinkUtil { + public static final String REL_COLLECTION = "collection"; + public static final String REL_NEXT = "next"; + public static final String REL_PREV = "prev"; + public static final String REL_FIRST = "first"; + public static final String REL_LAST = "last"; + private LinkUtil() { throw new AssertionError(); } From c7ce725cf6d952a01a2d503e1fb7295fdf4f1cf9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 17:11:38 +0200 Subject: [PATCH 398/796] testing work --- spring-security-rest-full/pom.xml | 604 +++++++++--------- .../web/controller/FooController.java | 1 - .../baeldung/common/web/AbstractLiveTest.java | 72 +++ .../java/org/baeldung/web/FooLiveTest.java | 12 + 4 files changed, 389 insertions(+), 300 deletions(-) create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 0270d43096b7..997b99ffdf44 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -1,301 +1,307 @@ - - 4.0.0 - org.baeldung - spring-security-rest-full - 0.1-SNAPSHOT - - spring-security-rest-full - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework.data - spring-data-jpa - ${spring-data-jpa.version} - - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - org.javassist - javassist - 3.18.0-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-security-rest-full - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 4.0.0.RELEASE - 3.2.0.RELEASE - - - 4.3.0.Final - 5.1.27 - 1.4.3.RELEASE - - - - 2.2.3 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - - - 3.1 - 2.4 - 2.16 - 1.4.5 - - + + 4.0.0 + org.baeldung + spring-security-rest-full + 0.1-SNAPSHOT + + spring-security-rest-full + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework.data + spring-data-jpa + ${spring-data-jpa.version} + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.javassist + javassist + 3.18.0-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + com.jayway.restassured + rest-assured + 2.1.0 + test + + + + + + spring-security-rest-full + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + 1.4.3.RELEASE + + + + 2.2.3 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 1.4.5 + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 167f2549d045..7a9889ae461a 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -68,7 +68,6 @@ public List findAll() { @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) @ResponseBody public List findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - final Page resultPage = service.findPaginated(page, size); if (page > resultPage.getTotalPages()) { throw new MyResourceNotFoundException(); diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java new file mode 100644 index 000000000000..c205997a0808 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -0,0 +1,72 @@ +package org.baeldung.common.web; + +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; + +import java.io.Serializable; +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Preconditions; +import com.jayway.restassured.RestAssured; +import com.jayway.restassured.response.Response; +import com.jayway.restassured.specification.RequestSpecification; + +public abstract class AbstractLiveTest { + + protected final Class clazz; + + public AbstractLiveTest(final Class clazzToSet) { + super(); + + Preconditions.checkNotNull(clazzToSet); + clazz = clazzToSet; + } + + // tests + + // find - one + + // find - all + + // find - all - paginated + + @Test + public void whenResourcesAreRetrievedPaged_then200IsReceived() { + final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); + + assertThat(response.getStatusCode(), is(200)); + } + + @Test + public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { + final Response response = givenAuth().get(getFooURL() + "?page=" + randomNumeric(5) + "&size=10"); + + assertThat(response.getStatusCode(), is(404)); + } + + @Test + public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { + // restTemplate.createResource(); + + final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); + + assertFalse(response.body().as(List.class).isEmpty()); + } + + // count + + // template method + + private String getFooURL() { + return "http://localhost:8080/spring-security-rest-full/foos"; + } + + protected final RequestSpecification givenAuth() { + return RestAssured.given().auth().preemptive().basic("user1", "user1Pass"); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java new file mode 100644 index 000000000000..18f0659af6ed --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java @@ -0,0 +1,12 @@ +package org.baeldung.web; + +import org.baeldung.common.web.AbstractLiveTest; +import org.baeldung.persistence.model.Foo; + +public class FooLiveTest extends AbstractLiveTest { + + public FooLiveTest() { + super(Foo.class); + } + +} From bce77ee846b07cc278aaa0c8df244b4d589ad27f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 18:21:51 +0200 Subject: [PATCH 399/796] pagination work --- spring-security-rest-full/pom.xml | 7 ++ .../web/controller/FooController.java | 17 +--- .../web/controller/RootController.java | 37 +++++++ .../RestResponseEntityExceptionHandler.java | 12 ++- ...sultsRetrievedDiscoverabilityListener.java | 2 +- .../baeldung/common/web/AbstractLiveTest.java | 82 +++++++++++++++- .../java/org/baeldung/spring/ConfigTest.java | 17 ++++ .../java/org/baeldung/test/IMarshaller.java | 15 +++ .../org/baeldung/test/JacksonMarshaller.java | 97 +++++++++++++++++++ .../java/org/baeldung/web/FooLiveTest.java | 16 +++ .../baeldung/web/util/HTTPLinkHeaderUtil.java | 69 +++++++++++++ 11 files changed, 347 insertions(+), 24 deletions(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/spring/ConfigTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/test/IMarshaller.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 997b99ffdf44..3eb5bc9bd6ce 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -159,6 +159,13 @@ + + org.springframework + spring-test + ${org.springframework.version} + test + + junit junit-dep diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 7a9889ae461a..5e05db105603 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,6 +1,5 @@ package org.baeldung.web.controller; -import java.net.URI; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -10,7 +9,6 @@ import org.baeldung.persistence.service.IFooService; import org.baeldung.web.exception.MyResourceNotFoundException; import org.baeldung.web.hateoas.PaginatedResultsRetrievedEvent; -import org.baeldung.web.util.LinkUtil; import org.baeldung.web.util.ResourceCreated; import org.baeldung.web.util.RestPreconditions; import org.baeldung.web.util.SingleResourceRetrieved; @@ -27,7 +25,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.util.UriComponentsBuilder; -import org.springframework.web.util.UriTemplate; import com.google.common.base.Preconditions; @@ -77,21 +74,9 @@ public List findPaginated(@RequestParam("page") final int page, @RequestPar return resultPage.getContent(); } - // discover - - @RequestMapping(value = "admin", method = RequestMethod.GET) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { - final String rootUri = request.getRequestURL().toString(); - - final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); - final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); - response.addHeader("Link", linkToFoo); - } - // write - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { Preconditions.checkNotNull(resource); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java new file mode 100644 index 000000000000..0f35a2933871 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java @@ -0,0 +1,37 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.web.util.LinkUtil; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriTemplate; + +@Controller +public class RootController { + + public RootController() { + super(); + } + + // API + + // discover + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java index be2d4331c1df..a465a82d75f1 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -28,8 +28,14 @@ public RestResponseEntityExceptionHandler() { // 400 - @ExceptionHandler({ ConstraintViolationException.class, DataIntegrityViolationException.class }) - public ResponseEntity handleBadRequest(final RuntimeException ex, final WebRequest request) { + @ExceptionHandler({ ConstraintViolationException.class }) + public ResponseEntity handleBadRequest(final ConstraintViolationException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); + } + + @ExceptionHandler({ DataIntegrityViolationException.class }) + public ResponseEntity handleBadRequest(final DataIntegrityViolationException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); } @@ -52,7 +58,7 @@ protected ResponseEntity handleMethodArgumentNotValid(final MethodArgume // 404 @ExceptionHandler(value = { EntityNotFoundException.class, MyResourceNotFoundException.class }) - protected ResponseEntity handleBadRequest(final EntityNotFoundException ex, final WebRequest request) { + protected ResponseEntity handleNotFound(final RuntimeException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java index 5d24a38ccbb2..dc65c754c6b1 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -100,7 +100,7 @@ final void appendCommaIfNecessary(final StringBuilder linkHeader) { // template protected void plural(final UriComponentsBuilder uriBuilder, final Class clazz) { - final String resourceName = clazz.getSimpleName() + "s"; + final String resourceName = clazz.getSimpleName().toLowerCase() + "s"; uriBuilder.path("/" + resourceName); } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java index c205997a0808..b16c6ca041ab 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -1,16 +1,22 @@ package org.baeldung.common.web; import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import static org.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import java.io.Serializable; import java.util.List; +import org.baeldung.test.IMarshaller; import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; import com.jayway.restassured.specification.RequestSpecification; @@ -19,6 +25,9 @@ public abstract class AbstractLiveTest { protected final Class clazz; + @Autowired + protected IMarshaller marshaller; + public AbstractLiveTest(final Class clazzToSet) { super(); @@ -36,31 +45,96 @@ public AbstractLiveTest(final Class clazzToSet) { @Test public void whenResourcesAreRetrievedPaged_then200IsReceived() { - final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); + final Response response = givenAuth().get(getFooURL() + "?page=0&size=10"); assertThat(response.getStatusCode(), is(200)); } @Test public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { - final Response response = givenAuth().get(getFooURL() + "?page=" + randomNumeric(5) + "&size=10"); + final String url = getFooURL() + "?page=" + randomNumeric(5) + "&size=10"; + final Response response = givenAuth().get(url); assertThat(response.getStatusCode(), is(404)); } @Test + // @Ignore("create is not done yet") public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { - // restTemplate.createResource(); + create(); - final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); + final Response response = givenAuth().get(getFooURL() + "?page=0&size=10"); assertFalse(response.body().as(List.class).isEmpty()); } + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenSecondPageIsNext() { + final Response response = givenAuth().get(getFooURL() + "?page=0&size=2"); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertEquals(getFooURL() + "?page=1&size=2", uriToNextPage); + } + + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenNoPreviousPage() { + final Response response = givenAuth().get(getFooURL() + "?page=0&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertNull(uriToPrevPage); + } + + @Test + public void whenSecondPageOfResourcesAreRetrieved_thenFirstPageIsPrevious() { + create(); + create(); + + final Response response = givenAuth().get(getFooURL() + "?page=1&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertEquals(getFooURL() + "?page=0&size=2", uriToPrevPage); + } + + @Test + public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { + final Response first = givenAuth().get(getFooURL() + "?page=0&size=2"); + final String uriToLastPage = extractURIByRel(first.getHeader(HttpHeaders.LINK), "last"); + + final Response response = givenAuth().get(uriToLastPage); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertNull(uriToNextPage); + } + // count // template method + public abstract void create(); + + protected final void create(final T resource) { + createAsUri(resource); + } + + final String createAsUri(final T resource) { + final Response response = createAsResponse(resource); + Preconditions.checkState(response.getStatusCode() == 201, "create operation: " + response.getStatusCode()); + + final String locationOfCreatedResource = response.getHeader(HttpHeaders.LOCATION); + Preconditions.checkNotNull(locationOfCreatedResource); + return locationOfCreatedResource; + } + + final Response createAsResponse(final T resource) { + Preconditions.checkNotNull(resource); + final RequestSpecification givenAuthenticated = givenAuth(); + + final String resourceAsString = marshaller.encode(resource); + return givenAuthenticated.contentType(marshaller.getMime()).body(resourceAsString).post(getFooURL()); + } + + // + private String getFooURL() { return "http://localhost:8080/spring-security-rest-full/foos"; } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/spring/ConfigTest.java b/spring-security-rest-full/src/test/java/org/baeldung/spring/ConfigTest.java new file mode 100644 index 000000000000..56f3de6cb01e --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/spring/ConfigTest.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.test") +public class ConfigTest extends WebMvcConfigurerAdapter { + + public ConfigTest() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/IMarshaller.java b/spring-security-rest-full/src/test/java/org/baeldung/test/IMarshaller.java new file mode 100644 index 000000000000..1eefbe87898f --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/IMarshaller.java @@ -0,0 +1,15 @@ +package org.baeldung.test; + +import java.util.List; + +public interface IMarshaller { + + String encode(final T entity); + + T decode(final String entityAsString, final Class clazz); + + List decodeList(final String entitiesAsString, final Class clazz); + + String getMime(); + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java new file mode 100644 index 000000000000..99deafaee499 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java @@ -0,0 +1,97 @@ +package org.baeldung.test; + +import java.io.IOException; +import java.util.List; + +import org.baeldung.persistence.model.Foo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Preconditions; + +@Component +public final class JacksonMarshaller implements IMarshaller { + private final Logger logger = LoggerFactory.getLogger(JacksonMarshaller.class); + + private final ObjectMapper objectMapper; + + public JacksonMarshaller() { + super(); + + objectMapper = new ObjectMapper(); + } + + // API + + @Override + public final String encode(final T resource) { + Preconditions.checkNotNull(resource); + String entityAsJSON = null; + try { + entityAsJSON = objectMapper.writeValueAsString(resource); + } catch (final JsonParseException parseEx) { + logger.error("", parseEx); + } catch (final JsonMappingException mappingEx) { + logger.error("", mappingEx); + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entityAsJSON; + } + + @Override + public final T decode(final String resourceAsString, final Class clazz) { + Preconditions.checkNotNull(resourceAsString); + + T entity = null; + try { + entity = objectMapper.readValue(resourceAsString, clazz); + } catch (final JsonParseException parseEx) { + logger.error("", parseEx); + } catch (final JsonMappingException mappingEx) { + logger.error("", mappingEx); + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entity; + } + + @SuppressWarnings("unchecked") + @Override + public final List decodeList(final String resourcesAsString, final Class clazz) { + Preconditions.checkNotNull(resourcesAsString); + + List entities = null; + try { + if (clazz.equals(Foo.class)) { + entities = objectMapper.readValue(resourcesAsString, new TypeReference>() { + // ... + }); + } else { + entities = objectMapper.readValue(resourcesAsString, List.class); + } + } catch (final JsonParseException parseEx) { + logger.error("", parseEx); + } catch (final JsonMappingException mappingEx) { + logger.error("", mappingEx); + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entities; + } + + @Override + public final String getMime() { + return MediaType.APPLICATION_JSON.toString(); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java index 18f0659af6ed..b158b223769d 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java @@ -1,12 +1,28 @@ package org.baeldung.web; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + import org.baeldung.common.web.AbstractLiveTest; import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.ConfigTest; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class) public class FooLiveTest extends AbstractLiveTest { public FooLiveTest() { super(Foo.class); } + // API + + @Override + public final void create() { + create(new Foo(randomAlphabetic(6))); + } + } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java b/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java new file mode 100644 index 000000000000..bb3919eacc20 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java @@ -0,0 +1,69 @@ +package org.baeldung.web.util; + +import java.util.List; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; + +public final class HTTPLinkHeaderUtil { + + private HTTPLinkHeaderUtil() { + throw new AssertionError(); + } + + // + + /** + * ex.
+ * https://api.github.com/users/steveklabnik/gists?page=2>; rel="next", ; rel="last" + */ + public static List extractAllURIs(final String linkHeader) { + Preconditions.checkNotNull(linkHeader); + + final List linkHeaders = Lists.newArrayList(); + final String[] links = linkHeader.split(", "); + for (final String link : links) { + final int positionOfSeparator = link.indexOf(';'); + linkHeaders.add(link.substring(1, positionOfSeparator - 1)); + } + + return linkHeaders; + } + + public static String extractURIByRel(final String linkHeader, final String rel) { + if (linkHeader == null) { + return null; + } + + String uriWithSpecifiedRel = null; + final String[] links = linkHeader.split(", "); + String linkRelation = null; + for (final String link : links) { + final int positionOfSeparator = link.indexOf(';'); + linkRelation = link.substring(positionOfSeparator + 1, link.length()).trim(); + if (extractTypeOfRelation(linkRelation).equals(rel)) { + uriWithSpecifiedRel = link.substring(1, positionOfSeparator - 1); + break; + } + } + + return uriWithSpecifiedRel; + } + + static Object extractTypeOfRelation(final String linkRelation) { + final int positionOfEquals = linkRelation.indexOf('='); + return linkRelation.substring(positionOfEquals + 2, linkRelation.length() - 1).trim(); + } + + /** + * ex.
+ * https://api.github.com/users/steveklabnik/gists?page=2>; rel="next" + */ + public static String extractSingleURI(final String linkHeader) { + Preconditions.checkNotNull(linkHeader); + final int positionOfSeparator = linkHeader.indexOf(';'); + + return linkHeader.substring(1, positionOfSeparator - 1); + } + +} From 8e647b888413d1dd96dbcb2a7bc413d3eec281c8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 18:22:13 +0200 Subject: [PATCH 400/796] minor fix --- .../src/test/java/org/baeldung/common/web/AbstractLiveTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java index b16c6ca041ab..d538a94645d1 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -59,7 +59,6 @@ public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { } @Test - // @Ignore("create is not done yet") public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { create(); From 00ef9f688cc863547c4cae628540d271bebed325 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 18:25:01 +0200 Subject: [PATCH 401/796] minor doc work --- spring-security-rest-full/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index a2b7dedbd8d0..59cf865b9a12 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -4,7 +4,8 @@ ### Relevant Articles: -- [Spring Security Expressions � hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) +- [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) +- [REST Pagination in Spring](http://www.baeldung.com/2012/01/18/rest-pagination-in-spring/) ### Build the Project From 71122adb3ee028d27d9e32cd2fc69d334f904c66 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 19:35:19 +0200 Subject: [PATCH 402/796] further HATEOAS work --- spring-security-rest-full/README.md | 2 ++ .../web/controller/FooController.java | 3 +- .../baeldung/web/hateoas/ResourceCreated.java | 33 +++++++++++++++++++ .../web/hateoas/SingleResourceRetrieved.java | 26 +++++++++++++++ ...ourceRetrievedDiscoverabilityListener.java | 3 +- .../baeldung/common/web/AbstractLiveTest.java | 18 +++++++++- .../java/org/baeldung/web/FooLiveTest.java | 5 +++ 7 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 59cf865b9a12..05586789345c 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -6,6 +6,8 @@ ### Relevant Articles: - [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) - [REST Pagination in Spring](http://www.baeldung.com/2012/01/18/rest-pagination-in-spring/) +- [HATEOAS for a Spring REST Service](http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/) +- [REST API Discoverability and HATEOAS](2011/11/06/restful-web-service-discoverability-part-4/) ### Build the Project diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 5e05db105603..32db49f9a7d0 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -48,8 +48,9 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletRequest request, final HttpServletResponse response) { + public Foo findById(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); return resourceById; } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java new file mode 100644 index 000000000000..3a2c8d31871e --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java @@ -0,0 +1,33 @@ +package org.baeldung.web.hateoas; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfNewResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java new file mode 100644 index 000000000000..8a115a1ff61a --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java @@ -0,0 +1,26 @@ +package org.baeldung.web.hateoas; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java index 61fb601ac903..6be6c08df925 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java @@ -7,6 +7,7 @@ import org.springframework.stereotype.Component; import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; @Component class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { @@ -26,7 +27,7 @@ void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, fi final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); - response.addHeader("Link", linkHeaderValue); + response.addHeader(HttpHeaders.LINK, linkHeaderValue); } } \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java index d538a94645d1..86b934ae1ef4 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -2,6 +2,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import static org.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -12,6 +13,7 @@ import java.util.List; import org.baeldung.test.IMarshaller; +import org.hamcrest.core.AnyOf; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +38,18 @@ public AbstractLiveTest(final Class clazzToSet) { } // tests + @Test + public void whenInvalidPOSTIsSentToValidURIOfResource_thenAllowHeaderListsTheAllowedActions() { + // Given + final String uriOfExistingResource = createAsUri(); + + // When + final Response res = givenAuth().post(uriOfExistingResource); + + // Then + final String allowHeader = res.getHeader(HttpHeaders.ALLOW); + assertThat(allowHeader, AnyOf. anyOf(containsString("GET"), containsString("PUT"), containsString("DELETE"))); + } // find - one @@ -111,11 +125,13 @@ public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { public abstract void create(); + public abstract String createAsUri(); + protected final void create(final T resource) { createAsUri(resource); } - final String createAsUri(final T resource) { + protected final String createAsUri(final T resource) { final Response response = createAsResponse(resource); Preconditions.checkState(response.getStatusCode() == 201, "create operation: " + response.getStatusCode()); diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java index b158b223769d..36b30d5e5704 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java @@ -25,4 +25,9 @@ public final void create() { create(new Foo(randomAlphabetic(6))); } + @Override + public final String createAsUri() { + return createAsUri(new Foo(randomAlphabetic(6))); + } + } From c2c3b5ed7449aebad47039a1bbb319221b4f8b3a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 20:25:03 +0200 Subject: [PATCH 403/796] etag work --- .../src/main/webapp/WEB-INF/web.xml | 95 ++++++----- .../common/web/AbstractBasicLiveTest.java | 158 ++++++++++++++++++ .../web/AbstractDiscoverabilityLiveTest.java | 74 ++++++++ .../baeldung/common/web/AbstractLiveTest.java | 100 +---------- .../web/FooDiscoverabilityLiveTest.java | 33 ++++ .../java/org/baeldung/web/FooLiveTest.java | 4 +- 6 files changed, 320 insertions(+), 144 deletions(-) create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml index d88703596fa6..423242852036 100644 --- a/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/web.xml @@ -1,52 +1,59 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring Security REST Application + Spring Security REST Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - / - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - index.html - + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + etagFilter + org.springframework.web.filter.ShallowEtagHeaderFilter + + + etagFilter + /* + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java new file mode 100644 index 000000000000..a8cd7f4f30ab --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java @@ -0,0 +1,158 @@ +package org.baeldung.common.web; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import static org.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.io.Serializable; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; + +import com.google.common.net.HttpHeaders; +import com.jayway.restassured.response.Response; + +public abstract class AbstractBasicLiveTest extends AbstractLiveTest { + + public AbstractBasicLiveTest(final Class clazzToSet) { + super(clazzToSet); + } + + // tests + + @Test + public void givenResourceExists_whenRetrievingResource_thenEtagIsAlsoReturned() { + // Given + final String uriOfResource = createAsUri(); + + // When + final Response findOneResponse = givenAuth().header("Accept", "application/json").get(uriOfResource); + + // Then + assertNotNull(findOneResponse.getHeader(HttpHeaders.ETAG)); + } + + @Test + public void givenResourceWasRetrieved_whenRetrievingAgainWithEtag_thenNotModifiedReturned() { + // Given + final String uriOfResource = createAsUri(); + final Response findOneResponse = givenAuth().header("Accept", "application/json").get(uriOfResource); + final String etagValue = findOneResponse.getHeader(HttpHeaders.ETAG); + + // When + final Response secondFindOneResponse = givenAuth().header("Accept", "application/json").headers("If-None-Match", etagValue).get(uriOfResource); + + // Then + assertTrue(secondFindOneResponse.getStatusCode() == 304); + } + + @Test + @Ignore("No Update operation yet") + public void givenResourceWasRetrievedThenModified_whenRetrievingAgainWithEtag_thenResourceIsReturned() { + // Given + final String uriOfResource = createAsUri(); + final Response findOneResponse = givenAuth().header("Accept", "application/json").get(uriOfResource); + final String etagValue = findOneResponse.getHeader(HttpHeaders.ETAG); + + // existingResource.setName(randomAlphabetic(6)); + // getApi().update(existingResource.setName("randomString")); + + // When + final Response secondFindOneResponse = givenAuth().header("Accept", "application/json").headers("If-None-Match", etagValue).get(uriOfResource); + + // Then + assertTrue(secondFindOneResponse.getStatusCode() == 200); + } + + @Test + @Ignore("Not Yet Implemented By Spring - https://jira.springsource.org/browse/SPR-10164") + public void givenResourceExists_whenRetrievedWithIfMatchIncorrectEtag_then412IsReceived() { + // Given + final String uriOfResource = createAsUri(); + + // When + final Response findOneResponse = givenAuth().header("Accept", "application/json").headers("If-Match", randomAlphabetic(8)).get(uriOfResource); + + // Then + assertTrue(findOneResponse.getStatusCode() == 412); + } + + // find - one + + // find - all + + // find - all - paginated + + @Test + public void whenResourcesAreRetrievedPaged_then200IsReceived() { + final Response response = givenAuth().get(getURL() + "?page=0&size=10"); + + assertThat(response.getStatusCode(), is(200)); + } + + @Test + public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { + final String url = getURL() + "?page=" + randomNumeric(5) + "&size=10"; + final Response response = givenAuth().get(url); + + assertThat(response.getStatusCode(), is(404)); + } + + @Test + public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { + create(); + + final Response response = givenAuth().get(getURL() + "?page=0&size=10"); + + assertFalse(response.body().as(List.class).isEmpty()); + } + + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenSecondPageIsNext() { + final Response response = givenAuth().get(getURL() + "?page=0&size=2"); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertEquals(getURL() + "?page=1&size=2", uriToNextPage); + } + + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenNoPreviousPage() { + final Response response = givenAuth().get(getURL() + "?page=0&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertNull(uriToPrevPage); + } + + @Test + public void whenSecondPageOfResourcesAreRetrieved_thenFirstPageIsPrevious() { + create(); + create(); + + final Response response = givenAuth().get(getURL() + "?page=1&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertEquals(getURL() + "?page=0&size=2", uriToPrevPage); + } + + @Test + public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { + final Response first = givenAuth().get(getURL() + "?page=0&size=2"); + final String uriToLastPage = extractURIByRel(first.getHeader(HttpHeaders.LINK), "last"); + + final Response response = givenAuth().get(uriToLastPage); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertNull(uriToNextPage); + } + + // count + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java new file mode 100644 index 000000000000..4a7c19b6ce59 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java @@ -0,0 +1,74 @@ +package org.baeldung.common.web; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.io.Serializable; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.web.util.HTTPLinkHeaderUtil; +import org.hamcrest.core.AnyOf; +import org.junit.Test; +import org.springframework.http.MediaType; + +import com.google.common.net.HttpHeaders; +import com.jayway.restassured.response.Response; + +public abstract class AbstractDiscoverabilityLiveTest extends AbstractLiveTest { + + public AbstractDiscoverabilityLiveTest(final Class clazzToSet) { + super(clazzToSet); + } + + // tests + + // discoverability + + @Test + public void whenInvalidPOSTIsSentToValidURIOfResource_thenAllowHeaderListsTheAllowedActions() { + // Given + final String uriOfExistingResource = createAsUri(); + + // When + final Response res = givenAuth().post(uriOfExistingResource); + + // Then + final String allowHeader = res.getHeader(HttpHeaders.ALLOW); + assertThat(allowHeader, AnyOf. anyOf(containsString("GET"), containsString("PUT"), containsString("DELETE"))); + } + + @Test + public void whenResourceIsCreated_thenUriOfTheNewlyCreatedResourceIsDiscoverable() { + // When + final Foo newResource = new Foo(randomAlphabetic(6)); + final Response createResp = givenAuth().contentType(MediaType.APPLICATION_JSON_VALUE).body(newResource).post(getURL()); + final String uriOfNewResource = createResp.getHeader(HttpHeaders.LOCATION); + + // Then + final Response response = givenAuth().header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).get(uriOfNewResource); + + final Foo resourceFromServer = response.body().as(Foo.class); + assertThat(newResource, equalTo(resourceFromServer)); + } + + @Test + public void whenResourceIsRetrieved_thenUriToGetAllResourcesIsDiscoverable() { + // Given + final String uriOfExistingResource = createAsUri(); + + // When + final Response getResponse = givenAuth().get(uriOfExistingResource); + + // Then + final String uriToAllResources = HTTPLinkHeaderUtil.extractURIByRel(getResponse.getHeader("Link"), "collection"); + + final Response getAllResponse = givenAuth().get(uriToAllResources); + assertThat(getAllResponse.getStatusCode(), is(200)); + } + + // template method + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java index 86b934ae1ef4..862651266b6f 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -1,20 +1,8 @@ package org.baeldung.common.web; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; -import static org.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - import java.io.Serializable; -import java.util.List; import org.baeldung.test.IMarshaller; -import org.hamcrest.core.AnyOf; -import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; @@ -37,90 +25,6 @@ public AbstractLiveTest(final Class clazzToSet) { clazz = clazzToSet; } - // tests - @Test - public void whenInvalidPOSTIsSentToValidURIOfResource_thenAllowHeaderListsTheAllowedActions() { - // Given - final String uriOfExistingResource = createAsUri(); - - // When - final Response res = givenAuth().post(uriOfExistingResource); - - // Then - final String allowHeader = res.getHeader(HttpHeaders.ALLOW); - assertThat(allowHeader, AnyOf. anyOf(containsString("GET"), containsString("PUT"), containsString("DELETE"))); - } - - // find - one - - // find - all - - // find - all - paginated - - @Test - public void whenResourcesAreRetrievedPaged_then200IsReceived() { - final Response response = givenAuth().get(getFooURL() + "?page=0&size=10"); - - assertThat(response.getStatusCode(), is(200)); - } - - @Test - public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { - final String url = getFooURL() + "?page=" + randomNumeric(5) + "&size=10"; - final Response response = givenAuth().get(url); - - assertThat(response.getStatusCode(), is(404)); - } - - @Test - public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { - create(); - - final Response response = givenAuth().get(getFooURL() + "?page=0&size=10"); - - assertFalse(response.body().as(List.class).isEmpty()); - } - - @Test - public void whenFirstPageOfResourcesAreRetrieved_thenSecondPageIsNext() { - final Response response = givenAuth().get(getFooURL() + "?page=0&size=2"); - - final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); - assertEquals(getFooURL() + "?page=1&size=2", uriToNextPage); - } - - @Test - public void whenFirstPageOfResourcesAreRetrieved_thenNoPreviousPage() { - final Response response = givenAuth().get(getFooURL() + "?page=0&size=2"); - - final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); - assertNull(uriToPrevPage); - } - - @Test - public void whenSecondPageOfResourcesAreRetrieved_thenFirstPageIsPrevious() { - create(); - create(); - - final Response response = givenAuth().get(getFooURL() + "?page=1&size=2"); - - final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); - assertEquals(getFooURL() + "?page=0&size=2", uriToPrevPage); - } - - @Test - public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { - final Response first = givenAuth().get(getFooURL() + "?page=0&size=2"); - final String uriToLastPage = extractURIByRel(first.getHeader(HttpHeaders.LINK), "last"); - - final Response response = givenAuth().get(uriToLastPage); - - final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); - assertNull(uriToNextPage); - } - - // count - // template method public abstract void create(); @@ -145,12 +49,12 @@ final Response createAsResponse(final T resource) { final RequestSpecification givenAuthenticated = givenAuth(); final String resourceAsString = marshaller.encode(resource); - return givenAuthenticated.contentType(marshaller.getMime()).body(resourceAsString).post(getFooURL()); + return givenAuthenticated.contentType(marshaller.getMime()).body(resourceAsString).post(getURL()); } // - private String getFooURL() { + protected String getURL() { return "http://localhost:8080/spring-security-rest-full/foos"; } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java new file mode 100644 index 000000000000..28dfcd372ce3 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java @@ -0,0 +1,33 @@ +package org.baeldung.web; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.common.web.AbstractDiscoverabilityLiveTest; +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.ConfigTest; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class) +public class FooDiscoverabilityLiveTest extends AbstractDiscoverabilityLiveTest { + + public FooDiscoverabilityLiveTest() { + super(Foo.class); + } + + // API + + @Override + public final void create() { + create(new Foo(randomAlphabetic(6))); + } + + @Override + public final String createAsUri() { + return createAsUri(new Foo(randomAlphabetic(6))); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java index 36b30d5e5704..9024ca4f963c 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java @@ -2,7 +2,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.common.web.AbstractLiveTest; +import org.baeldung.common.web.AbstractBasicLiveTest; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.ConfigTest; import org.junit.runner.RunWith; @@ -12,7 +12,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class) -public class FooLiveTest extends AbstractLiveTest { +public class FooLiveTest extends AbstractBasicLiveTest { public FooLiveTest() { super(Foo.class); From a00ccc43ae320b813c19a3b06d1b2dd582d45fc8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 21:08:54 +0200 Subject: [PATCH 404/796] doc work --- spring-security-rest-full/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 05586789345c..88cd3422eaef 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -7,7 +7,8 @@ - [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) - [REST Pagination in Spring](http://www.baeldung.com/2012/01/18/rest-pagination-in-spring/) - [HATEOAS for a Spring REST Service](http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/) -- [REST API Discoverability and HATEOAS](2011/11/06/restful-web-service-discoverability-part-4/) +- [REST API Discoverability and HATEOAS](http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/) +- [ETags for REST with Spring](http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/) ### Build the Project From 52a6046e45a3d4811952d07ca448645a2b7de72a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Jan 2014 23:02:40 +0200 Subject: [PATCH 405/796] minor cleanup work --- .../baeldung/jackson/test/JacksonSerializationUnitTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index e348e60de3fc..f510bd93dacf 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -40,7 +40,7 @@ public final void whenSerializing_thenCorrect() throws JsonParseException, IOExc } @Test - public final void givenNameOfFieldIsChanged_whenSerializing_thenCorrect() throws JsonParseException, IOException { + public final void givenNameOfFieldIsChangedViaAnnotationOnGetter_whenSerializing_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoFieldNameChanged dtoObject = new MyDtoFieldNameChanged(); dtoObject.setStringValue("a"); @@ -52,6 +52,8 @@ public final void givenNameOfFieldIsChanged_whenSerializing_thenCorrect() throws System.out.println(dtoAsString); } + // tests - serialize via accessors/fields + @Test(expected = JsonMappingException.class) public final void givenObjectHasNoAccessors_whenSerializing_thenException() throws JsonParseException, IOException { final String dtoAsString = new ObjectMapper().writeValueAsString(new MyDtoNoAccessors()); From 458db43570987dc4ed3149262f7929b5654a3b60 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 6 Jan 2014 21:35:23 +0200 Subject: [PATCH 406/796] maven added dependency and IO work --- core-java/pom.xml | 6 + .../org/baeldung/java/CoreJavaIoUnitTest.java | 55 +++- guava/pom.xml | 259 +++++++++--------- 3 files changed, 190 insertions(+), 130 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index ed3cb6ce435c..cc745fb96f6d 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -28,6 +28,12 @@ 2.4 + + org.apache.commons + commons-lang3 + 3.2 + + diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java index 424621bc5953..8d01ebefd82c 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -1,8 +1,17 @@ package org.baeldung.java; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.nio.charset.StandardCharsets; import java.util.Scanner; import org.apache.commons.io.FileUtils; @@ -11,12 +20,15 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Charsets; +import com.google.common.io.ByteSource; +import com.google.common.io.CharStreams; import com.google.common.io.Files; +import com.google.common.io.InputSupplier; public class CoreJavaIoUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); - // tests - + // tests - iterate lines in a file @Test public final void givenUsingGuava_whenIteratingAFile_thenCorrect() throws IOException { @@ -70,7 +82,45 @@ public final void whenStreamingThroughAFile_thenCorrect() throws IOException { logMemory(); } - // + // tests - InputStream to String + + @Test + public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(8); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8); + + // When + String text = null; + try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) { + text = scanner.useDelimiter("\\A").next(); + } + + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingGuavaNoEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(8); + final InputSupplier readerSupplier = CharStreams.newReaderSupplier(originalString); + + // When + final String text = CharStreams.toString(readerSupplier); + + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingGuavaWithEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(8); + final InputSupplier readerSupplier = ByteSource.wrap(originalString.getBytes()).asCharSource(Charsets.UTF_8); + + // When + final String text = CharStreams.toString(readerSupplier); + + assertThat(text, equalTo(originalString)); + } + + // utils private final void logMemory() { logger.info("Max Memory: {} Mb", Runtime.getRuntime().maxMemory() / 1048576); @@ -79,4 +129,3 @@ private final void logMemory() { } } -// \ No newline at end of file diff --git a/guava/pom.xml b/guava/pom.xml index f9994defec69..2b078d979146 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -1,129 +1,134 @@ - - 4.0.0 - org.baeldung - spring-rest - 0.1-SNAPSHOT - - spring-rest - - - - - - - com.google.guava - guava - 15.0 - - - - org.apache.commons - commons-collections4 - 4.0 - - - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-rest - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - 4.0.0.RELEASE - 3.2.0.RELEASE - - - 4.3.0.Final - 5.1.27 - - - 1.7.5 - 1.0.11 - - - 5.0.1.Final - - - 15.0 - 3.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - - - 3.1 - 2.4 - 2.16 - 2.6 - 1.4.5 - - + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + 15.0 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + org.apache.commons + commons-lang3 + 3.2 + + + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-rest + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.27 + + + 1.7.5 + 1.0.11 + + + 5.0.1.Final + + + 15.0 + 3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + \ No newline at end of file From faefaa5088d9a4bd2bed5e872132c50493e1d14e Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 7 Jan 2014 11:33:39 +0200 Subject: [PATCH 407/796] java IO testing work --- .../java/CoreJavaIoIntegrationTest.java | 81 ++++++++++++++++++ .../org/baeldung/java/CoreJavaIoUnitTest.java | 85 +++++-------------- 2 files changed, 103 insertions(+), 63 deletions(-) create mode 100644 core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java new file mode 100644 index 000000000000..f492ebf68f6e --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java @@ -0,0 +1,81 @@ +package org.baeldung.java; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Scanner; + +import org.apache.commons.io.FileUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; + +public class CoreJavaIoIntegrationTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - iterate lines in a file + + @Test + public final void givenUsingGuava_whenIteratingAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + Files.readLines(new File(path), Charsets.UTF_8); + logMemory(); + } + + @Test + public final void givenUsingCommonsIo_whenIteratingAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + FileUtils.readLines(new File(path)); + logMemory(); + } + + @Test + public final void whenStreamingThroughAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + + FileInputStream inputStream = null; + Scanner sc = null; + try { + inputStream = new FileInputStream(path); + sc = new Scanner(inputStream, "UTF-8"); + while (sc.hasNextLine()) { + final String line = sc.nextLine(); + // System.out.println(line); + } + // note that Scanner suppresses exceptions + if (sc.ioException() != null) { + throw sc.ioException(); + } + } finally { + if (inputStream != null) { + inputStream.close(); + } + if (sc != null) { + sc.close(); + } + } + + logMemory(); + } + + // utils + + private final void logMemory() { + logger.info("Max Memory: {} Mb", Runtime.getRuntime().maxMemory() / 1048576); + logger.info("Total Memory: {} Mb", Runtime.getRuntime().totalMemory() / 1048576); + logger.info("Free Memory: {} Mb", Runtime.getRuntime().freeMemory() / 1048576); + } + +} diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java index 8d01ebefd82c..1e2dbc6750e2 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -5,16 +5,15 @@ import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; +import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.util.Scanner; -import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,66 +21,11 @@ import com.google.common.base.Charsets; import com.google.common.io.ByteSource; import com.google.common.io.CharStreams; -import com.google.common.io.Files; import com.google.common.io.InputSupplier; public class CoreJavaIoUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); - // tests - iterate lines in a file - - @Test - public final void givenUsingGuava_whenIteratingAFile_thenCorrect() throws IOException { - final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; - // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; - - logMemory(); - Files.readLines(new File(path), Charsets.UTF_8); - logMemory(); - } - - @Test - public final void givenUsingCommonsIo_whenIteratingAFile_thenCorrect() throws IOException { - final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; - // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; - - logMemory(); - FileUtils.readLines(new File(path)); - logMemory(); - } - - @Test - public final void whenStreamingThroughAFile_thenCorrect() throws IOException { - final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; - // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; - - logMemory(); - - FileInputStream inputStream = null; - Scanner sc = null; - try { - inputStream = new FileInputStream(path); - sc = new Scanner(inputStream, "UTF-8"); - while (sc.hasNextLine()) { - final String line = sc.nextLine(); - // System.out.println(line); - } - // note that Scanner suppresses exceptions - if (sc.ioException() != null) { - throw sc.ioException(); - } - } finally { - if (inputStream != null) { - inputStream.close(); - } - if (sc != null) { - sc.close(); - } - } - - logMemory(); - } - // tests - InputStream to String @Test @@ -120,12 +64,27 @@ public final void givenUsingGuavaWithEncoding_whenConvertingAnInputStreamToAStri assertThat(text, equalTo(originalString)); } - // utils + @Test + public final void givenUsingCommonsIoWithEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(8); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + final String text = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingCommonsIoWithEncoding2_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(8); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + final StringWriter writer = new StringWriter(); + final String encoding = StandardCharsets.UTF_8.name(); + IOUtils.copy(inputStream, writer, encoding); - private final void logMemory() { - logger.info("Max Memory: {} Mb", Runtime.getRuntime().maxMemory() / 1048576); - logger.info("Total Memory: {} Mb", Runtime.getRuntime().totalMemory() / 1048576); - logger.info("Free Memory: {} Mb", Runtime.getRuntime().freeMemory() / 1048576); + assertThat(writer.toString(), equalTo(originalString)); } } From 36d843329e78dd33c2efcc6018719dc9f7f2e158 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 7 Jan 2014 12:28:09 +0200 Subject: [PATCH 408/796] io testing work --- .../org/baeldung/java/CoreJavaIoUnitTest.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java index 1e2dbc6750e2..a9eb9d18b1a5 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -7,8 +7,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; -import java.io.StringReader; import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.util.Scanner; @@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Charsets; -import com.google.common.io.ByteSource; import com.google.common.io.CharStreams; import com.google.common.io.InputSupplier; @@ -43,9 +42,17 @@ public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorre } @Test - public final void givenUsingGuavaNoEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + public final void givenUsingGuava_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(8); - final InputSupplier readerSupplier = CharStreams.newReaderSupplier(originalString); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + final InputSupplier inputSupplier = new InputSupplier() { + @Override + public final InputStream getInput() throws IOException { + return inputStream; + } + }; + final InputSupplier readerSupplier = CharStreams.newReaderSupplier(inputSupplier, Charsets.UTF_8); // When final String text = CharStreams.toString(readerSupplier); @@ -54,18 +61,21 @@ public final void givenUsingGuavaNoEncoding_whenConvertingAnInputStreamToAString } @Test - public final void givenUsingGuavaWithEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(8); - final InputSupplier readerSupplier = ByteSource.wrap(originalString.getBytes()).asCharSource(Charsets.UTF_8); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // When - final String text = CharStreams.toString(readerSupplier); + String text = null; + try (final Reader reader = new InputStreamReader(inputStream)) { + text = CharStreams.toString(reader); + } assertThat(text, equalTo(originalString)); } @Test - public final void givenUsingCommonsIoWithEncoding_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + public final void givenUsingCommonsIo_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(8); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); @@ -75,7 +85,7 @@ public final void givenUsingCommonsIoWithEncoding_whenConvertingAnInputStreamToA } @Test - public final void givenUsingCommonsIoWithEncoding2_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + public final void givenUsingCommonsIoWithCopy_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(8); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); From 05cf9b75417e90e92e885de740bb1f65efa364e1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 9 Jan 2014 18:11:32 +0200 Subject: [PATCH 409/796] furthe example work --- .../config/{MvcConfig.java => WebConfig.java} | 6 +- .../BarMappingExamplesController.java} | 6 +- .../FooMappingExamplesController.java} | 8 +- .../web/controller/FooController.java | 6 +- .../src/main/webapp/WEB-INF/web.xml | 78 ++++++++++--------- 5 files changed, 54 insertions(+), 50 deletions(-) rename spring-rest/src/main/java/org/baeldung/config/{MvcConfig.java => WebConfig.java} (74%) rename spring-rest/src/main/java/org/baeldung/{controller/BarController.java => web/controller/BarMappingExamplesController.java} (91%) rename spring-rest/src/main/java/org/baeldung/{controller/FooController.java => web/controller/FooMappingExamplesController.java} (94%) diff --git a/spring-rest/src/main/java/org/baeldung/config/MvcConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java similarity index 74% rename from spring-rest/src/main/java/org/baeldung/config/MvcConfig.java rename to spring-rest/src/main/java/org/baeldung/config/WebConfig.java index 18924ad855b1..c26e09ca54eb 100644 --- a/spring-rest/src/main/java/org/baeldung/config/MvcConfig.java +++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java @@ -6,10 +6,10 @@ @EnableWebMvc @Configuration -@ComponentScan({ "org.baeldung.controller" }) -public class MvcConfig { +@ComponentScan({ "org.baeldung.web" }) +public class WebConfig { - public MvcConfig() { + public WebConfig() { super(); } diff --git a/spring-rest/src/main/java/org/baeldung/controller/BarController.java b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java similarity index 91% rename from spring-rest/src/main/java/org/baeldung/controller/BarController.java rename to spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java index d85c41086298..46e8bcf97550 100644 --- a/spring-rest/src/main/java/org/baeldung/controller/BarController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java @@ -1,4 +1,4 @@ -package org.baeldung.controller; +package org.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -7,9 +7,9 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller -public class BarController { +public class BarMappingExamplesController { - public BarController() { + public BarMappingExamplesController() { super(); } diff --git a/spring-rest/src/main/java/org/baeldung/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java similarity index 94% rename from spring-rest/src/main/java/org/baeldung/controller/FooController.java rename to spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java index 292f46729abf..e031ac13dee5 100644 --- a/spring-rest/src/main/java/org/baeldung/controller/FooController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java @@ -1,4 +1,4 @@ -package org.baeldung.controller; +package org.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -7,15 +7,15 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller -public class FooController { +public class FooMappingExamplesController { - public FooController() { + public FooMappingExamplesController() { super(); } // API - // by paths + // mapping examples @RequestMapping(value = "/foos") @ResponseBody diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java index 642878b91826..cd0153540fa2 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -31,14 +31,16 @@ public FooController() { // API - // read + // read - single @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + public Foo findById(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { return new Foo(randomAlphabetic(6)); } + // read - multiple + @RequestMapping(method = RequestMethod.GET) @ResponseBody public List findAll() { diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index fe62026bc7d6..a33a3fd2c14a 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,52 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file From f06b24bea298e3a3297050e9cb27aa4576ab3496 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 9 Jan 2014 18:37:55 +0200 Subject: [PATCH 410/796] updating mappings so that the project can be used for other purposes --- .../web/controller/BarMappingExamplesController.java | 1 + .../web/controller/FooMappingExamplesController.java | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java index 46e8bcf97550..1c3a1086ca1f 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller +@RequestMapping(value = "/ex") public class BarMappingExamplesController { public BarMappingExamplesController() { diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java index e031ac13dee5..5fb92d6d872a 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller +@RequestMapping(value = "/ex") public class FooMappingExamplesController { public FooMappingExamplesController() { @@ -59,10 +60,16 @@ public String getFoosWithHeaders() { return "Get some Foos with Header"; } + // @RequestMapping(value = "/foos", method = RequestMethod.GET, headers = "Accept=application/json") + // @ResponseBody + // public String getFoosAsJsonFromBrowser() { + // return "Get some Foos with Header Old"; + // } + @RequestMapping(value = "/foos", produces = { "application/json", "application/xml" }) @ResponseBody public String getFoosAsJsonFromREST() { - return "Get some Foos with Header Exact"; + return "Get some Foos with Header New"; } // advanced - multiple mappings From 71c8dffe40c6a735581c9ed355d787e70bb54b9c Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 10 Jan 2014 11:50:41 +0200 Subject: [PATCH 411/796] new foo controller - work in progress --- spring-rest/pom.xml | 54 +++++++++++++++---- .../web/controller/FooController.java | 28 ++++++++++ .../main/java/org/baeldung/web/dto/Foo.java | 39 ++++++++++++++ spring-security-rest-full/pom.xml | 2 +- 4 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 spring-rest/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-rest/src/main/java/org/baeldung/web/dto/Foo.java diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index e7396227eeb8..2aa91aab4559 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -39,6 +39,34 @@ runtime + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.thoughtworks.xstream + xstream + 1.4.6 + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + 3.2.1 + + @@ -80,7 +108,7 @@ - + org.apache.maven.plugins maven-compiler-plugin @@ -90,7 +118,7 @@ 1.7 - + org.apache.maven.plugins maven-war-plugin @@ -143,17 +171,17 @@ 4.3.0.Final - 5.1.27 + 5.1.28 - - 1.7.5 - 1.0.11 + + + 2.3.0 - 5.0.1.Final + 5.0.2.Final - 15.0 + 16.0-rc1 3.1 @@ -161,16 +189,20 @@ 4.11 1.9.5 - 4.3 + 4.3.1 4.3.1 - 2.1.0 + 2.2.0 + + + 1.7.5 + 1.0.11 3.1 2.4 2.16 - 1.4.5 + 1.4.6 diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..d90a98d3897b --- /dev/null +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class FooController { + + public FooController() { + super(); + } + + // API + + @RequestMapping(method = RequestMethod.GET, value = "/foos/{id}") + public @ResponseBody + Foo findById(@PathVariable final long id) { + return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); + } + +} diff --git a/spring-rest/src/main/java/org/baeldung/web/dto/Foo.java b/spring-rest/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..774d54746454 --- /dev/null +++ b/spring-rest/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,39 @@ +package org.baeldung.web.dto; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +@XStreamAlias("Foo") +public class Foo { + private long id; + private String name; + + public Foo() { + super(); + } + + public Foo(final long id, final String name) { + super(); + + this.id = id; + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 3eb5bc9bd6ce..4e45b9c18be2 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -91,7 +91,7 @@ org.javassist javassist - 3.18.0-GA + 3.18.1-GA mysql From 72edb72fd51157e779d9b35ebe4f834f3fe58232 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 10 Jan 2014 13:42:21 +0200 Subject: [PATCH 412/796] further marshalling work --- spring-rest/pom.xml | 36 +++++++++++ .../java/org/baeldung/config/WebConfig.java | 60 ++++++++++++++----- .../web/controller/FooController.java | 13 +++- spring-security-rest-full/pom.xml | 8 +-- 4 files changed, 96 insertions(+), 21 deletions(-) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 2aa91aab4559..07231e35f4d0 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -16,12 +16,23 @@ org.springframework spring-web ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework spring-webmvc ${org.springframework.version} + + org.springframework + spring-oxm + ${org.springframework.version} + @@ -67,6 +78,31 @@ 3.2.1 + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + diff --git a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java index c26e09ca54eb..d0689100424c 100644 --- a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java +++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java @@ -1,16 +1,44 @@ -package org.baeldung.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; - -@EnableWebMvc -@Configuration -@ComponentScan({ "org.baeldung.web" }) -public class WebConfig { - - public WebConfig() { - super(); - } - -} \ No newline at end of file +package org.baeldung.config; + +import java.util.List; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.converter.xml.MarshallingHttpMessageConverter; +import org.springframework.oxm.xstream.XStreamMarshaller; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan({ "org.baeldung.web" }) +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + + @Override + public void configureMessageConverters(final List> messageConverters) { + messageConverters.add(marshallingHttpMessageConverter()); + messageConverters.add(new MappingJackson2HttpMessageConverter()); + + super.configureMessageConverters(messageConverters); + } + + // UTIL + + private final MarshallingHttpMessageConverter marshallingHttpMessageConverter() { + final MarshallingHttpMessageConverter marshallingHttpMessageConverter = new MarshallingHttpMessageConverter(); + final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller(); + marshallingHttpMessageConverter.setMarshaller(xstreamMarshaller); + marshallingHttpMessageConverter.setUnmarshaller(xstreamMarshaller); + + return marshallingHttpMessageConverter; + } + +} diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java index d90a98d3897b..4dc6949c5d7a 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -4,11 +4,14 @@ import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import org.baeldung.web.dto.Foo; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; @Controller public class FooController { @@ -17,7 +20,7 @@ public FooController() { super(); } - // API + // API - read @RequestMapping(method = RequestMethod.GET, value = "/foos/{id}") public @ResponseBody @@ -25,4 +28,12 @@ Foo findById(@PathVariable final long id) { return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); } + // API - write + + @RequestMapping(method = RequestMethod.PUT, value = "/foos/{id}") + @ResponseStatus(HttpStatus.OK) + public void updateFoo(@PathVariable("id") final String id, @RequestBody final Foo foo) { + System.out.println(foo); + } + } diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 4e45b9c18be2..8b9eb62ca3ce 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -196,7 +196,7 @@ com.jayway.restassured rest-assured - 2.1.0 + 2.2.0 test @@ -275,12 +275,12 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.4.3.RELEASE - 2.2.3 + 2.3.0 1.7.5 @@ -291,7 +291,7 @@ 15.0 - 3.1 + 3.2.1 1.3 From 0f8409bf7d39748c4e25685d0eb3c25784b31120 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 10 Jan 2014 13:49:11 +0200 Subject: [PATCH 413/796] minor configuration work --- .../main/java/org/baeldung/config/WebConfig.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java index d0689100424c..fe73f719bf29 100644 --- a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java +++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java @@ -20,25 +20,24 @@ public WebConfig() { super(); } - // API + // @Override public void configureMessageConverters(final List> messageConverters) { - messageConverters.add(marshallingHttpMessageConverter()); + messageConverters.add(createXmlHttpMessageConverter()); messageConverters.add(new MappingJackson2HttpMessageConverter()); super.configureMessageConverters(messageConverters); } - // UTIL + private HttpMessageConverter createXmlHttpMessageConverter() { + final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter(); - private final MarshallingHttpMessageConverter marshallingHttpMessageConverter() { - final MarshallingHttpMessageConverter marshallingHttpMessageConverter = new MarshallingHttpMessageConverter(); final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller(); - marshallingHttpMessageConverter.setMarshaller(xstreamMarshaller); - marshallingHttpMessageConverter.setUnmarshaller(xstreamMarshaller); + xmlConverter.setMarshaller(xstreamMarshaller); + xmlConverter.setUnmarshaller(xstreamMarshaller); - return marshallingHttpMessageConverter; + return xmlConverter; } } From 82fe27e433ec97ed692ef33f8b5089e36191d6d7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 10 Jan 2014 13:57:15 +0200 Subject: [PATCH 414/796] initial testing work --- ...MessageConvertersIntegrationTestsCase.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java diff --git a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java new file mode 100644 index 000000000000..9f451bace4be --- /dev/null +++ b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java @@ -0,0 +1,100 @@ +package org.baeldung.web.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.baeldung.web.dto.Foo; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.xml.MarshallingHttpMessageConverter; +import org.springframework.oxm.xstream.XStreamMarshaller; +import org.springframework.web.client.RestTemplate; + +/** + * Integration Test class. Tests methods hits the server's rest services. + */ +public class SpringHttpMessageConvertersIntegrationTestsCase { + + private static String BASE_URI = "http://localhost:8080/spring-rest/"; + + /** + * Without specifying Accept Header, uses the default response from the + * server (in this case json) + */ + @Test + public void testGetFoo() { + final String URI = BASE_URI + "foos/{id}"; + + final RestTemplate restTemplate = new RestTemplate(); + final Foo resource = restTemplate.getForObject(URI, Foo.class, "1"); + + Assert.assertEquals(1l, resource.getId()); + } + + /** + * Specifying Accept Header with application/xml for getting the xml response from the server. + */ + @Test + public void testGetFooAcceptXML() { + final String URI = BASE_URI + "foos/{id}"; + + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.setMessageConverters(getMessageConverters()); + + final HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Arrays.asList(MediaType.APPLICATION_XML)); + final HttpEntity entity = new HttpEntity(headers); + + final ResponseEntity response = restTemplate.exchange(URI, HttpMethod.GET, entity, Foo.class, "1"); + final Foo resource = response.getBody(); + + Assert.assertEquals(1l, resource.getId()); + + } + + /** + * Specifying Accept Header with application/xml for getting the xml response from the server. + */ + @Test + public void testPUTFooXML() { + final String URI = BASE_URI + "foos/{id}"; + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.setMessageConverters(getMessageConverters()); + + final Foo resource = new Foo(4, "andres"); + final HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Arrays.asList(MediaType.APPLICATION_XML)); + headers.setContentType((MediaType.APPLICATION_XML)); + final HttpEntity entity = new HttpEntity(resource, headers); + + final ResponseEntity response = restTemplate.exchange(URI, HttpMethod.PUT, entity, Foo.class, resource.getId()); + final Foo fooResponse = response.getBody(); + + Assert.assertEquals(resource.getId(), fooResponse.getId()); + } + + // UTIL + + /** + * Configures Message Converters. + */ + private List> getMessageConverters() { + final List> converters = new ArrayList>(); + // adds XML converter using XStreamMarshaller + final XStreamMarshaller marshaller = new XStreamMarshaller(); + marshaller.setAnnotatedClasses(Foo.class); + + final MarshallingHttpMessageConverter marshallingConverter = new MarshallingHttpMessageConverter(marshaller); + converters.add(marshallingConverter); + + return converters; + } + +} From 99573ad02b6249f0e72bdf2b42067c6127c96602 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 10 Jan 2014 15:37:24 +0200 Subject: [PATCH 415/796] marshalling work --- .../web/controller/FooController.java | 9 +-- ...MessageConvertersIntegrationTestsCase.java | 55 ++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java index 4dc6949c5d7a..6f68defcd642 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -23,8 +23,8 @@ public FooController() { // API - read @RequestMapping(method = RequestMethod.GET, value = "/foos/{id}") - public @ResponseBody - Foo findById(@PathVariable final long id) { + @ResponseBody + public Foo findById(@PathVariable final long id) { return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); } @@ -32,8 +32,9 @@ Foo findById(@PathVariable final long id) { @RequestMapping(method = RequestMethod.PUT, value = "/foos/{id}") @ResponseStatus(HttpStatus.OK) - public void updateFoo(@PathVariable("id") final String id, @RequestBody final Foo foo) { + @ResponseBody + public Foo updateFoo(@PathVariable("id") final String id, @RequestBody final Foo foo) { System.out.println(foo); + return foo; } - } diff --git a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java index 9f451bace4be..c21641ca225e 100644 --- a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java +++ b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java @@ -1,5 +1,8 @@ package org.baeldung.web.test; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -13,6 +16,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.xml.MarshallingHttpMessageConverter; import org.springframework.oxm.xstream.XStreamMarshaller; import org.springframework.web.client.RestTemplate; @@ -29,20 +33,17 @@ public class SpringHttpMessageConvertersIntegrationTestsCase { * server (in this case json) */ @Test - public void testGetFoo() { + public void whenRetrievingAFoo_thenCorrect() { final String URI = BASE_URI + "foos/{id}"; final RestTemplate restTemplate = new RestTemplate(); final Foo resource = restTemplate.getForObject(URI, Foo.class, "1"); - Assert.assertEquals(1l, resource.getId()); + assertThat(resource, notNullValue()); } - /** - * Specifying Accept Header with application/xml for getting the xml response from the server. - */ @Test - public void testGetFooAcceptXML() { + public void givenConsumingXml_whenReadingTheFoo_thenCorrect() { final String URI = BASE_URI + "foos/{id}"; final RestTemplate restTemplate = new RestTemplate(); @@ -55,22 +56,35 @@ public void testGetFooAcceptXML() { final ResponseEntity response = restTemplate.exchange(URI, HttpMethod.GET, entity, Foo.class, "1"); final Foo resource = response.getBody(); - Assert.assertEquals(1l, resource.getId()); + assertThat(resource, notNullValue()); + } + + @Test + public void givenConsumingJson_whenReadingTheFoo_thenCorrect() { + final String URI = BASE_URI + "foos/{id}"; + + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.setMessageConverters(getMessageConverters()); + + final HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); + final HttpEntity entity = new HttpEntity(headers); + + final ResponseEntity response = restTemplate.exchange(URI, HttpMethod.GET, entity, Foo.class, "1"); + final Foo resource = response.getBody(); + assertThat(resource, notNullValue()); } - /** - * Specifying Accept Header with application/xml for getting the xml response from the server. - */ @Test - public void testPUTFooXML() { + public void givenConsumingXml_whenWritingTheFoo_thenCorrect() { final String URI = BASE_URI + "foos/{id}"; final RestTemplate restTemplate = new RestTemplate(); restTemplate.setMessageConverters(getMessageConverters()); - final Foo resource = new Foo(4, "andres"); + final Foo resource = new Foo(4, "jason"); final HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Arrays.asList(MediaType.APPLICATION_XML)); + headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.setContentType((MediaType.APPLICATION_XML)); final HttpEntity entity = new HttpEntity(resource, headers); @@ -82,17 +96,16 @@ public void testPUTFooXML() { // UTIL - /** - * Configures Message Converters. - */ private List> getMessageConverters() { final List> converters = new ArrayList>(); - // adds XML converter using XStreamMarshaller - final XStreamMarshaller marshaller = new XStreamMarshaller(); - marshaller.setAnnotatedClasses(Foo.class); - final MarshallingHttpMessageConverter marshallingConverter = new MarshallingHttpMessageConverter(marshaller); - converters.add(marshallingConverter); + final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter(); + final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller(); + xmlConverter.setMarshaller(xstreamMarshaller); + xmlConverter.setUnmarshaller(xstreamMarshaller); + + converters.add(xmlConverter); + converters.add(new MappingJackson2HttpMessageConverter()); return converters; } From c905b21ffce8b2f906698151047ced9d498b5f57 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 Jan 2014 17:48:59 +0200 Subject: [PATCH 416/796] maven upgrade --- core-java/pom.xml | 10 +++++----- experiments/pom.xml | 8 ++++---- guava/pom.xml | 12 ++++++------ httpclient/pom.xml | 8 ++++---- jackson/pom.xml | 10 +++++----- mockito/pom.xml | 10 +++++----- rest-testing/pom.xml | 6 +++--- spring-all/pom.xml | 8 ++++---- spring-exceptions/pom.xml | 8 ++++---- spring-hibernate3/pom.xml | 8 ++++---- spring-hibernate4/pom.xml | 6 +++--- spring-jpa/pom.xml | 8 ++++---- spring-mvc-java/pom.xml | 8 ++++---- spring-rest/pom.xml | 2 +- spring-security-basic-auth/pom.xml | 8 ++++---- spring-security-mvc-custom/pom.xml | 8 ++++---- spring-security-mvc-digest-auth/pom.xml | 8 ++++---- spring-security-mvc-login/pom.xml | 8 ++++---- spring-security-mvc-session/pom.xml | 8 ++++---- spring-security-rest-basic-auth/pom.xml | 8 ++++---- spring-security-rest-custom/pom.xml | 8 ++++---- spring-security-rest-digest-auth/pom.xml | 8 ++++---- spring-security-rest-full/pom.xml | 4 ++-- spring-security-rest/pom.xml | 8 ++++---- 24 files changed, 94 insertions(+), 94 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index cc745fb96f6d..a07602e57003 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -13,7 +13,7 @@ com.google.guava guava - 15.0 + ${guava.version} @@ -31,7 +31,7 @@ org.apache.commons commons-lang3 - 3.2 + ${commons-lang3.version} @@ -148,11 +148,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/experiments/pom.xml b/experiments/pom.xml index 79c969935626..369d6278b97d 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -260,18 +260,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/guava/pom.xml b/guava/pom.xml index 2b078d979146..8dc777de7790 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -13,7 +13,7 @@ com.google.guava guava - 15.0 + ${guava.version} @@ -25,7 +25,7 @@ org.apache.commons commons-lang3 - 3.2 + ${commons-lang3.version} @@ -99,18 +99,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index d3ef5e6d69cc..ab120746dee3 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -129,18 +129,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/jackson/pom.xml b/jackson/pom.xml index b5d16d26fcc0..14e0da23f9c6 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -106,7 +106,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 2.3.0 @@ -116,11 +116,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 @@ -137,7 +137,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.6 diff --git a/mockito/pom.xml b/mockito/pom.xml index c2d0e48b922e..5f28802cce2a 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -14,7 +14,7 @@ com.google.guava guava - 15.0 + ${guava.version} @@ -94,18 +94,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index a789c5781606..c96af8924da7 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -148,11 +148,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index e7578a418165..6052f76823f3 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -199,18 +199,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 3f17e77d5843..e80ede909a9b 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -211,7 +211,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 7.0.42 @@ -219,11 +219,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index d329bb12f080..1cad62d30b64 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -180,7 +180,7 @@ 3.6.10.Final - 5.1.27 + 5.1.28 7.0.47 @@ -188,11 +188,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index fbb4059f1cfe..ec1c284ef8ae 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -196,11 +196,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index f139c609ec43..849a62ee36d5 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -182,18 +182,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 091e4f3f362e..86614199803c 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -146,18 +146,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 07231e35f4d0..13f384c92675 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -218,7 +218,7 @@ 16.0-rc1 - 3.1 + 3.2.1 1.3 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 0413373c8699..d32a3169eb96 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -225,18 +225,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index acf5094423e1..a61c49352cc6 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -230,18 +230,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 9a1f883ea859..5147a3f1b447 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -225,18 +225,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index ad71b17bb042..e26b65f0ef59 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -222,18 +222,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 7dcd791cacc7..b1d769083dce 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -230,18 +230,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 27e3404cffe2..eb2e95725200 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -291,7 +291,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 4.3.1 @@ -302,11 +302,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 783dfd06253b..2cea3553ab5d 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -247,18 +247,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 61ad000edf88..381974eabc35 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -280,7 +280,7 @@ 4.3.0.Final - 5.1.27 + 5.1.28 4.3 @@ -291,11 +291,11 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 8b9eb62ca3ce..b93c13fc172d 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -287,10 +287,10 @@ 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 + 16.0-rc1 3.2.1 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 7c856cd44630..cdb279792202 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -213,18 +213,18 @@ 4.3.0.Final - 5.1.27 + 5.1.28 1.7.5 1.0.11 - 5.0.1.Final + 5.0.2.Final - 15.0 - 3.1 + 16.0-rc1 + 3.2.1 1.3 From a47c533ec99b31001adbb36d50721293ade043a2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 Jan 2014 18:23:45 +0200 Subject: [PATCH 417/796] custom serializer work --- jackson/pom.xml | 6 ++ .../java/org/baeldung/jackson/dtos/Item.java | 28 ++++++++ .../java/org/baeldung/jackson/dtos/User.java | 22 +++++++ .../JacksonSerializationEnumsUnitTest.java | 57 ++++++++++++++++ .../test/JacksonSerializationUnitTest.java | 66 ++++++++----------- .../baeldung/jackson/try1/ItemSerializer.java | 23 +++++++ 6 files changed, 162 insertions(+), 40 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/Item.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/User.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java diff --git a/jackson/pom.xml b/jackson/pom.xml index 14e0da23f9c6..8de8dfd5d802 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -27,6 +27,12 @@ 4.0 + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java new file mode 100644 index 000000000000..db834a073319 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java @@ -0,0 +1,28 @@ +package org.baeldung.jackson.dtos; + +public class Item { + public final int id; + public final String itemNr; + public final User createdBy; + + public Item(final int id, final String itemNr, final User createdBy) { + this.id = id; + this.itemNr = itemNr; + this.createdBy = createdBy; + } + + // API + + public int getId() { + return id; + } + + public String getItemNr() { + return itemNr; + } + + public User getCreatedBy() { + return createdBy; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/User.java b/jackson/src/test/java/org/baeldung/jackson/dtos/User.java new file mode 100644 index 000000000000..c2e70ab8e9ac --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/User.java @@ -0,0 +1,22 @@ +package org.baeldung.jackson.dtos; + +public class User { + public final int id; + public final String name; + + public User(final int id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public int getId() { + return id; + } + + public String getName() { + return name; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java new file mode 100644 index 000000000000..a19b6831bd5f --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java @@ -0,0 +1,57 @@ +package org.baeldung.jackson.test; + +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertThat; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnum; +import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom; +import org.baeldung.jackson.dtos.withEnum.TypeEnum; +import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JacksonSerializationEnumsUnitTest { + + // tests - enums + + @Test + public final void whenSerializingSimpleEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + + @Test + public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String json = mapper.writeValueAsString(new TypeEnum[] { TypeEnum.TYPE1, TypeEnum.TYPE2 }); + + System.out.println(json); + assertThat(json, containsString("\"name\":\"Type A\"")); + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index f510bd93dacf..ad7aa1b29682 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -1,28 +1,33 @@ package org.baeldung.jackson.test; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; import java.io.IOException; +import java.io.StringWriter; import java.util.List; +import org.baeldung.jackson.dtos.Item; import org.baeldung.jackson.dtos.MyDto; import org.baeldung.jackson.dtos.MyDtoFieldNameChanged; import org.baeldung.jackson.dtos.MyDtoNoAccessors; import org.baeldung.jackson.dtos.MyDtoNoAccessorsAndFieldVisibility; -import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnum; -import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom; -import org.baeldung.jackson.dtos.withEnum.TypeEnum; -import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; +import org.baeldung.jackson.dtos.User; +import org.baeldung.jackson.try1.ItemSerializer; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.collect.Lists; public class JacksonSerializationUnitTest { @@ -82,54 +87,35 @@ public final void givenObjectHasNoAccessorsButHasVisibleFields_whenSerializing_t assertThat(dtoAsString, containsString("booleanValue")); } - // tests - enums - - @Test - public final void whenSerializingSimpleEnum_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); - - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); - } - - @Test - public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); - - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); - } + // tests - multiple entities to json @Test - public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { - final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); - - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); - } + public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { + final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); - @Test - public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(new TypeEnum[] { TypeEnum.TYPE1, TypeEnum.TYPE2 }); + final String dtosAsString = mapper.writeValueAsString(listOfDtos); - System.out.println(json); - assertThat(json, containsString("\"name\":\"Type A\"")); + System.out.println(dtosAsString); } - // tests - multiple entities to json + // tests - custom serializer @Test - public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException { - final List listOfDtos = Lists.newArrayList(new MyDto("a", 1, true), new MyDto("bc", 3, false)); + public final void whenSerializingWithCustomSerializer_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException { + final Item myItem = new Item(Integer.parseInt(randomNumeric(2)), randomAlphabetic(8), new User(Integer.parseInt(randomNumeric(2)), randomAlphabetic(8))); final ObjectMapper mapper = new ObjectMapper(); - final String dtosAsString = mapper.writeValueAsString(listOfDtos); - System.out.println(dtosAsString); + final SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, null)); + simpleModule.addSerializer(Item.class, new ItemSerializer()); + // simpleModule.addSerializer(User.class, new UserSerializer()); + mapper.registerModule(simpleModule); + + final StringWriter writer = new StringWriter(); + mapper.writeValue(writer, myItem); + final String serialized = writer.toString(); + System.out.println(serialized); } } diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java b/jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java new file mode 100644 index 000000000000..42cdfe92be5d --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java @@ -0,0 +1,23 @@ +package org.baeldung.jackson.try1; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.Item; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class ItemSerializer extends JsonSerializer { + + @Override + public final void serialize(final Item value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeNumberField("id", value.id); + jgen.writeStringField("itemNr", value.itemNr); + jgen.writeNumberField("createdBy", value.createdBy.id); + jgen.writeEndObject(); + } + +} \ No newline at end of file From 1a217c46ea6b2273a7775d6118382f4a6797f00c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 11 Jan 2014 20:56:10 +0200 Subject: [PATCH 418/796] jackson custom serializer work --- .../java/org/baeldung/jackson/dtos/Item.java | 10 +++--- .../jackson/dtos/ItemWithSerializer.java | 33 +++++++++++++++++++ .../dtos/{ => ignore}/MyDtoIgnoreField.java | 2 +- .../{ => ignore}/MyDtoIgnoreFieldByName.java | 2 +- .../dtos/{ => ignore}/MyDtoIgnoreNull.java | 2 +- .../dtos/{ => ignore}/MyDtoIgnoreType.java | 2 +- .../dtos/{ => ignore}/MyDtoIgnoreUnknown.java | 2 +- .../ItemSerializer.java | 4 +-- .../serialization/ItemSerializerOnClass.java | 23 +++++++++++++ .../test/JacksonDeserializationUnitTest.java | 2 +- .../JacksonSerializationIgnoreUnitTest.java | 6 ++-- .../test/JacksonSerializationUnitTest.java | 31 ++++++++++------- 12 files changed, 92 insertions(+), 27 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => ignore}/MyDtoIgnoreField.java (94%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => ignore}/MyDtoIgnoreFieldByName.java (95%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => ignore}/MyDtoIgnoreNull.java (96%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => ignore}/MyDtoIgnoreType.java (96%) rename jackson/src/test/java/org/baeldung/jackson/dtos/{ => ignore}/MyDtoIgnoreUnknown.java (96%) rename jackson/src/test/java/org/baeldung/jackson/{try1 => serialization}/ItemSerializer.java (87%) create mode 100644 jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java index db834a073319..75f4e8266d6d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java @@ -3,12 +3,12 @@ public class Item { public final int id; public final String itemNr; - public final User createdBy; + public final User owner; - public Item(final int id, final String itemNr, final User createdBy) { + public Item(final int id, final String itemNr, final User owner) { this.id = id; this.itemNr = itemNr; - this.createdBy = createdBy; + this.owner = owner; } // API @@ -21,8 +21,8 @@ public String getItemNr() { return itemNr; } - public User getCreatedBy() { - return createdBy; + public User getOwner() { + return owner; } } \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java new file mode 100644 index 000000000000..13f748ce2f87 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java @@ -0,0 +1,33 @@ +package org.baeldung.jackson.dtos; + +import org.baeldung.jackson.serialization.ItemSerializerOnClass; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(using = ItemSerializerOnClass.class) +public class ItemWithSerializer { + public final int id; + public final String itemNr; + public final User owner; + + public ItemWithSerializer(final int id, final String itemNr, final User owner) { + this.id = id; + this.itemNr = itemNr; + this.owner = owner; + } + + // API + + public int getId() { + return id; + } + + public String getItemNr() { + return itemNr; + } + + public User getOwner() { + return owner; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java similarity index 94% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java index 78d493ae60d3..4e3aecd0d2cf 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreField.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.ignore; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java similarity index 95% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java index 7902214571d9..d752e0576d47 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreFieldByName.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java index 239df1318701..0e28e430244c 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreNull.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.ignore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreType.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreType.java index fc77ec6d02c9..58876aec7971 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreType.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreType.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreUnknown.java similarity index 96% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java rename to jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreUnknown.java index fb4fa2f72447..ca702343ebea 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoIgnoreUnknown.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ignore/MyDtoIgnoreUnknown.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.dtos.ignore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java similarity index 87% rename from jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java rename to jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java index 42cdfe92be5d..860a290398bc 100644 --- a/jackson/src/test/java/org/baeldung/jackson/try1/ItemSerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.try1; +package org.baeldung.jackson.serialization; import java.io.IOException; @@ -16,7 +16,7 @@ public final void serialize(final Item value, final JsonGenerator jgen, final Se jgen.writeStartObject(); jgen.writeNumberField("id", value.id); jgen.writeStringField("itemNr", value.itemNr); - jgen.writeNumberField("createdBy", value.createdBy.id); + jgen.writeNumberField("createdBy", value.owner.id); jgen.writeEndObject(); } diff --git a/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java new file mode 100644 index 000000000000..669ce2f2f8c1 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java @@ -0,0 +1,23 @@ +package org.baeldung.jackson.serialization; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.ItemWithSerializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class ItemSerializerOnClass extends JsonSerializer { + + @Override + public final void serialize(final ItemWithSerializer value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeNumberField("id", value.id); + jgen.writeStringField("itemNr", value.itemNr); + jgen.writeNumberField("createdBy", value.owner.id); + jgen.writeEndObject(); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 6938c0c2762f..71e1f4c69d26 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -7,7 +7,7 @@ import java.io.IOException; import org.baeldung.jackson.dtos.MyDto; -import org.baeldung.jackson.dtos.MyDtoIgnoreUnknown; +import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreUnknown; import org.junit.Test; import com.fasterxml.jackson.core.JsonFactory; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java index 81881fb699b5..e9608ad7f026 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -7,12 +7,12 @@ import java.io.IOException; import org.baeldung.jackson.dtos.MyDto; -import org.baeldung.jackson.dtos.MyDtoIgnoreField; -import org.baeldung.jackson.dtos.MyDtoIgnoreFieldByName; -import org.baeldung.jackson.dtos.MyDtoIgnoreNull; import org.baeldung.jackson.dtos.MyDtoIncludeNonDefault; import org.baeldung.jackson.dtos.MyDtoWithFilter; import org.baeldung.jackson.dtos.MyMixInForString; +import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreField; +import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreFieldByName; +import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreNull; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java index ad7aa1b29682..4a34f168c7d7 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationUnitTest.java @@ -1,30 +1,27 @@ package org.baeldung.jackson.test; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; import java.io.IOException; -import java.io.StringWriter; import java.util.List; import org.baeldung.jackson.dtos.Item; +import org.baeldung.jackson.dtos.ItemWithSerializer; import org.baeldung.jackson.dtos.MyDto; import org.baeldung.jackson.dtos.MyDtoFieldNameChanged; import org.baeldung.jackson.dtos.MyDtoNoAccessors; import org.baeldung.jackson.dtos.MyDtoNoAccessorsAndFieldVisibility; import org.baeldung.jackson.dtos.User; -import org.baeldung.jackson.try1.ItemSerializer; +import org.baeldung.jackson.serialization.ItemSerializer; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -101,20 +98,32 @@ public final void whenDtoIsSerialized_thenCorrect() throws JsonParseException, I // tests - custom serializer + @Test + public final void whenSerializing_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException { + final Item myItem = new Item(1, "theItem", new User(2, "theUser")); + final String serialized = new ObjectMapper().writeValueAsString(myItem); + System.out.println(serialized); + } + @Test public final void whenSerializingWithCustomSerializer_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException { - final Item myItem = new Item(Integer.parseInt(randomNumeric(2)), randomAlphabetic(8), new User(Integer.parseInt(randomNumeric(2)), randomAlphabetic(8))); + final Item myItem = new Item(1, "theItem", new User(2, "theUser")); final ObjectMapper mapper = new ObjectMapper(); - final SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, null)); + final SimpleModule simpleModule = new SimpleModule(); simpleModule.addSerializer(Item.class, new ItemSerializer()); - // simpleModule.addSerializer(User.class, new UserSerializer()); mapper.registerModule(simpleModule); - final StringWriter writer = new StringWriter(); - mapper.writeValue(writer, myItem); - final String serialized = writer.toString(); + final String serialized = mapper.writeValueAsString(myItem); + System.out.println(serialized); + } + + @Test + public final void givenSerializerRegisteredOnClass_whenSerializingWithCustomSerializer_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException { + final ItemWithSerializer myItem = new ItemWithSerializer(1, "theItem", new User(2, "theUser")); + + final String serialized = new ObjectMapper().writeValueAsString(myItem); System.out.println(serialized); } From ff141b5afbb8c46509cebe44369a969a2bb1ceae Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 12 Jan 2014 11:58:07 +0200 Subject: [PATCH 419/796] custom deserialization work --- .../deserialization/ItemDeserializer.java | 30 +++++++++++++++ .../ItemDeserializerOnClass.java | 30 +++++++++++++++ .../java/org/baeldung/jackson/dtos/Item.java | 18 +++++---- .../jackson/dtos/ItemWithSerializer.java | 13 ++++--- .../java/org/baeldung/jackson/dtos/User.java | 8 +++- .../jackson/serialization/ItemSerializer.java | 4 +- .../serialization/ItemSerializerOnClass.java | 4 +- .../test/JacksonDeserializationUnitTest.java | 37 ++++++++++++++++++- 8 files changed, 125 insertions(+), 19 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializerOnClass.java diff --git a/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java new file mode 100644 index 000000000000..8c6b67532ab8 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java @@ -0,0 +1,30 @@ +package org.baeldung.jackson.deserialization; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.Item; +import org.baeldung.jackson.dtos.User; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.IntNode; + +public class ItemDeserializer extends JsonDeserializer { + + /** + * {"id":1,"itemNr":"theItem","owner":2} + */ + @Override + public Item deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + final JsonNode node = jp.getCodec().readTree(jp); + final int id = (Integer) ((IntNode) node.get("id")).numberValue(); + final String itemName = node.get("itemName").asText(); + final int userId = (Integer) ((IntNode) node.get("owner")).numberValue(); + + return new Item(id, itemName, new User(userId, null)); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializerOnClass.java b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializerOnClass.java new file mode 100644 index 000000000000..346f75db0719 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializerOnClass.java @@ -0,0 +1,30 @@ +package org.baeldung.jackson.deserialization; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.ItemWithSerializer; +import org.baeldung.jackson.dtos.User; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.IntNode; + +public class ItemDeserializerOnClass extends JsonDeserializer { + + /** + * {"id":1,"itemNr":"theItem","owner":2} + */ + @Override + public ItemWithSerializer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + final JsonNode node = jp.getCodec().readTree(jp); + final int id = (Integer) ((IntNode) node.get("id")).numberValue(); + final String itemName = node.get("itemName").asText(); + final int userId = (Integer) ((IntNode) node.get("owner")).numberValue(); + + return new ItemWithSerializer(id, itemName, new User(userId, null)); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java index 75f4e8266d6d..1dd840372a85 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/Item.java @@ -1,13 +1,17 @@ package org.baeldung.jackson.dtos; public class Item { - public final int id; - public final String itemNr; - public final User owner; + public int id; + public String itemName; + public User owner; - public Item(final int id, final String itemNr, final User owner) { + public Item() { + super(); + } + + public Item(final int id, final String itemName, final User owner) { this.id = id; - this.itemNr = itemNr; + this.itemName = itemName; this.owner = owner; } @@ -17,8 +21,8 @@ public int getId() { return id; } - public String getItemNr() { - return itemNr; + public String getItemName() { + return itemName; } public User getOwner() { diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java index 13f748ce2f87..6dadfa490826 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/ItemWithSerializer.java @@ -1,18 +1,21 @@ package org.baeldung.jackson.dtos; +import org.baeldung.jackson.deserialization.ItemDeserializerOnClass; import org.baeldung.jackson.serialization.ItemSerializerOnClass; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(using = ItemSerializerOnClass.class) +@JsonDeserialize(using = ItemDeserializerOnClass.class) public class ItemWithSerializer { public final int id; - public final String itemNr; + public final String itemName; public final User owner; - public ItemWithSerializer(final int id, final String itemNr, final User owner) { + public ItemWithSerializer(final int id, final String itemName, final User owner) { this.id = id; - this.itemNr = itemNr; + this.itemName = itemName; this.owner = owner; } @@ -22,8 +25,8 @@ public int getId() { return id; } - public String getItemNr() { - return itemNr; + public String getItemName() { + return itemName; } public User getOwner() { diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/User.java b/jackson/src/test/java/org/baeldung/jackson/dtos/User.java index c2e70ab8e9ac..cef29f11b45d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/User.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/User.java @@ -1,8 +1,12 @@ package org.baeldung.jackson.dtos; public class User { - public final int id; - public final String name; + public int id; + public String name; + + public User() { + super(); + } public User(final int id, final String name) { this.id = id; diff --git a/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java index 860a290398bc..7a1362a41647 100644 --- a/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializer.java @@ -15,8 +15,8 @@ public class ItemSerializer extends JsonSerializer { public final void serialize(final Item value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeNumberField("id", value.id); - jgen.writeStringField("itemNr", value.itemNr); - jgen.writeNumberField("createdBy", value.owner.id); + jgen.writeStringField("itemName", value.itemName); + jgen.writeNumberField("owner", value.owner.id); jgen.writeEndObject(); } diff --git a/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java index 669ce2f2f8c1..44060cabb92f 100644 --- a/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java +++ b/jackson/src/test/java/org/baeldung/jackson/serialization/ItemSerializerOnClass.java @@ -15,8 +15,8 @@ public class ItemSerializerOnClass extends JsonSerializer { public final void serialize(final ItemWithSerializer value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeNumberField("id", value.id); - jgen.writeStringField("itemNr", value.itemNr); - jgen.writeNumberField("createdBy", value.owner.id); + jgen.writeStringField("itemName", value.itemName); + jgen.writeNumberField("owner", value.owner.id); jgen.writeEndObject(); } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index 71e1f4c69d26..e62b73e0ef7d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -1,11 +1,15 @@ package org.baeldung.jackson.test; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import java.io.IOException; +import org.baeldung.jackson.deserialization.ItemDeserializer; +import org.baeldung.jackson.dtos.Item; +import org.baeldung.jackson.dtos.ItemWithSerializer; import org.baeldung.jackson.dtos.MyDto; import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreUnknown; import org.junit.Test; @@ -18,7 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; - +import com.fasterxml.jackson.databind.module.SimpleModule; public class JacksonDeserializationUnitTest { @@ -130,4 +134,35 @@ public final void givenTheJsonNode_whenRetrievingDataFromId_thenCorrect() throws assertThat(jsonNode1.textValue(), equalTo("v1")); } + // custom deserialization + + @Test + public final void whenDeserializingTheStandardRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":{\"id\":2,\"name\":\"theUser\"}}"; + + final Item readValue = new ObjectMapper().readValue(json, Item.class); + assertThat(readValue, notNullValue()); + } + + @Test + public final void whenDeserializingANonStandardRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":2}"; + final ObjectMapper mapper = new ObjectMapper(); + + final SimpleModule module = new SimpleModule(); + module.addDeserializer(Item.class, new ItemDeserializer()); + mapper.registerModule(module); + + final Item readValue = mapper.readValue(json, Item.class); + assertThat(readValue, notNullValue()); + } + + @Test + public final void givenDeserializerIsOnClass_whenDeserializingCustomRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":2}"; + + final ItemWithSerializer readValue = new ObjectMapper().readValue(json, ItemWithSerializer.class); + assertThat(readValue, notNullValue()); + } + } From 0f9fef533742679e8dfab63a4140b8e312c92c41 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 15 Jan 2014 19:53:33 +0200 Subject: [PATCH 420/796] minor jaackson example and new streaming logic for large files --- .../java/CoreJavaIoIntegrationTest.java | 27 +++++++++++-- .../org/baeldung/jackson/try1/IEntity.java | 4 ++ .../try1/JacksonDeserializationUnitTest.java | 25 ++++++++++++ .../jackson/try1/RestLoaderRequest.java | 38 +++++++++++++++++++ .../try1/RestLoaderRequestDeserializer.java | 37 ++++++++++++++++++ 5 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/JacksonDeserializationUnitTest.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequest.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequestDeserializer.java diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java index f492ebf68f6e..66cea6df43c1 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java @@ -6,6 +6,7 @@ import java.util.Scanner; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.LineIterator; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,9 +30,9 @@ public final void givenUsingGuava_whenIteratingAFile_thenCorrect() throws IOExce } @Test - public final void givenUsingCommonsIo_whenIteratingAFile_thenCorrect() throws IOException { - final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; - // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + public final void givenUsingCommonsIo_whenIteratingAFileInMemory_thenCorrect() throws IOException { + // final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; logMemory(); FileUtils.readLines(new File(path)); @@ -70,6 +71,26 @@ public final void whenStreamingThroughAFile_thenCorrect() throws IOException { logMemory(); } + @Test + public final void givenUsingApacheIo_whenStreamingThroughAFile_thenCorrect() throws IOException { + final String path = "G:\\full\\train\\input\\" + "trainDataNegative.csv"; + // final String path = "G:\\full\\train\\input\\" + "trainDataPositive.csv"; + + logMemory(); + + final LineIterator it = FileUtils.lineIterator(new File(path), "UTF-8"); + try { + while (it.hasNext()) { + final String line = it.nextLine(); + // do something with line + } + } finally { + LineIterator.closeQuietly(it); + } + + logMemory(); + } + // utils private final void logMemory() { diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java b/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java new file mode 100644 index 000000000000..e7dfb560e242 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java @@ -0,0 +1,4 @@ +package org.baeldung.jackson.try1; +public interface IEntity { + public int getId(); +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonDeserializationUnitTest.java new file mode 100644 index 000000000000..673577cf6fd9 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/JacksonDeserializationUnitTest.java @@ -0,0 +1,25 @@ +package org.baeldung.jackson.try1; + +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.io.IOException; + +import org.baeldung.jackson.dtos.ItemWithSerializer; +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JacksonDeserializationUnitTest { + + @Test + public final void givenDeserializerIsOnClass_whenDeserializingCustomRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":2}"; + + final ItemWithSerializer readValue = new ObjectMapper().readValue(json, ItemWithSerializer.class); + assertThat(readValue, notNullValue()); + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequest.java b/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequest.java new file mode 100644 index 000000000000..171f4c1e1445 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequest.java @@ -0,0 +1,38 @@ +package org.baeldung.jackson.try1; + +import java.io.Serializable; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = RestLoaderRequestDeserializer.class) +// @Produces(MediaType.APPLICATION_JSON) +public class RestLoaderRequest implements Serializable { + private T entity; // entity to load field to + private String className; // actual class of entity + private String fieldName; // fieldName to lazy REST load + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(final String fieldName) { + this.fieldName = fieldName; + } + + public String getClassName() { + return className; + } + + public void setClassName(final String className) { + this.className = className; + } + + public T getEntity() { + return entity; + } + + public void setEntity(final T entity) { + this.entity = entity; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequestDeserializer.java b/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequestDeserializer.java new file mode 100644 index 000000000000..6110e8b0e07d --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/try1/RestLoaderRequestDeserializer.java @@ -0,0 +1,37 @@ +package org.baeldung.jackson.try1; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; + +public class RestLoaderRequestDeserializer extends JsonDeserializer> { + + @Override + public RestLoaderRequest deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + try { + final ObjectCodec objectCodec = jp.getCodec(); + final JsonNode node = objectCodec.readTree(jp); + final String className = node.get("className").textValue(); + final String fieldName = node.get("fieldName").textValue(); + + final Class clazz = Class.forName(className); + + final JsonNode rawEntityNode = node.get("entity"); + // How to deserialize rawEntityNode to T based on className ? + + final RestLoaderRequest request = new RestLoaderRequest(); + request.setClassName(className); + request.setFieldName(fieldName); + } catch (final ClassNotFoundException e) { + e.printStackTrace(); + } + + return null; + } + +} \ No newline at end of file From 52600ea3abf3d2d7931e5f5779e8d5c396b5ae15 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 17 Jan 2014 15:16:42 +0200 Subject: [PATCH 421/796] added InputStream to String examples --- .../org/baeldung/java/CoreJavaIoUnitTest.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java index a9eb9d18b1a5..d860d1ab4246 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java @@ -2,14 +2,17 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Scanner; @@ -24,12 +27,32 @@ public class CoreJavaIoUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); + private static final int DEFAULT_SIZE = 150000000; + + // private static final int DEFAULT_SIZE = 8; // tests - InputStream to String + // 11s + @Test + public void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + final StringBuilder textBuilder = new StringBuilder(); + try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) { + int c = 0; + while ((c = reader.read()) != -1) { + textBuilder.append((char) c); + } + } + assertEquals(textBuilder.toString(), originalString); + } + + // 8s @Test public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(8); + final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8); // When @@ -43,7 +66,7 @@ public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorre @Test public final void givenUsingGuava_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(8); + final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); final InputSupplier inputSupplier = new InputSupplier() { @@ -62,7 +85,7 @@ public final InputStream getInput() throws IOException { @Test public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(8); + final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // When @@ -76,7 +99,7 @@ public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_t @Test public final void givenUsingCommonsIo_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(8); + final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // When @@ -86,7 +109,7 @@ public final void givenUsingCommonsIo_whenConvertingAnInputStreamToAString_thenC @Test public final void givenUsingCommonsIoWithCopy_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(8); + final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // When From e04d2cd2e5e329dcd58d0e856b8b81243bbea9f6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 17 Jan 2014 17:49:53 +0200 Subject: [PATCH 422/796] initial work on starting projects --- starting/spring-jpa/.classpath | 37 +++ starting/spring-jpa/.gitignore | 13 ++ starting/spring-jpa/.project | 43 ++++ starting/spring-jpa/.settings/.jsdtscope | 12 + .../.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 55 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 6 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 15 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + starting/spring-jpa/.springBeans | 14 ++ starting/spring-jpa/README.md | 8 + starting/spring-jpa/pom.xml | 218 ++++++++++++++++++ .../persistence/dao/AbstractJpaDAO.java | 46 ++++ .../org/baeldung/persistence/dao/FooDao.java | 17 ++ .../org/baeldung/persistence/dao/IFooDao.java | 21 ++ .../org/baeldung/persistence/model/Foo.java | 83 +++++++ .../persistence/service/FooService.java | 26 +++ .../baeldung/spring/PersistenceJPAConfig.java | 85 +++++++ .../spring/PersistenceJPAConfigXml.java | 18 ++ .../src/main/resources/jpaConfig.xml | 43 ++++ .../spring-jpa/src/main/resources/logback.xml | 20 ++ .../resources/persistence-mysql.properties | 10 + .../src/main/resources/webSecurityConfig.xml | 36 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../src/main/webapp/WEB-INF/view/sample.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 21 ++ .../FooServicePersistenceIntegrationTest.java | 58 +++++ .../spring-jpa/src/test/resources/.gitignore | 13 ++ 33 files changed, 1046 insertions(+) create mode 100644 starting/spring-jpa/.classpath create mode 100644 starting/spring-jpa/.gitignore create mode 100644 starting/spring-jpa/.project create mode 100644 starting/spring-jpa/.settings/.jsdtscope create mode 100644 starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs create mode 100644 starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs create mode 100644 starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs create mode 100644 starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.common.component create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs create mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 starting/spring-jpa/.springBeans create mode 100644 starting/spring-jpa/README.md create mode 100644 starting/spring-jpa/pom.xml create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java create mode 100644 starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java create mode 100644 starting/spring-jpa/src/main/resources/jpaConfig.xml create mode 100644 starting/spring-jpa/src/main/resources/logback.xml create mode 100644 starting/spring-jpa/src/main/resources/persistence-mysql.properties create mode 100644 starting/spring-jpa/src/main/resources/webSecurityConfig.xml create mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp create mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/web.xml create mode 100644 starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java create mode 100644 starting/spring-jpa/src/test/resources/.gitignore diff --git a/starting/spring-jpa/.classpath b/starting/spring-jpa/.classpath new file mode 100644 index 000000000000..ca257cf1f962 --- /dev/null +++ b/starting/spring-jpa/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/starting/spring-jpa/.gitignore b/starting/spring-jpa/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/starting/spring-jpa/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/starting/spring-jpa/.project b/starting/spring-jpa/.project new file mode 100644 index 000000000000..235ae29ecfc3 --- /dev/null +++ b/starting/spring-jpa/.project @@ -0,0 +1,43 @@ + + + spring-jpa + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/starting/spring-jpa/.settings/.jsdtscope b/starting/spring-jpa/.settings/.jsdtscope new file mode 100644 index 000000000000..b46b9207a89e --- /dev/null +++ b/starting/spring-jpa/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs b/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..c201ee1f7a18 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs b/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs b/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs b/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.common.component b/starting/spring-jpa/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..0327e45de6dc --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml b/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..a67649dfa5ae --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs b/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..0d0aee4f7201 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,15 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 +disabled=06target +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs b/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/starting/spring-jpa/.springBeans b/starting/spring-jpa/.springBeans new file mode 100644 index 000000000000..7623a7e88836 --- /dev/null +++ b/starting/spring-jpa/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/starting/spring-jpa/README.md b/starting/spring-jpa/README.md new file mode 100644 index 000000000000..c62c4eabed74 --- /dev/null +++ b/starting/spring-jpa/README.md @@ -0,0 +1,8 @@ +========= + +## Spring JPA Example Project + + +### Relevant Articles: +- [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) +- [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) diff --git a/starting/spring-jpa/pom.xml b/starting/spring-jpa/pom.xml new file mode 100644 index 000000000000..849a62ee36d5 --- /dev/null +++ b/starting/spring-jpa/pom.xml @@ -0,0 +1,218 @@ + + 4.0.0 + + org.baeldung + spring-jpa + 0.1-SNAPSHOT + + war + spring-jpa + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.javassist + javassist + 3.18.1-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-jpa + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 4.0.0.RELEASE + 3.2.0.RELEASE + + + 4.3.0.Final + 5.1.28 + + + 1.7.5 + 1.0.11 + + + 5.0.2.Final + + + 16.0-rc1 + 3.2.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3 + 4.3.1 + + 2.1.0 + + + + 3.1 + 2.4 + 2.16 + 2.6 + 1.4.5 + + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java new file mode 100644 index 000000000000..13007d9fccef --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java @@ -0,0 +1,46 @@ +package org.baeldung.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +public abstract class AbstractJpaDAO { + + private Class clazz; + + @PersistenceContext + private EntityManager entityManager; + + public final void setClazz(final Class clazzToSet) { + this.clazz = clazzToSet; + } + + public T findOne(final long id) { + return entityManager.find(clazz, id); + } + + @SuppressWarnings("unchecked") + public List findAll() { + return entityManager.createQuery("from " + clazz.getName()).getResultList(); + } + + public void create(final T entity) { + entityManager.persist(entity); + } + + public T update(final T entity) { + return entityManager.merge(entity); + } + + public void delete(final T entity) { + entityManager.remove(entity); + } + + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + delete(entity); + } + +} \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java new file mode 100644 index 000000000000..77978c5cf282 --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java @@ -0,0 +1,17 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.model.Foo; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractJpaDAO implements IFooDao { + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 000000000000..f5799522e2fa --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,21 @@ +package org.baeldung.persistence.dao; + +import java.util.List; + +import org.baeldung.persistence.model.Foo; + +public interface IFooDao { + + Foo findOne(long id); + + List findAll(); + + void create(Foo entity); + + Foo update(Foo entity); + + void delete(Foo entity); + + void deleteById(long entityId); + +} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java new file mode 100644 index 000000000000..8e1dee33e845 --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..b07698c43854 --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,26 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class FooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + public void create(final Foo entity) { + dao.create(entity); + } + +} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java new file mode 100644 index 000000000000..3b36b47438e7 --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -0,0 +1,85 @@ +package org.baeldung.spring; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +// @Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-mysql.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) +public class PersistenceJPAConfig { + + @Autowired + private Environment env; + + public PersistenceJPAConfig() { + super(); + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + // vendorAdapter.set + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + + return em; + } + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(emf); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties additionalProperties() { + return new Properties() { + { + setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + // setProperty("hibernate.globally_quoted_identifiers", "true"); + // note: necessary in launchpad-storage, but causing problems here + } + }; + } + +} \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java new file mode 100644 index 000000000000..98f4f47249f6 --- /dev/null +++ b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java @@ -0,0 +1,18 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "org.baeldung.persistence" }) +@ImportResource({ "classpath:jpaConfig.xml" }) +public class PersistenceJPAConfigXml { + + public PersistenceJPAConfigXml() { + super(); + } + +} \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/jpaConfig.xml b/starting/spring-jpa/src/main/resources/jpaConfig.xml new file mode 100644 index 000000000000..a291786a5ce1 --- /dev/null +++ b/starting/spring-jpa/src/main/resources/jpaConfig.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/logback.xml b/starting/spring-jpa/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/starting/spring-jpa/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/persistence-mysql.properties b/starting/spring-jpa/src/main/resources/persistence-mysql.properties new file mode 100644 index 000000000000..c4de4ceb80a5 --- /dev/null +++ b/starting/spring-jpa/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_jpa_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/starting/spring-jpa/src/main/resources/webSecurityConfig.xml b/starting/spring-jpa/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..35dcb9c1ef53 --- /dev/null +++ b/starting/spring-jpa/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml b/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..a675fc6d954f --- /dev/null +++ b/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp b/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml b/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..90f2abc2f6c9 --- /dev/null +++ b/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,21 @@ + + + + Spring JPA Application + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + \ No newline at end of file diff --git a/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..2d8de007dbfc --- /dev/null +++ b/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,58 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceJPAConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test(expected = DataAccessException.class) + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + +} diff --git a/starting/spring-jpa/src/test/resources/.gitignore b/starting/spring-jpa/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/starting/spring-jpa/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 899e7afea6670a5f1606d8b58a5b08df3a135628 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 17 Jan 2014 17:54:32 +0200 Subject: [PATCH 423/796] cleanup work --- starting/spring-jpa/.project | 2 +- starting/spring-jpa/pom.xml | 65 +++++++------- .../persistence/dao/AbstractJpaDAO.java | 46 ---------- .../org/baeldung/persistence/dao/FooDao.java | 17 ---- .../org/baeldung/persistence/dao/IFooDao.java | 21 ----- .../org/baeldung/persistence/model/Foo.java | 83 ------------------ .../persistence/service/FooService.java | 26 ------ .../baeldung/spring/PersistenceJPAConfig.java | 85 ------------------- .../spring/PersistenceJPAConfigXml.java | 18 ---- .../FooServicePersistenceIntegrationTest.java | 58 ------------- 10 files changed, 32 insertions(+), 389 deletions(-) delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java delete mode 100644 starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java delete mode 100644 starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java diff --git a/starting/spring-jpa/.project b/starting/spring-jpa/.project index 235ae29ecfc3..20cc7fd450ed 100644 --- a/starting/spring-jpa/.project +++ b/starting/spring-jpa/.project @@ -1,6 +1,6 @@ - spring-jpa + spring-jpa-start diff --git a/starting/spring-jpa/pom.xml b/starting/spring-jpa/pom.xml index 849a62ee36d5..416b6f11e331 100644 --- a/starting/spring-jpa/pom.xml +++ b/starting/spring-jpa/pom.xml @@ -11,42 +11,39 @@ - - - - org.springframework - spring-web - ${org.springframework.version} - - org.springframework - spring-orm - ${org.springframework.version} + org.javassist + javassist + 3.18.1-GA + + + org.springframework spring-context ${org.springframework.version} + + + + + + - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - org.javassist - javassist - 3.18.1-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - + + + + + + + + + + + @@ -67,16 +64,16 @@ - org.apache.commons - commons-lang3 - ${commons-lang3.version} + org.springframework + spring-test + ${org.springframework.version} test - org.springframework - spring-test - ${org.springframework.version} + org.apache.commons + commons-lang3 + ${commons-lang3.version} test @@ -205,13 +202,13 @@ 2.1.0 - + 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.6 diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java deleted file mode 100644 index 13007d9fccef..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.baeldung.persistence.dao; - -import java.io.Serializable; -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -public abstract class AbstractJpaDAO { - - private Class clazz; - - @PersistenceContext - private EntityManager entityManager; - - public final void setClazz(final Class clazzToSet) { - this.clazz = clazzToSet; - } - - public T findOne(final long id) { - return entityManager.find(clazz, id); - } - - @SuppressWarnings("unchecked") - public List findAll() { - return entityManager.createQuery("from " + clazz.getName()).getResultList(); - } - - public void create(final T entity) { - entityManager.persist(entity); - } - - public T update(final T entity) { - return entityManager.merge(entity); - } - - public void delete(final T entity) { - entityManager.remove(entity); - } - - public void deleteById(final long entityId) { - final T entity = findOne(entityId); - delete(entity); - } - -} \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java deleted file mode 100644 index 77978c5cf282..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.Foo; -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao extends AbstractJpaDAO implements IFooDao { - - public FooDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java deleted file mode 100644 index f5799522e2fa..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.baeldung.persistence.dao; - -import java.util.List; - -import org.baeldung.persistence.model.Foo; - -public interface IFooDao { - - Foo findOne(long id); - - List findAll(); - - void create(Foo entity); - - Foo update(Foo entity); - - void delete(Foo entity); - - void deleteById(long entityId); - -} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java deleted file mode 100644 index 8e1dee33e845..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Foo implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(nullable = false) - private String name; - - public Foo() { - super(); - } - - public Foo(final String name) { - super(); - - this.name = name; - } - - // API - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Foo other = (Foo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Foo [name=").append(name).append("]"); - return builder.toString(); - } - -} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java b/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java deleted file mode 100644 index b07698c43854..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.model.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class FooService { - - @Autowired - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - public void create(final Foo entity) { - dao.create(entity); - } - -} diff --git a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java deleted file mode 100644 index 3b36b47438e7..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.baeldung.spring; - -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import com.google.common.base.Preconditions; - -// @Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) -public class PersistenceJPAConfig { - - @Autowired - private Environment env; - - public PersistenceJPAConfig() { - super(); - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { - final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - // vendorAdapter.set - em.setJpaVendorAdapter(vendorAdapter); - em.setJpaProperties(additionalProperties()); - - return em; - } - - @Bean - public DataSource dataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); - dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); - dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); - dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); - - return dataSource; - } - - @Bean - public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(emf); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - final Properties additionalProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; - } - -} \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java b/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java deleted file mode 100644 index 98f4f47249f6..000000000000 --- a/starting/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@ComponentScan({ "org.baeldung.persistence" }) -@ImportResource({ "classpath:jpaConfig.xml" }) -public class PersistenceJPAConfigXml { - - public PersistenceJPAConfigXml() { - super(); - } - -} \ No newline at end of file diff --git a/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java deleted file mode 100644 index 2d8de007dbfc..000000000000 --- a/starting/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -import org.baeldung.persistence.model.Foo; -import org.baeldung.spring.PersistenceJPAConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServicePersistenceIntegrationTest { - - @Autowired - private FooService service; - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Foo(randomAlphabetic(6))); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo()); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenEntityWithLongNameIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - @Test(expected = InvalidDataAccessApiUsageException.class) - public final void whenSameEntityIsCreatedTwice_thenDataException() { - final Foo entity = new Foo(randomAlphabetic(8)); - service.create(entity); - service.create(entity); - } - - @Test(expected = DataAccessException.class) - public final void temp_whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo()); - } - -} From 0d5f88e206a574b859e86c08ced795641a34a558 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 19 Jan 2014 12:15:32 +0200 Subject: [PATCH 424/796] minor cleanup --- starting/spring-jpa/src/main/java/.gitignore | 13 +++++++++++++ starting/spring-jpa/src/test/java/.gitignore | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 starting/spring-jpa/src/main/java/.gitignore create mode 100644 starting/spring-jpa/src/test/java/.gitignore diff --git a/starting/spring-jpa/src/main/java/.gitignore b/starting/spring-jpa/src/main/java/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/starting/spring-jpa/src/main/java/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/starting/spring-jpa/src/test/java/.gitignore b/starting/spring-jpa/src/test/java/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/starting/spring-jpa/src/test/java/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 29f02a2a8b6442350a4e2e26842c04b1fb38be5f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 Jan 2014 15:28:38 +0200 Subject: [PATCH 425/796] persistence cleanup --- .../{spring => config}/PersistenceJPAConfig.java | 8 +++++--- .../{spring => config}/PersistenceJPAConfigXml.java | 5 ++--- .../org/baeldung/persistence/service/FooService.java | 4 ++++ .../service/FooServicePersistenceIntegrationTest.java | 11 ++++++++++- 4 files changed, 21 insertions(+), 7 deletions(-) rename spring-jpa/src/main/java/org/baeldung/{spring => config}/PersistenceJPAConfig.java (96%) rename spring-jpa/src/main/java/org/baeldung/{spring => config}/PersistenceJPAConfigXml.java (80%) diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java similarity index 96% rename from spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java rename to spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java index 3b36b47438e7..ea729fde0ca0 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package org.baeldung.config; import java.util.Properties; @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -20,7 +21,7 @@ import com.google.common.base.Preconditions; -// @Configuration +@Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) @@ -33,6 +34,8 @@ public PersistenceJPAConfig() { super(); } + // beans + @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); @@ -40,7 +43,6 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - // vendorAdapter.set em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java similarity index 80% rename from spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java rename to spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java index 98f4f47249f6..3df36e62ee9e 100644 --- a/spring-jpa/src/main/java/org/baeldung/spring/PersistenceJPAConfigXml.java +++ b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java @@ -1,11 +1,10 @@ -package org.baeldung.spring; +package org.baeldung.config; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.transaction.annotation.EnableTransactionManagement; -@Configuration +// @Configuration @EnableTransactionManagement @ComponentScan({ "org.baeldung.persistence" }) @ImportResource({ "classpath:jpaConfig.xml" }) diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java index b07698c43854..b72e40a43085 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java @@ -23,4 +23,8 @@ public void create(final Foo entity) { dao.create(entity); } + public Foo findOne(final long id) { + return dao.findOne(id); + } + } diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 2d8de007dbfc..96b3235f6429 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -2,8 +2,9 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import org.baeldung.config.PersistenceJPAConfig; import org.baeldung.persistence.model.Foo; -import org.baeldung.spring.PersistenceJPAConfig; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -55,4 +56,12 @@ public final void temp_whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } + @Test + public final void whenEntityIsCreated_thenFound() { + final Foo fooEntity = new Foo("abc"); + service.create(fooEntity); + final Foo found = service.findOne(fooEntity.getId()); + Assert.assertNotNull(found); + } + } From 4c5bb1b1333ab47541f2cf58259af8f986b4c8dd Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 25 Jan 2014 17:11:42 +0200 Subject: [PATCH 426/796] httpclient - custom header --- .../httpclient/HttpClientHeadersLiveTest.java | 123 ++++++++++++++++++ .../httpclient/HttpClientLiveTest.java | 30 ----- 2 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java new file mode 100644 index 000000000000..081f83c90512 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java @@ -0,0 +1,123 @@ +package org.baeldung.httpclient; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.methods.RequestBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpProtocolParams; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class HttpClientHeadersLiveTest { + + private static final String SAMPLE_URL = "http://www.github.com"; + + private CloseableHttpClient client; + + private CloseableHttpResponse response; + + @Before + public final void before() { + client = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests - headers - deprecated + + @SuppressWarnings("deprecation") + @Test + public final void givenDeprecatedApi_whenClientUsesCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + client = new DefaultHttpClient(); + client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); + HttpProtocolParams.setUserAgent(client.getParams(), "Mozilla/5.0 Firefox/26.0"); + + final HttpGet request = new HttpGet(SAMPLE_URL); + response = client.execute(request); + } + + // tests - headers - user agent + + @Test + public final void givenConfigOnRequest_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + client = HttpClients.custom().build(); + final HttpGet request = new HttpGet(SAMPLE_URL); + request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); + response = client.execute(request); + } + + @Test + public final void givenConfigOnClient_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { + client = HttpClients.custom().setUserAgent("Mozilla/5.0 Firefox/26.0").build(); + response = client.execute(new HttpGet(SAMPLE_URL)); + } + + // tests - headers - content type + + @SuppressWarnings("deprecation") + @Test + public final void givenUsingDeprecatedApi_whenRequestHasCustomContentType_thenCorrect() throws ClientProtocolException, IOException { + client = new DefaultHttpClient(); + final HttpGet request = new HttpGet(SAMPLE_URL); + request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + response = client.execute(request); + } + + @SuppressWarnings("deprecation") + @Test + public final void givenRequestBuildWithBuilderWithDeprecatedApi_whenRequestHasCustomContentType_thenCorrect() throws ClientProtocolException, IOException { + final DefaultHttpClient client2 = new DefaultHttpClient(); + final HttpGet request = new HttpGet(SAMPLE_URL); + request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + response = client2.execute(request); + } + + @Test + public final void givenRequestBuildWithBuilder_whenRequestHasCustomContentType_thenCorrect() throws ClientProtocolException, IOException { + client = HttpClients.custom().build(); + final HttpUriRequest request = RequestBuilder.get().setUri(SAMPLE_URL).setHeader(HttpHeaders.CONTENT_TYPE, "application/json").build(); + response = client.execute(request); + } + + @Test + public final void givenConfigOnClient_whenRequestHasCustomContentType_thenCorrect() throws ClientProtocolException, IOException { + final Header header = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + final List
headers = Lists.newArrayList(header); + client = HttpClients.custom().setDefaultHeaders(headers).build(); + final HttpUriRequest request = RequestBuilder.get().setUri(SAMPLE_URL).build(); + response = client.execute(request); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java index e2c7a139f550..3a54b7e1b84e 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java @@ -16,12 +16,9 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; -import org.apache.http.params.CoreProtocolPNames; -import org.apache.http.params.HttpProtocolParams; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -89,33 +86,6 @@ public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCo assertThat(headers, not(emptyArray())); } - // tests - headers - - @SuppressWarnings("deprecation") - @Test - public final void givenDeprecatedApi_whenClientUsesCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { - final DefaultHttpClient client = new DefaultHttpClient(); - client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); - HttpProtocolParams.setUserAgent(client.getParams(), "Mozilla/5.0 Firefox/26.0"); - - final HttpGet request = new HttpGet(SAMPLE_URL); - response = client.execute(request); - } - - @Test - public final void givenDeprecatedApi_whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { - instance = HttpClients.custom().build(); - final HttpGet request = new HttpGet(SAMPLE_URL); - request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); - response = instance.execute(request); - } - - @Test - public final void whenRequestHasCustomUserAgent_thenCorrect() throws ClientProtocolException, IOException { - instance = HttpClients.custom().setUserAgent("Mozilla/5.0 Firefox/26.0").build(); - response = instance.execute(new HttpGet(SAMPLE_URL)); - } - // tests - cancel request @Test From 5b91988d0edc60452b7f187e5ef27b92e1afda2f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 26 Jan 2014 12:30:28 +0200 Subject: [PATCH 427/796] introducing parent-child context to experiment with properties and httpclient cleanup --- .../HttpClientUnshortenLiveTest.java | 4 +- spring-security-rest-custom/README.md | 1 - .../config/MainWebAppInitializer.java | 48 +++++++++++++++++++ .../{spring => config/child}/WebConfig.java | 2 +- .../parent/SecurityConfig.java} | 6 +-- .../baeldung/config/parent/ServiceConfig.java | 14 ++++++ .../java/org/baeldung/service/FooService.java | 20 ++++++++ .../org/baeldung/service/IFooService.java | 9 ++++ .../web/controller/FooController.java | 6 +-- .../src/main/webapp/WEB-INF/api-servlet.xml | 5 +- .../webapp/WEB-INF/{web.xml => web_old.xml} | 10 ++-- 11 files changed, 107 insertions(+), 18 deletions(-) rename spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java => httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java (98%) create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java rename spring-security-rest-custom/src/main/java/org/baeldung/{spring => config/child}/WebConfig.java (96%) rename spring-security-rest-custom/src/main/java/org/baeldung/{spring/SecSecurityConfig.java => config/parent/SecurityConfig.java} (77%) create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java create mode 100644 spring-security-rest-custom/src/main/java/org/baeldung/service/IFooService.java rename spring-security-rest-custom/src/main/webapp/WEB-INF/{web.xml => web_old.xml} (86%) diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java similarity index 98% rename from spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java rename to httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java index 19f8f5325e9f..7eef1cade88c 100644 --- a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.live; +package org.baeldung.httpclient; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; @@ -25,7 +25,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; -public class HttpLiveServiceTemp { +public class HttpClientUnshortenLiveTest { private CloseableHttpClient client; diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index 690d80a00980..3ec8cf92c71a 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -5,4 +5,3 @@ ### Relevant Articles: - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) -- [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java new file mode 100644 index 000000000000..0d2c2be7702f --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java @@ -0,0 +1,48 @@ +package org.baeldung.config; + +import java.util.Set; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + public MainWebAppInitializer() { + super(); + } + + // + + /** + * Register and configure all Servlet container components necessary to power the web application. + */ + @Override + public void onStartup(final ServletContext sc) throws ServletException { + System.out.println("MyWebAppInitializer.onStartup()"); + + // Create the 'root' Spring application context + final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.scan("org.baeldung.config.parent"); + // root.getEnvironment().setDefaultProfiles("embedded"); + + // Manages the lifecycle of the root application context + sc.addListener(new ContextLoaderListener(root)); + + // Handles requests into the application + final AnnotationConfigWebApplicationContext childWebApplicationContext = new AnnotationConfigWebApplicationContext(); + childWebApplicationContext.scan("org.baeldung.config.child"); + final ServletRegistration.Dynamic appServlet = sc.addServlet("api", new DispatcherServlet(childWebApplicationContext)); + appServlet.setLoadOnStartup(1); + final Set mappingConflicts = appServlet.addMapping("/"); + if (!mappingConflicts.isEmpty()) { + throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); + } + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java similarity index 96% rename from spring-security-rest-custom/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java index 8c3d677af601..bbddbe2bae51 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package org.baeldung.config.child; import java.util.List; diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java similarity index 77% rename from spring-security-rest-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java index 4ce80dab9f1c..ee9b0868e738 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package org.baeldung.config.parent; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -7,9 +7,9 @@ @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) @ComponentScan("org.baeldung.security") -public class SecSecurityConfig { +public class SecurityConfig { - public SecSecurityConfig() { + public SecurityConfig() { super(); } diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java new file mode 100644 index 000000000000..11ff616f8862 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.config.parent; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.service") +public class ServiceConfig { + + public ServiceConfig() { + super(); + } + +} \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java b/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java new file mode 100644 index 000000000000..0709426e1f4b --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java @@ -0,0 +1,20 @@ +package org.baeldung.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService implements IFooService { + + public FooService() { + super(); + } + + // API + + @Override + public Foo findOne(final Long id) { + return new Foo(); + } + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/service/IFooService.java b/spring-security-rest-custom/src/main/java/org/baeldung/service/IFooService.java new file mode 100644 index 000000000000..de234b1b4577 --- /dev/null +++ b/spring-security-rest-custom/src/main/java/org/baeldung/service/IFooService.java @@ -0,0 +1,9 @@ +package org.baeldung.service; + +import org.baeldung.web.dto.Foo; + +public interface IFooService { + + Foo findOne(final Long id); + +} diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java index ff5a00fd9509..4fa8b8094ead 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java @@ -1,8 +1,8 @@ package org.baeldung.web.controller; +import org.baeldung.service.IFooService; import org.baeldung.web.dto.Foo; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,7 +14,7 @@ public class FooController { @Autowired - private ApplicationEventPublisher eventPublisher; + private IFooService service; public FooController() { super(); @@ -25,7 +25,7 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public Foo findOne(@PathVariable("id") final Long id) { - return new Foo(); + return service.findOne(id); } } diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..d6e8f7549aff 100644 --- a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml similarity index 86% rename from spring-security-rest-custom/src/main/webapp/WEB-INF/web.xml rename to spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml index 372688c8d87e..950bbab5059c 100644 --- a/spring-security-rest-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml @@ -15,7 +15,7 @@ contextConfigLocation - org.baeldung.spring + org.baeldung.config.parent @@ -26,6 +26,10 @@ api org.springframework.web.servlet.DispatcherServlet + + + + 1 @@ -44,8 +48,4 @@ /* - - - - \ No newline at end of file From c3820519cbe3d4bb42e4e4ec9098f925329c14b0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 26 Jan 2014 14:41:33 +0200 Subject: [PATCH 428/796] parent-child contexts, properties file included in each --- spring-security-rest-custom/.springBeans | 3 +-- .../config/MainWebAppInitializer.java | 7 +++++++ .../org/baeldung/config/child/WebConfig.java | 13 ++++++++++++- .../baeldung/config/parent/ServiceConfig.java | 14 ++++++++++++++ .../java/org/baeldung/service/FooService.java | 18 +++++++++++++++++- .../web/controller/FooController.java | 19 +++++++++++++++++-- .../src/main/resources/foo.properties | 2 ++ .../src/main/resources/prop.xml | 13 +++++++++++++ .../src/main/webapp/WEB-INF/api-servlet.xml | 5 ----- .../src/main/webapp/WEB-INF/web_old.xml | 1 - 10 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 spring-security-rest-custom/src/main/resources/foo.properties create mode 100644 spring-security-rest-custom/src/main/resources/prop.xml delete mode 100644 spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest-custom/.springBeans b/spring-security-rest-custom/.springBeans index a79097f40d30..f25fc5ab49de 100644 --- a/spring-security-rest-custom/.springBeans +++ b/spring-security-rest-custom/.springBeans @@ -1,13 +1,12 @@ 1 - + - src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java index 0d2c2be7702f..0a11cdab724d 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/MainWebAppInitializer.java @@ -2,6 +2,7 @@ import java.util.Set; +import javax.servlet.FilterRegistration.Dynamic; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; @@ -9,6 +10,7 @@ import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.servlet.DispatcherServlet; public class MainWebAppInitializer implements WebApplicationInitializer { @@ -43,6 +45,11 @@ public void onStartup(final ServletContext sc) throws ServletException { if (!mappingConflicts.isEmpty()) { throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); } + + // spring security filter + final DelegatingFilterProxy springSecurityFilterChain = new DelegatingFilterProxy("springSecurityFilterChain"); + final Dynamic addedFilter = sc.addFilter("springSecurityFilterChain", springSecurityFilterChain); + addedFilter.addMappingForUrlPatterns(null, false, "/*"); } } diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java index bbddbe2bae51..0c2042f711bd 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java @@ -2,8 +2,10 @@ import java.util.List; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -12,6 +14,8 @@ @Configuration @EnableWebMvc @ComponentScan("org.baeldung.web") +// @ImportResource({ "classpath:prop.xml" }) +// @PropertySource("classpath:foo.properties") public class WebConfig extends WebMvcConfigurerAdapter { public WebConfig() { @@ -26,6 +30,13 @@ public void configureMessageConverters(final List> conve converters.add(new MappingJackson2HttpMessageConverter()); } - // + // beans + + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); + ppc.setIgnoreUnresolvablePlaceholders(true); + return ppc; + } } \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java index 11ff616f8862..02af0165f484 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/ServiceConfig.java @@ -1,14 +1,28 @@ package org.baeldung.config.parent; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration @ComponentScan("org.baeldung.service") +// @ImportResource({ "classpath:prop.xml" }) +@PropertySource("classpath:foo.properties") public class ServiceConfig { public ServiceConfig() { super(); } + // beans + + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); + ppc.setIgnoreUnresolvablePlaceholders(true); + return ppc; + } + } \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java b/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java index 0709426e1f4b..cb374ae4b02f 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/service/FooService.java @@ -1,10 +1,20 @@ package org.baeldung.service; import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; @Service -public class FooService implements IFooService { +public class FooService implements IFooService, InitializingBean { + + @Value("${foo1}") + private String foo1; + + @Autowired + private Environment env; public FooService() { super(); @@ -17,4 +27,10 @@ public Foo findOne(final Long id) { return new Foo(); } + @Override + public final void afterPropertiesSet() { + System.out.println("In Parent Context, property via @Value = " + foo1); + System.out.println("In Parent Context, property via env = " + env.getProperty("foo2")); + } + } diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java index 4fa8b8094ead..74fd5e403f57 100644 --- a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/FooController.java @@ -2,7 +2,10 @@ import org.baeldung.service.IFooService; import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,8 +13,14 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller -@RequestMapping(value = "/foo") -public class FooController { +@RequestMapping(value = "/foos") +public class FooController implements InitializingBean { + + @Value("${foo1}") + private String foo1; + + @Autowired + private Environment env; @Autowired private IFooService service; @@ -28,4 +37,10 @@ public Foo findOne(@PathVariable("id") final Long id) { return service.findOne(id); } + @Override + public final void afterPropertiesSet() { + System.out.println("In Child Context, property via @Value = " + foo1); + System.out.println("In Child Context, property via env = " + env.getProperty("foo2")); + } + } diff --git a/spring-security-rest-custom/src/main/resources/foo.properties b/spring-security-rest-custom/src/main/resources/foo.properties new file mode 100644 index 000000000000..3fe2eceff0a2 --- /dev/null +++ b/spring-security-rest-custom/src/main/resources/foo.properties @@ -0,0 +1,2 @@ +foo1=bar1 +foo2=bar2 \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/resources/prop.xml b/spring-security-rest-custom/src/main/resources/prop.xml new file mode 100644 index 000000000000..4c11f2154cce --- /dev/null +++ b/spring-security-rest-custom/src/main/resources/prop.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml deleted file mode 100644 index d6e8f7549aff..000000000000 --- a/spring-security-rest-custom/src/main/webapp/WEB-INF/api-servlet.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml index 950bbab5059c..15f790d77a29 100644 --- a/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml +++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml @@ -37,7 +37,6 @@ /api/* - springSecurityFilterChain From 281cb6a31c542bafec3e18b69d9039a0e661ac40 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 30 Jan 2014 20:49:50 +0200 Subject: [PATCH 429/796] httpclient auth work --- .../src/main/webapp/WEB-INF/api-servlet.xml | 6 -- httpclient/src/main/webapp/WEB-INF/web.xml | 42 ----------- .../httpclient/HttpClientAuthLiveTest.java | 27 ++++--- .../httpclient/HttpClientSandboxLiveTest.java | 67 +++++++++++++++++ httpclient/src/test/resources/sandbox.txt | 50 +++++++++++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 +- .../src/main/webapp/WEB-INF/web.xml | 75 ++++++++++--------- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/web.xml | 74 +++++++++--------- 9 files changed, 211 insertions(+), 137 deletions(-) delete mode 100644 httpclient/src/main/webapp/WEB-INF/api-servlet.xml delete mode 100644 httpclient/src/main/webapp/WEB-INF/web.xml create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java create mode 100644 httpclient/src/test/resources/sandbox.txt diff --git a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml deleted file mode 100644 index a675fc6d954f..000000000000 --- a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/httpclient/src/main/webapp/WEB-INF/web.xml b/httpclient/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 48d4b8fe61af..000000000000 --- a/httpclient/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - Spring MVC Application - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.config - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - / - - - - - - - \ No newline at end of file diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java index beb5abbeead4..6614b05cc35f 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java @@ -23,6 +23,10 @@ public class HttpClientAuthLiveTest { + private static final String URL_SECURED_BY_BASIC_AUTHENTICATION = "http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"; + private static final String DEFAULT_USER = "user1"; + private static final String DEFAULT_PASS = "user1Pass"; + private CloseableHttpClient instance; private CloseableHttpResponse response; @@ -51,22 +55,23 @@ public final void after() throws IllegalStateException, IOException { // tests - // simple request - response - @Test - public final void whenExecutingBasicGetRequest_thenNoExceptions() throws ClientProtocolException, IOException { - final CredentialsProvider provider = new BasicCredentialsProvider(); - final AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user1", "user1Pass"); - - provider.setCredentials(scope, credentials); - - instance = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); + public final void whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws ClientProtocolException, IOException { + instance = HttpClientBuilder.create().setDefaultCredentialsProvider(provider()).build(); - response = instance.execute(new HttpGet("http://localhost:8080/spring-security-mvc-basic-auth/homepage.html")); + response = instance.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION)); final int statusCode = response.getStatusLine().getStatusCode(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); } + // UTILS + + private final CredentialsProvider provider() { + final CredentialsProvider provider = new BasicCredentialsProvider(); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS); + provider.setCredentials(AuthScope.ANY, credentials); + return provider; + } + } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java new file mode 100644 index 000000000000..e3661ffbd9c6 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java @@ -0,0 +1,67 @@ +package org.baeldung.httpclient; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.HttpEntity; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientSandboxLiveTest { + + private CloseableHttpClient client; + + private CloseableHttpResponse response; + + @Before + public final void before() { + client = HttpClientBuilder.create().build(); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + // EntityUtils.consume(entity); + final InputStream instream = entity.getContent(); + instream.close(); + } + } finally { + response.close(); + } + } + + // tests + + // simple request - response + + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { + final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + final AuthScope authscp = new AuthScope("api.calltrackingmetrics.com", 443); + credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("mykey", "mysecret")); + final HttpClientContext localContext = HttpClientContext.create(); + localContext.setCredentialsProvider(credentialsProvider); + final HttpGet httpGet = new HttpGet("https://api.calltrackingmetrics.com/api/v1/accounts/myaccout/calls.json"); + response = client.execute(httpGet); + + System.out.println(response.getStatusLine()); + } + +} diff --git a/httpclient/src/test/resources/sandbox.txt b/httpclient/src/test/resources/sandbox.txt new file mode 100644 index 000000000000..9925166fa6c2 --- /dev/null +++ b/httpclient/src/test/resources/sandbox.txt @@ -0,0 +1,50 @@ +web - 2014-01-30 20:48:07,161 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match +web - 2014-01-30 20:48:07,171 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context +web - 2014-01-30 20:48:07,172 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20] +web - 2014-01-30 20:48:07,185 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20] +web - 2014-01-30 20:48:07,190 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://localhost:8080 +web - 2014-01-30 20:48:07,192 [main] DEBUG o.a.h.c.HttpClientConnectionManager - Connecting to localhost/127.0.0.1:8080 +web - 2014-01-30 20:48:07,193 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /spring-security-rest-basic-auth/api/foos/1 HTTP/1.1 +web - 2014-01-30 20:48:07,193 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED +web - 2014-01-30 20:48:07,193 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED +web - 2014-01-30 20:48:07,194 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /spring-security-rest-basic-auth/api/foos/1 HTTP/1.1 +web - 2014-01-30 20:48:07,194 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: localhost:8080 +web - 2014-01-30 20:48:07,194 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive +web - 2014-01-30 20:48:07,194 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.1 (java 1.5) +web - 2014-01-30 20:48:07,194 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 401 Unauthorized +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Apache-Coyote/1.1 +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << WWW-Authenticate: Basic realm="Spring Security Application" +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/html;charset=utf-8 +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Language: en +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 1061 +web - 2014-01-30 20:48:07,203 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Thu, 30 Jan 2014 18:48:07 GMT +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.http.impl.auth.HttpAuthenticator - Authentication required +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.http.impl.auth.HttpAuthenticator - localhost:8080 requested authentication +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Authentication schemes in the order of preference: [negotiate, Kerberos, NTLM, Digest, Basic] +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Challenge for negotiate authentication scheme not available +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Challenge for Kerberos authentication scheme not available +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Challenge for NTLM authentication scheme not available +web - 2014-01-30 20:48:07,206 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Challenge for Digest authentication scheme not available +web - 2014-01-30 20:48:07,213 [main] DEBUG o.a.http.impl.auth.HttpAuthenticator - Selected authentication options: [BASIC] +web - 2014-01-30 20:48:07,214 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /spring-security-rest-basic-auth/api/foos/1 HTTP/1.1 +web - 2014-01-30 20:48:07,214 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: CHALLENGED +web - 2014-01-30 20:48:07,214 [main] DEBUG o.a.http.impl.auth.HttpAuthenticator - Generating response to an authentication challenge using basic scheme +web - 2014-01-30 20:48:07,215 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /spring-security-rest-basic-auth/api/foos/1 HTTP/1.1 +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: localhost:8080 +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.1 (java 1.5) +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate +web - 2014-01-30 20:48:07,215 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Basic dXNlcjE6dXNlcjFQYXNz +web - 2014-01-30 20:48:07,217 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK +web - 2014-01-30 20:48:07,217 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Apache-Coyote/1.1 +web - 2014-01-30 20:48:07,217 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json;charset=UTF-8 +web - 2014-01-30 20:48:07,217 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked +web - 2014-01-30 20:48:07,217 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Thu, 30 Jan 2014 18:48:07 GMT +web - 2014-01-30 20:48:07,218 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely +web - 2014-01-30 20:48:07,218 [main] DEBUG o.a.http.impl.auth.HttpAuthenticator - Authentication succeeded +web - 2014-01-30 20:48:07,219 [main] DEBUG o.a.h.i.c.TargetAuthenticationStrategy - Caching 'basic' auth scheme for http://localhost:8080 +web - 2014-01-30 20:48:07,227 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://localhost:8080] can be kept alive indefinitely +web - 2014-01-30 20:48:07,227 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://localhost:8080][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20] diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..d6e8f7549aff 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index 0d08bdb9b9a9..08183daa249f 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -1,37 +1,42 @@ - - Spring Security Basic Auth Application - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - index.html - + + Spring Security Basic Auth Application + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + + \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml index de4a235b1e48..a0f45d48f25b 100644 --- a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml index 1ab8806632b2..6b707294061b 100644 --- a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -1,46 +1,42 @@ - + - Spring Security Custom Application + Spring Security Custom Application - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + \ No newline at end of file From 648493db94d1f317b18f2b826e480fa9939cc3dc Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 30 Jan 2014 21:14:12 +0200 Subject: [PATCH 430/796] auth work --- .../httpclient/HttpClientAuthLiveTest.java | 8 ++++---- .../httpclient/HttpClientSandboxLiveTest.java | 18 ++++++------------ httpclient/src/test/resources/sandbox.txt | 1 - 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java index 6614b05cc35f..df55de7d3a9c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java @@ -27,13 +27,13 @@ public class HttpClientAuthLiveTest { private static final String DEFAULT_USER = "user1"; private static final String DEFAULT_PASS = "user1Pass"; - private CloseableHttpClient instance; + private CloseableHttpClient client; private CloseableHttpResponse response; @Before public final void before() { - instance = HttpClientBuilder.create().build(); + client = HttpClientBuilder.create().build(); } @After @@ -57,9 +57,9 @@ public final void after() throws IllegalStateException, IOException { @Test public final void whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws ClientProtocolException, IOException { - instance = HttpClientBuilder.create().setDefaultCredentialsProvider(provider()).build(); + client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider()).build(); - response = instance.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION)); + response = client.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION)); final int statusCode = response.getStatusLine().getStatusCode(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java index e3661ffbd9c6..d8e687df1b5b 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java @@ -10,12 +10,10 @@ import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.junit.After; -import org.junit.Before; import org.junit.Test; public class HttpClientSandboxLiveTest { @@ -24,11 +22,6 @@ public class HttpClientSandboxLiveTest { private CloseableHttpResponse response; - @Before - public final void before() { - client = HttpClientBuilder.create().build(); - } - @After public final void after() throws IllegalStateException, IOException { if (response == null) { @@ -54,11 +47,12 @@ public final void after() throws IllegalStateException, IOException { @Test public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - final AuthScope authscp = new AuthScope("api.calltrackingmetrics.com", 443); - credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("mykey", "mysecret")); - final HttpClientContext localContext = HttpClientContext.create(); - localContext.setCredentialsProvider(credentialsProvider); - final HttpGet httpGet = new HttpGet("https://api.calltrackingmetrics.com/api/v1/accounts/myaccout/calls.json"); + final AuthScope authscp = new AuthScope("localhost", 8080); + credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("user1", "user1Pass")); + + client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build(); + + final HttpGet httpGet = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"); response = client.execute(httpGet); System.out.println(response.getStatusLine()); diff --git a/httpclient/src/test/resources/sandbox.txt b/httpclient/src/test/resources/sandbox.txt index 9925166fa6c2..e0352ba83993 100644 --- a/httpclient/src/test/resources/sandbox.txt +++ b/httpclient/src/test/resources/sandbox.txt @@ -1,4 +1,3 @@ -web - 2014-01-30 20:48:07,161 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match web - 2014-01-30 20:48:07,171 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context web - 2014-01-30 20:48:07,172 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20] web - 2014-01-30 20:48:07,185 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20] From 4a4cf8491e8023d90fd9d0c7e472a3e4dba8273f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 31 Jan 2014 23:51:15 +0200 Subject: [PATCH 431/796] basic authentication work --- .../httpclient/HttpClientAuthLiveTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java index df55de7d3a9c..65aa059e6241 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java @@ -5,18 +5,27 @@ import java.io.IOException; import java.io.InputStream; +import java.nio.charset.Charset; +import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpHost; import org.apache.http.HttpStatus; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.AuthCache; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.protocol.HttpContext; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -65,6 +74,42 @@ public final void whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_the assertThat(statusCode, equalTo(HttpStatus.SC_OK)); } + @Test + public final void givenAuthenticationIsPreemptive_whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws ClientProtocolException, IOException { + client = HttpClientBuilder.create().build(); + response = client.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION), context()); + + final int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + + @Test + public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess() throws ClientProtocolException, IOException { + client = HttpClientBuilder.create().build(); + + final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION); + request.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeader(DEFAULT_USER, DEFAULT_PASS)); + response = client.execute(request); + + final int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + + @Test + public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess2() throws ClientProtocolException, IOException { + final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION); + final String auth = DEFAULT_USER + ":" + DEFAULT_PASS; + final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); + final String authHeader = "Basic " + new String(encodedAuth); + request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); + + client = HttpClientBuilder.create().build(); + response = client.execute(request); + + final int statusCode = response.getStatusLine().getStatusCode(); + assertThat(statusCode, equalTo(HttpStatus.SC_OK)); + } + // UTILS private final CredentialsProvider provider() { @@ -74,4 +119,30 @@ private final CredentialsProvider provider() { return provider; } + private final HttpContext context() { + final HttpHost targetHost = new HttpHost("localhost", 8080, "http"); + final CredentialsProvider credsProvider = new BasicCredentialsProvider(); + credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS)); + + // Create AuthCache instance + final AuthCache authCache = new BasicAuthCache(); + // Generate BASIC scheme object and add it to the local auth cache + authCache.put(targetHost, new BasicScheme()); + + // Add AuthCache to the execution context + final HttpClientContext context = HttpClientContext.create(); + context.setCredentialsProvider(credsProvider); + context.setAuthCache(authCache); + + return context; + } + + private final String authorizationHeader(final String username, final String password) { + final String auth = username + ":" + password; + final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); + final String authHeader = "Basic " + new String(encodedAuth); + + return authHeader; + } + } From 512fb68c90dffdf9adf00860753423a7dda6f0b1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 00:29:52 +0200 Subject: [PATCH 432/796] maven upgrades --- core-java/pom.xml | 18 +++++++++--------- experiments/pom.xml | 18 +++++++++--------- guava/pom.xml | 18 +++++++++--------- httpclient/pom.xml | 16 ++++++++-------- jackson/pom.xml | 16 ++++++++-------- mockito/pom.xml | 18 +++++++++--------- rest-testing/pom.xml | 12 ++++++------ spring-all/pom.xml | 18 +++++++++--------- spring-exceptions/pom.xml | 18 +++++++++--------- spring-hibernate3/pom.xml | 16 ++++++++-------- spring-hibernate4/pom.xml | 18 +++++++++--------- spring-jpa/pom.xml | 18 +++++++++--------- spring-mvc-java/pom.xml | 16 ++++++++-------- spring-mvc-no-xml/pom.xml | 10 +++++----- spring-mvc-xml/pom.xml | 10 +++++----- spring-rest/pom.xml | 12 ++++++------ spring-security-basic-auth/pom.xml | 18 +++++++++--------- spring-security-mvc-custom/pom.xml | 18 +++++++++--------- spring-security-mvc-digest-auth/pom.xml | 18 +++++++++--------- spring-security-mvc-login/pom.xml | 18 +++++++++--------- spring-security-mvc-session/pom.xml | 18 +++++++++--------- spring-security-rest-basic-auth/pom.xml | 16 ++++++++-------- spring-security-rest-custom/pom.xml | 18 +++++++++--------- spring-security-rest-digest-auth/pom.xml | 18 +++++++++--------- spring-security-rest-full/pom.xml | 18 +++++++++--------- spring-security-rest/pom.xml | 18 +++++++++--------- 26 files changed, 215 insertions(+), 215 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index a07602e57003..2d5210fa753e 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -133,12 +133,12 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 2.3.0 @@ -148,10 +148,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -159,17 +159,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/experiments/pom.xml b/experiments/pom.xml index 369d6278b97d..912dcaf49f9e 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,22 +255,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -278,17 +278,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/guava/pom.xml b/guava/pom.xml index 8dc777de7790..8cb19e61f5c7 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,22 +94,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -117,17 +117,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index ab120746dee3..78c0219ad6ea 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -124,22 +124,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -148,16 +148,16 @@ 1.9.5 4.3.1 - 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/jackson/pom.xml b/jackson/pom.xml index 8de8dfd5d802..0067215d7e77 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,12 +107,12 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 2.3.0 @@ -122,10 +122,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -133,10 +133,10 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 diff --git a/mockito/pom.xml b/mockito/pom.xml index 5f28802cce2a..d162bbcf0085 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,22 +89,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -112,17 +112,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index c96af8924da7..e4e50271d6d2 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -138,7 +138,7 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 2.3.0 @@ -148,10 +148,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -160,16 +160,16 @@ 1.9.5 4.3.1 - 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 6052f76823f3..041139f3b80d 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,24 +192,24 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE 3.18.1-GA 1.2 - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -217,10 +217,10 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 @@ -228,7 +228,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index e80ede909a9b..c1dc189aa4ca 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,14 +204,14 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE 3.18.1-GA 1.2 - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 7.0.42 @@ -219,10 +219,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -230,10 +230,10 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 1.8.9 @@ -241,7 +241,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 1cad62d30b64..78f7d6bbf2dd 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,13 +174,13 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE 3.18.1-GA 3.6.10.Final - 5.1.28 + 5.1.29 7.0.47 @@ -188,10 +188,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -199,17 +199,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index ec1c284ef8ae..a69fdac5c1b1 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,13 +182,13 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE 3.18.1-GA - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 7.0.42 @@ -196,10 +196,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -207,10 +207,10 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 @@ -218,7 +218,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 849a62ee36d5..ed78ee29e4b6 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,22 +177,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -200,10 +200,10 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 @@ -211,7 +211,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 86614199803c..75cf27c2c5b7 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,22 +141,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -164,8 +164,8 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 2.0.1 @@ -174,7 +174,7 @@ 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 76187c2c7c7f..d0af83906d2a 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 1.7.5 @@ -156,17 +156,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index f53e1b2a2d6c..89da53e5854e 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,7 +141,7 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 1.7.5 @@ -152,17 +152,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 13f384c92675..ee07d30e462a 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,22 +202,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 2.3.0 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -226,7 +226,7 @@ 1.9.5 4.3.1 - 4.3.1 + 4.3.2 2.2.0 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index d32a3169eb96..b060f67c1734 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -220,22 +220,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -243,17 +243,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index a61c49352cc6..f16e71a82174 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -225,22 +225,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -248,17 +248,17 @@ 4.11 1.9.5 - 4.3.1 - 4.3 + 4.3.2 + 4.3.1 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 5147a3f1b447..b1b699cd60e4 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -220,22 +220,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -243,17 +243,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index e26b65f0ef59..54dcd87924df 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -217,22 +217,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -240,17 +240,17 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index b1d769083dce..9567e05d9b0d 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -225,22 +225,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -248,17 +248,17 @@ 4.11 1.9.5 - 4.3.1 - 4.3 + 4.3.2 + 4.3.1 - 2.1.0 + 2.3.0 3.1 2.4 2.16 2.6 - 1.4.5 + 1.4.7 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index eb2e95725200..78bb86ccee0c 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -286,26 +286,26 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 4.3.1 - 4.3.1 + 4.3.2 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -313,13 +313,13 @@ 4.11 1.9.5 - 2.1.0 + 2.3.0 3.1 2.4 2.16 - 1.4.5 + 1.4.7 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 2cea3553ab5d..37a9cfe1c065 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -242,22 +242,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -265,16 +265,16 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 - 1.4.5 + 1.4.7 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 381974eabc35..585f0110f10b 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,26 +275,26 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -302,13 +302,13 @@ 4.11 1.9.5 - 2.1.0 + 2.3.0 3.1 2.4 2.16 - 1.4.5 + 1.4.7 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index b93c13fc172d..1816856f4cbc 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -270,12 +270,12 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.4.3.RELEASE @@ -287,10 +287,10 @@ 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -298,16 +298,16 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 - 1.4.5 + 1.4.7 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index cdb279792202..5bc19094e9b2 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -208,22 +208,22 @@ - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE - 4.3.0.Final - 5.1.28 + 4.3.1.Final + 5.1.29 1.7.5 1.0.11 - 5.0.2.Final + 5.0.3.Final - 16.0-rc1 + 16.0.1 3.2.1 @@ -231,16 +231,16 @@ 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.1 + 4.3.2 - 2.1.0 + 2.3.0 3.1 2.4 2.16 - 1.4.5 + 1.4.7 From 18cdfdc62abd44de1bf5e2b11e180acd76086133 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 00:52:06 +0200 Subject: [PATCH 433/796] Using the new Location support --- .../baeldung/web/controller/FooController.java | 4 ++-- .../org/baeldung/web/util/ResourceCreated.java | 9 +-------- .../ResourceCreatedDiscoverabilityListener.java | 16 ++++++++-------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 32db49f9a7d0..d734a6748beb 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -79,11 +79,11 @@ public List findPaginated(@RequestParam("page") final int page, @RequestPar @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + public void create(@RequestBody final Foo resource, final HttpServletResponse response) { Preconditions.checkNotNull(resource); final Long idOfCreatedResource = service.create(resource).getId(); - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + eventPublisher.publishEvent(new ResourceCreated(this, response, idOfCreatedResource)); } } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java index c471cc08180b..8f0e85b5bc8c 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java @@ -1,19 +1,16 @@ package org.baeldung.web.util; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; public class ResourceCreated extends ApplicationEvent { private final HttpServletResponse response; - private final HttpServletRequest request; private final long idOfNewResource; - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + public ResourceCreated(final Object source, final HttpServletResponse response, final long idOfNewResource) { super(source); - this.request = request; this.response = response; this.idOfNewResource = idOfNewResource; } @@ -24,10 +21,6 @@ public HttpServletResponse getResponse() { return response; } - public HttpServletRequest getRequest() { - return request; - } - public long getIdOfNewResource() { return idOfNewResource; } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java index fbfd2fd085c5..aaceac07378a 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java @@ -2,15 +2,14 @@ import java.net.URI; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.HttpHeaders; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import com.google.common.base.Preconditions; -import com.google.common.net.HttpHeaders; @Component class ResourceCreatedDiscoverabilityListener implements ApplicationListener { @@ -19,16 +18,17 @@ class ResourceCreatedDiscoverabilityListener implements ApplicationListener Date: Thu, 13 Feb 2014 00:59:29 +0200 Subject: [PATCH 434/796] HATEOAS cleanup --- .../web/controller/FooController.java | 10 +++--- .../baeldung/web/hateoas/ResourceCreated.java | 33 ------------------- .../web/hateoas/SingleResourceRetrieved.java | 26 --------------- .../PaginatedResultsRetrievedEvent.java | 2 +- .../event/ResourceCreatedEvent.java} | 6 ++-- .../event/SingleResourceRetrievedEvent.java} | 8 ++--- ...sultsRetrievedDiscoverabilityListener.java | 3 +- ...esourceCreatedDiscoverabilityListener.java | 7 ++-- ...ourceRetrievedDiscoverabilityListener.java | 8 +++-- 9 files changed, 24 insertions(+), 79 deletions(-) delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java delete mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java rename spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/{ => event}/PaginatedResultsRetrievedEvent.java (97%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{util/ResourceCreated.java => hateoas/event/ResourceCreatedEvent.java} (68%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{util/SingleResourceRetrieved.java => hateoas/event/SingleResourceRetrievedEvent.java} (67%) rename spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/{ => listener}/PaginatedResultsRetrievedDiscoverabilityListener.java (97%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{util => hateoas/listener}/ResourceCreatedDiscoverabilityListener.java (84%) rename spring-security-rest-full/src/main/java/org/baeldung/web/{util => hateoas/listener}/SingleResourceRetrievedDiscoverabilityListener.java (84%) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index d734a6748beb..1462b4c9ca27 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -8,10 +8,10 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.web.exception.MyResourceNotFoundException; -import org.baeldung.web.hateoas.PaginatedResultsRetrievedEvent; -import org.baeldung.web.util.ResourceCreated; +import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; +import org.baeldung.web.hateoas.event.ResourceCreatedEvent; +import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; import org.baeldung.web.util.RestPreconditions; -import org.baeldung.web.util.SingleResourceRetrieved; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; @@ -51,7 +51,7 @@ public FooController() { public Foo findById(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + eventPublisher.publishEvent(new SingleResourceRetrievedEvent(this, request, response)); return resourceById; } @@ -83,7 +83,7 @@ public void create(@RequestBody final Foo resource, final HttpServletResponse re Preconditions.checkNotNull(resource); final Long idOfCreatedResource = service.create(resource).getId(); - eventPublisher.publishEvent(new ResourceCreated(this, response, idOfCreatedResource)); + eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource)); } } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java deleted file mode 100644 index 3a2c8d31871e..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.baeldung.web.hateoas; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class ResourceCreated extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - private final long idOfNewResource; - - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - super(source); - - this.request = request; - this.response = response; - this.idOfNewResource = idOfNewResource; - } - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - - public long getIdOfNewResource() { - return idOfNewResource; - } - -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java deleted file mode 100644 index 8a115a1ff61a..000000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.baeldung.web.hateoas; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class SingleResourceRetrieved extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { - super(source); - - this.request = request; - this.response = response; - } - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java index a9fe55ed3f1a..01f7e658f18d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.web.hateoas; +package org.baeldung.web.hateoas.event; import java.io.Serializable; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java similarity index 68% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java index 8f0e85b5bc8c..efc04299bc35 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java @@ -1,14 +1,14 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.event; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; -public class ResourceCreated extends ApplicationEvent { +public class ResourceCreatedEvent extends ApplicationEvent { private final HttpServletResponse response; private final long idOfNewResource; - public ResourceCreated(final Object source, final HttpServletResponse response, final long idOfNewResource) { + public ResourceCreatedEvent(final Object source, final HttpServletResponse response, final long idOfNewResource) { super(source); this.response = response; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java similarity index 67% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java index 143a73da652d..e71fde51e2aa 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java @@ -1,15 +1,15 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.event; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; -public class SingleResourceRetrieved extends ApplicationEvent { +public class SingleResourceRetrievedEvent extends ApplicationEvent { private final HttpServletResponse response; private final HttpServletRequest request; - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + public SingleResourceRetrievedEvent(final Object source, final HttpServletRequest request, final HttpServletResponse response) { super(source); this.request = request; @@ -26,4 +26,4 @@ public HttpServletRequest getRequest() { return request; } -} +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java index dc65c754c6b1..312ead0ab02d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -1,7 +1,8 @@ -package org.baeldung.web.hateoas; +package org.baeldung.web.hateoas.listener; import javax.servlet.http.HttpServletResponse; +import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java similarity index 84% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java index aaceac07378a..0b308712cb67 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java @@ -1,10 +1,11 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.listener; import java.net.URI; import javax.servlet.http.HttpServletResponse; import org.apache.http.HttpHeaders; +import org.baeldung.web.hateoas.event.ResourceCreatedEvent; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @@ -12,10 +13,10 @@ import com.google.common.base.Preconditions; @Component -class ResourceCreatedDiscoverabilityListener implements ApplicationListener { +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { @Override - public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + public void onApplicationEvent(final ResourceCreatedEvent resourceCreatedEvent) { Preconditions.checkNotNull(resourceCreatedEvent); final HttpServletResponse response = resourceCreatedEvent.getResponse(); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java similarity index 84% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java index 6be6c08df925..3dd57cb78d7d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java @@ -1,8 +1,10 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.listener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; +import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @@ -10,10 +12,10 @@ import com.google.common.net.HttpHeaders; @Component -class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { @Override - public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + public void onApplicationEvent(final SingleResourceRetrievedEvent resourceRetrievedEvent) { Preconditions.checkNotNull(resourceRetrievedEvent); final HttpServletRequest request = resourceRetrievedEvent.getRequest(); From 860285bef121daf3f15eda44f79fa6f91b5aa91d Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 01:07:17 +0200 Subject: [PATCH 435/796] new static access to current request used for discoverability --- .../java/org/baeldung/web/controller/FooController.java | 5 ++--- .../web/hateoas/event/SingleResourceRetrievedEvent.java | 9 +-------- .../SingleResourceRetrievedDiscoverabilityListener.java | 9 ++++----- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 1462b4c9ca27..f8fcbbe1dc61 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -2,7 +2,6 @@ import java.util.List; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.baeldung.persistence.model.Foo; @@ -48,10 +47,10 @@ public FooController() { @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findById(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + public Foo findById(@PathVariable("id") final Long id, final HttpServletResponse response) { final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); - eventPublisher.publishEvent(new SingleResourceRetrievedEvent(this, request, response)); + eventPublisher.publishEvent(new SingleResourceRetrievedEvent(this, response)); return resourceById; } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java index e71fde51e2aa..0c9eb889e62f 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java @@ -1,18 +1,15 @@ package org.baeldung.web.hateoas.event; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; public class SingleResourceRetrievedEvent extends ApplicationEvent { private final HttpServletResponse response; - private final HttpServletRequest request; - public SingleResourceRetrievedEvent(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + public SingleResourceRetrievedEvent(final Object source, final HttpServletResponse response) { super(source); - this.request = request; this.response = response; } @@ -22,8 +19,4 @@ public HttpServletResponse getResponse() { return response; } - public HttpServletRequest getRequest() { - return request; - } - } \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java index 3dd57cb78d7d..32407e9f2b26 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java @@ -1,12 +1,12 @@ package org.baeldung.web.hateoas.listener; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import com.google.common.base.Preconditions; import com.google.common.net.HttpHeaders; @@ -18,13 +18,12 @@ class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListe public void onApplicationEvent(final SingleResourceRetrievedEvent resourceRetrievedEvent) { Preconditions.checkNotNull(resourceRetrievedEvent); - final HttpServletRequest request = resourceRetrievedEvent.getRequest(); final HttpServletResponse response = resourceRetrievedEvent.getResponse(); - addLinkHeaderOnSingleResourceRetrieval(request, response); + addLinkHeaderOnSingleResourceRetrieval(response); } - void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { - final StringBuffer requestURL = request.getRequestURL(); + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletResponse response) { + final String requestURL = ServletUriComponentsBuilder.fromCurrentRequestUri().build().toUri().toASCIIString(); final int positionOfLastSlash = requestURL.lastIndexOf("/"); final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); From 49658f77501c6cf7746b8a2dce8fdbe5f401e13d Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 11:16:16 +0200 Subject: [PATCH 436/796] logging cleanup work --- httpclient/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 78c0219ad6ea..5bbf0fdec003 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -28,6 +28,12 @@ org.apache.httpcomponents httpclient ${httpclient.version} + + + commons-logging + commons-logging + + org.apache.httpcomponents From 9d1002385cfade84818f223b646bdf8ddbcdfcc0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 11:23:54 +0200 Subject: [PATCH 437/796] additional examples --- .../baeldung/jackson/sandbox/SandboxTest.java | 25 +++++++++++++++++ .../baeldung/jackson/sandbox/TestElement.java | 28 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java diff --git a/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java b/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java new file mode 100644 index 000000000000..76a902b89dda --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java @@ -0,0 +1,25 @@ +package org.baeldung.jackson.sandbox; + +import java.io.IOException; + +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SandboxTest { + + @Test + public final void whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final TestElement testElement = new TestElement(); + testElement.setX(10); + testElement.setY("adasd"); + final ObjectMapper om = new ObjectMapper(); + final String serialized = om.writeValueAsString(testElement); + System.err.println(serialized); + } + + // + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java b/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java new file mode 100644 index 000000000000..ee2f8dd26509 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java @@ -0,0 +1,28 @@ +package org.baeldung.jackson.sandbox; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class TestElement { + + int x; + + @JsonIgnore + private String y; + + public int getX() { + return x; + } + + public void setX(final int x) { + this.x = x; + } + + public String getY() { + return y; + } + + public void setY(final String y) { + this.y = y; + } + +} \ No newline at end of file From 31fd5453a5e0f40eb16f87e74de75c1f6e99248a Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 13 Feb 2014 23:05:21 +0200 Subject: [PATCH 438/796] jackson cleanup work --- .../test/java/org/baeldung/jackson/sandbox/SandboxTest.java | 3 +++ .../test/java/org/baeldung/jackson/sandbox/TestElement.java | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java b/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java index 76a902b89dda..19491377e864 100644 --- a/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/sandbox/SandboxTest.java @@ -4,6 +4,7 @@ import org.junit.Test; +import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -16,6 +17,8 @@ public final void whenDeserializing_thenCorrect() throws JsonParseException, Jso testElement.setX(10); testElement.setY("adasd"); final ObjectMapper om = new ObjectMapper(); + om.setVisibilityChecker(om.getSerializationConfig().getDefaultVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE)); + final String serialized = om.writeValueAsString(testElement); System.err.println(serialized); } diff --git a/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java b/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java index ee2f8dd26509..3b6a852b6b11 100644 --- a/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java +++ b/jackson/src/test/java/org/baeldung/jackson/sandbox/TestElement.java @@ -1,13 +1,10 @@ package org.baeldung.jackson.sandbox; -import com.fasterxml.jackson.annotation.JsonIgnore; - public class TestElement { int x; - @JsonIgnore - private String y; + private transient String y; public int getX() { return x; From d8b171ead01f5e412a2a6f5fa1f151d04f0b3440 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 15 Feb 2014 15:32:47 +0200 Subject: [PATCH 439/796] minor doc and maven work --- spring-security-rest-custom/README.md | 2 +- spring-security-rest-full/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index 3ec8cf92c71a..f19af32d4104 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -2,6 +2,6 @@ ## Spring Security for REST Example Project - ### Relevant Articles: - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) +- [Retrieve User Information in Spring Security](http://www.baeldung.com/get-user-in-spring-security) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 1816856f4cbc..922897b2439d 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -196,7 +196,7 @@ com.jayway.restassured rest-assured - 2.2.0 + 2.3.0 test From e71adf5a17af26939890ff1d380b11e25f3c2cc9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 15 Feb 2014 16:13:45 +0200 Subject: [PATCH 440/796] update on security work for rest api --- spring-security-rest/src/main/resources/webSecurityConfig.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index cefa3cd4efa9..cff7c1cc0729 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -10,12 +10,13 @@ - + + From 3778d74ee4b960297b972189a50d1691d3aa0e7d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 21 Feb 2014 18:46:18 +0100 Subject: [PATCH 441/796] cleanup work --- jackson/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jackson/pom.xml b/jackson/pom.xml index 0067215d7e77..11b7f18baa74 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-rest + jackson 0.1-SNAPSHOT - spring-rest + jackson From 06b521b4ee52463c5524657cd9ba8124e3e2d370 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 25 Feb 2014 00:27:46 +0200 Subject: [PATCH 442/796] jackson mapping fix --- .../org/baeldung/jackson/deserialization/ItemDeserializer.java | 2 +- .../baeldung/jackson/test/JacksonDeserializationUnitTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java index 8c6b67532ab8..baf5b945e7b1 100644 --- a/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/deserialization/ItemDeserializer.java @@ -22,7 +22,7 @@ public Item deserialize(final JsonParser jp, final DeserializationContext ctxt) final JsonNode node = jp.getCodec().readTree(jp); final int id = (Integer) ((IntNode) node.get("id")).numberValue(); final String itemName = node.get("itemName").asText(); - final int userId = (Integer) ((IntNode) node.get("owner")).numberValue(); + final int userId = (Integer) ((IntNode) node.get("createdBy")).numberValue(); return new Item(id, itemName, new User(userId, null)); } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java index e62b73e0ef7d..eb62ba9ded5d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDeserializationUnitTest.java @@ -146,7 +146,7 @@ public final void whenDeserializingTheStandardRepresentation_thenCorrect() throw @Test public final void whenDeserializingANonStandardRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException { - final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":2}"; + final String json = "{\"id\":1,\"itemName\":\"theItem\",\"createdBy\":2}"; final ObjectMapper mapper = new ObjectMapper(); final SimpleModule module = new SimpleModule(); From cce938c9cb1e69a0e6fd3cbaaaf4653cbc93fe55 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 7 Mar 2014 18:28:52 +0200 Subject: [PATCH 443/796] cleanup work --- core-java-8/pom.xml | 2 +- jackson/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index aacc12ec67a6..33585a5667ae 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -14,7 +14,7 @@ com.google.guava guava - 16.0-rc1 + 16.0.1 diff --git a/jackson/pom.xml b/jackson/pom.xml index 11b7f18baa74..08380ec83e43 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -13,7 +13,7 @@ com.google.guava guava - 16.0-rc1 + 16.0.1 commons-io From d195c3a0960fafb2c8c38eb468ee006de46b287a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 15 Mar 2014 12:10:49 +0200 Subject: [PATCH 444/796] maven upgrades --- core-java/pom.xml | 12 ++++++------ experiments/pom.xml | 12 ++++++------ guava/pom.xml | 12 ++++++------ httpclient/pom.xml | 12 ++++++------ jackson/pom.xml | 14 +++++++------- mockito/pom.xml | 12 ++++++------ rest-testing/pom.xml | 8 ++++---- spring-all/pom.xml | 12 ++++++------ spring-exceptions/pom.xml | 12 ++++++------ spring-hibernate3/pom.xml | 10 +++++----- spring-hibernate4/pom.xml | 12 ++++++------ spring-jpa/pom.xml | 12 ++++++------ spring-mvc-java/pom.xml | 14 +++++++------- spring-mvc-no-xml/pom.xml | 6 +++--- spring-mvc-xml/pom.xml | 6 +++--- spring-rest/pom.xml | 16 ++++++++-------- spring-security-basic-auth/pom.xml | 12 ++++++------ spring-security-mvc-custom/pom.xml | 12 ++++++------ spring-security-mvc-digest-auth/pom.xml | 12 ++++++------ spring-security-mvc-login/pom.xml | 12 ++++++------ spring-security-mvc-session/pom.xml | 12 ++++++------ spring-security-rest-basic-auth/pom.xml | 12 ++++++------ spring-security-rest-custom/pom.xml | 12 ++++++------ spring-security-rest-digest-auth/pom.xml | 12 ++++++------ spring-security-rest-full/pom.xml | 12 ++++++------ spring-security-rest/pom.xml | 12 ++++++------ 26 files changed, 151 insertions(+), 151 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 2d5210fa753e..53cb493cadd7 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -133,11 +133,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -152,15 +152,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/experiments/pom.xml b/experiments/pom.xml index 912dcaf49f9e..126f3932656f 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,11 +255,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -271,15 +271,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/guava/pom.xml b/guava/pom.xml index 8cb19e61f5c7..e9636e023197 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,11 +94,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -110,15 +110,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 5bbf0fdec003..afe45b345f50 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -130,11 +130,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -146,15 +146,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/jackson/pom.xml b/jackson/pom.xml index 08380ec83e43..eb969d1f2c22 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,11 +107,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -126,15 +126,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 @@ -143,7 +143,7 @@ 2.4 2.16 2.6 - 1.4.6 + 1.4.7 diff --git a/mockito/pom.xml b/mockito/pom.xml index d162bbcf0085..73da5593390f 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,11 +89,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -105,15 +105,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index e4e50271d6d2..ba659764a412 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -138,7 +138,7 @@ - 4.0.1.RELEASE + 4.0.2.RELEASE 2.3.0 @@ -152,15 +152,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 041139f3b80d..beaf8c93fe3a 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,13 +192,13 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE 3.18.1-GA 1.2 - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -210,15 +210,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index c1dc189aa4ca..2c3a16b51ff3 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,13 +204,13 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE 3.18.1-GA 1.2 - 4.3.1.Final + 4.3.4.Final 5.1.29 7.0.42 @@ -223,15 +223,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 1.8.9 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 78f7d6bbf2dd..23346cfc2ca9 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,8 +174,8 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE 3.18.1-GA @@ -192,15 +192,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index a69fdac5c1b1..91713ede6964 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,12 +182,12 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE 3.18.1-GA - 4.3.1.Final + 4.3.4.Final 5.1.29 7.0.42 @@ -200,15 +200,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index ed78ee29e4b6..f319e321c56b 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,11 +177,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -193,15 +193,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 75cf27c2c5b7..820ab433f9af 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,11 +141,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -157,17 +157,17 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 - 2.0.1 + 2.3.0 3.1 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index d0af83906d2a..a2ba3d90e97c 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.0.1.RELEASE + 4.0.2.RELEASE 1.7.5 @@ -156,8 +156,8 @@ 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 89da53e5854e..141228662a47 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,7 +141,7 @@ - 4.0.1.RELEASE + 4.0.2.RELEASE 1.7.5 @@ -152,8 +152,8 @@ 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index ee07d30e462a..1ec414553345 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,11 +202,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -218,17 +218,17 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 - 2.2.0 + 2.3.0 1.7.5 @@ -238,7 +238,7 @@ 3.1 2.4 2.16 - 1.4.6 + 1.4.7 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index b060f67c1734..aa50cde874b3 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -220,11 +220,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -236,15 +236,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index f16e71a82174..33e1b64c3dd6 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -225,11 +225,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -241,15 +241,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.2 - 4.3.1 + 4.3.3 + 4.3.2 2.3.0 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index b1b699cd60e4..6f91acf5931e 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -220,11 +220,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -236,15 +236,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 54dcd87924df..c6c935d3408b 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -217,11 +217,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -233,15 +233,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 9567e05d9b0d..68c5fcf03699 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -225,11 +225,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -241,15 +241,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.2 - 4.3.1 + 4.3.3 + 4.3.2 2.3.0 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 78bb86ccee0c..06e5ef92b24c 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -286,16 +286,16 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 1.7.5 @@ -306,7 +306,7 @@ 16.0.1 - 3.2.1 + 3.3 1.3 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 37a9cfe1c065..708bcb467f70 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -242,11 +242,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -258,15 +258,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 585f0110f10b..6ee64ebb3210 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,16 +275,16 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 1.7.5 @@ -295,7 +295,7 @@ 16.0.1 - 3.2.1 + 3.3 1.3 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 922897b2439d..a4f114b691fb 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -270,11 +270,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 1.4.3.RELEASE @@ -291,15 +291,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 5bc19094e9b2..82b9762ec853 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -208,11 +208,11 @@ - 4.0.1.RELEASE - 3.2.0.RELEASE + 4.0.2.RELEASE + 3.2.2.RELEASE - 4.3.1.Final + 4.3.4.Final 5.1.29 @@ -224,15 +224,15 @@ 16.0.1 - 3.2.1 + 3.3 1.3 4.11 1.9.5 - 4.3.1 - 4.3.2 + 4.3.2 + 4.3.3 2.3.0 From 50c94d735d832af2cbd36f8d045cb321cd5ffa83 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 15 Mar 2014 12:19:33 +0200 Subject: [PATCH 445/796] cleanup work --- spring-mvc-java/README.md | 1 - .../org/baeldung/spring/web/config/MainWebAppInitializer.java | 2 +- spring-mvc-xml/README.md | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index e32eeec83a90..bf76c7e1d4a3 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -4,4 +4,3 @@ ### Relevant Articles: -- [Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java index 81a94f1a8c10..87502e20881a 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/MainWebAppInitializer.java @@ -19,7 +19,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer { */ @Override public void onStartup(final ServletContext sc) throws ServletException { - System.out.println("GreenhouseWebAppInitializer.onStartup()"); + System.out.println("MainWebAppInitializer.onStartup()"); // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 6943393ce333..4773e6981a29 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -4,4 +4,5 @@ ### Relevant Articles: +- [Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) - [Servlet Session Timeout](http://www.baeldung.com/servlet-session-timeout) From 8a93af3d8599e4875cf67feff844929583a09a26 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 15 Mar 2014 12:20:16 +0200 Subject: [PATCH 446/796] minor doc work --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 4773e6981a29..908e21d4bf72 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,6 +1,7 @@ ========= ## Spring MVC with XML Configuration Example Project +- access a sample jsp page at: `http://localhost:8080/spring-mvc-xml/sample.html` ### Relevant Articles: From 1805d42f2ae611c994c84fefd96c2fcc03ce30d9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 16 Mar 2014 01:08:05 +0200 Subject: [PATCH 447/796] spring mvc xml config --- .../org/baeldung/spring/ClientWebConfig.java | 26 +------------ .../baeldung/spring/ClientWebConfigOld.java | 37 +++++++++++++++++++ .../src/main/resources/webMvcConfig.xml | 19 ++++++++++ .../src/main/resources/webSecurityConfig.xml | 36 ------------------ 4 files changed, 58 insertions(+), 60 deletions(-) create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java create mode 100644 spring-mvc-xml/src/main/resources/webMvcConfig.xml delete mode 100644 spring-mvc-xml/src/main/resources/webSecurityConfig.xml diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java index eaefb0984b77..c4d819caa5d1 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java @@ -1,15 +1,10 @@ package org.baeldung.spring; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.context.annotation.ImportResource; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; -@EnableWebMvc +@ImportResource("classpath:webMvcConfig.xml") @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { @@ -19,21 +14,4 @@ public ClientWebConfig() { // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/sample.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } } \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java new file mode 100644 index 000000000000..d621a001062e --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java @@ -0,0 +1,37 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +//@EnableWebMvc +//@Configuration +public class ClientWebConfigOld extends WebMvcConfigurerAdapter { + + public ClientWebConfigOld() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-mvc-xml/src/main/resources/webMvcConfig.xml new file mode 100644 index 000000000000..2a9cccdbe450 --- /dev/null +++ b/spring-mvc-xml/src/main/resources/webMvcConfig.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-xml/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 35dcb9c1ef53..000000000000 --- a/spring-mvc-xml/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From cab8e4d830c25ac2a54c7de99a91b0256d04f3d7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 16 Mar 2014 01:14:05 +0200 Subject: [PATCH 448/796] spring mvc work --- ...{ClientWebConfigOld.java => ClientWebConfigJava.java} | 4 ++-- spring-mvc-xml/src/main/resources/webMvcConfig.xml | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) rename spring-mvc-xml/src/main/java/org/baeldung/spring/{ClientWebConfigOld.java => ClientWebConfigJava.java} (90%) diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java similarity index 90% rename from spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java rename to spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java index d621a001062e..d2b57da8189d 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigOld.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java @@ -9,9 +9,9 @@ //@EnableWebMvc //@Configuration -public class ClientWebConfigOld extends WebMvcConfigurerAdapter { +public class ClientWebConfigJava extends WebMvcConfigurerAdapter { - public ClientWebConfigOld() { + public ClientWebConfigJava() { super(); } diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-mvc-xml/src/main/resources/webMvcConfig.xml index 2a9cccdbe450..5f6e26643b25 100644 --- a/spring-mvc-xml/src/main/resources/webMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/webMvcConfig.xml @@ -1,13 +1,10 @@ - + http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> From a45c572d4b5a75d91383815368a2c6817c693406 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 16 Mar 2014 12:59:09 +0200 Subject: [PATCH 449/796] new spring properties tests - for external properties --- .../core/ComponentInXmlUsingProperties.java | 2 +- ...rnalPropertiesWithJavaIntegrationTest.java | 36 +++++++++++++++++++ ...ertiesWithMultipleXmlsIntegrationTest.java | 36 +++++++++++++++++++ ...ernalPropertiesWithXmlIntegrationTest.java | 35 ++++++++++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java create mode 100644 spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java index f695326cd6bd..dbdcebcb3604 100644 --- a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java @@ -16,7 +16,7 @@ public class ComponentInXmlUsingProperties implements InitializingBean { public ComponentInXmlUsingProperties(final String propertyValue) { super(); - System.out.println("Constructor Injection - Property Value resolted to: " + propertyValue); + System.out.println("Constructor Injection - Property Value resolved to: " + propertyValue); } // diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java new file mode 100644 index 000000000000..bfc2f52579e9 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java @@ -0,0 +1,36 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithJavaConfig; +import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithJavaIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java new file mode 100644 index 000000000000..6391b8d655f8 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java @@ -0,0 +1,36 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; +import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithMultipleXmlsIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java new file mode 100644 index 000000000000..0d437842e6f1 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java @@ -0,0 +1,35 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithXmlIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +} From 8e575a44d5e8de00d4dad2b57598e10bbfc34633 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 20 Mar 2014 21:59:42 +0200 Subject: [PATCH 450/796] documentation cleanup work --- core-java/README.md | 2 ++ httpclient/README.md | 3 +++ jackson/README.md | 6 ++++++ spring-hibernate4/README.md | 1 + spring-jpa/README.md | 1 + spring-rest/README.md | 2 +- spring-security-mvc-session/README.md | 1 + spring-security-rest-full/README.md | 1 + 8 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core-java/README.md b/core-java/README.md index 717008f507f8..772681ad57ce 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -5,3 +5,5 @@ ### Relevant Articles: - [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) - [Java - Reading a Large File Efficiently](http://www.baeldung.com/java-read-lines-large-file) +- [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) + diff --git a/httpclient/README.md b/httpclient/README.md index 70e44b56cf05..529ac754f8e9 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -11,3 +11,6 @@ - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) - [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) - [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) +- [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) +- [HttpClient – Set Custom Header](http://www.baeldung.com/httpclient-custom-http-header) +- [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) diff --git a/jackson/README.md b/jackson/README.md index 3601f99efe54..539cb347615f 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -4,3 +4,9 @@ ### Relevant Articles: - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) +- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) +- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) +- [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) +- [Jackson – Custom Deserializer](http://www.baeldung.com/jackson-deserialization) + + diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index e9a6cc2be5e1..0d1ac1600ef8 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -4,6 +4,7 @@ ### Relevant Articles: - [Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring) +- [The DAO with Spring 3 and Hibernate](http://www.baeldung.com/2011/12/02/the-persistence-layer-with-spring-3-1-and-hibernate/) ### Quick Start diff --git a/spring-jpa/README.md b/spring-jpa/README.md index c62c4eabed74..11df42ac5205 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -6,3 +6,4 @@ ### Relevant Articles: - [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) - [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) +- [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa) diff --git a/spring-rest/README.md b/spring-rest/README.md index b979f263ed51..5e0a62c3eb64 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -5,5 +5,5 @@ ### Relevant Articles: - [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) - +- [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) diff --git a/spring-security-mvc-session/README.md b/spring-security-mvc-session/README.md index 840a1e0a3b68..0df728688ae7 100644 --- a/spring-security-mvc-session/README.md +++ b/spring-security-mvc-session/README.md @@ -5,6 +5,7 @@ ### Relevant Articles: - [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) +- [Spring Security Session Management](http://www.baeldung.com/spring-security-session) ### Build the Project diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 88cd3422eaef..06656d650cb6 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -9,6 +9,7 @@ - [HATEOAS for a Spring REST Service](http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/) - [REST API Discoverability and HATEOAS](http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/) - [ETags for REST with Spring](http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/) +- [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) ### Build the Project From ebb75abf66ff680b7ad6fb948b8957539ca82387 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 26 Mar 2014 12:34:22 +0200 Subject: [PATCH 451/796] maven upgrades, new way of configuring properties for persistence --- core-java/pom.xml | 6 +++--- experiments/pom.xml | 6 +++--- guava/pom.xml | 6 +++--- httpclient/pom.xml | 6 +++--- jackson/pom.xml | 6 +++--- mockito/pom.xml | 6 +++--- spring-all/pom.xml | 7 +++---- .../baeldung/spring/config/PersistenceConfig.java | 15 ++++++--------- spring-exceptions/pom.xml | 6 +++--- .../spring/Cause1PersistenceConfig.java | 15 ++++++--------- .../spring/Cause2PersistenceConfig.java | 15 ++++++--------- .../spring/Cause3PersistenceConfig.java | 15 ++++++--------- .../baeldung/spring/config/PersistenceConfig.java | 15 ++++++--------- spring-hibernate3/pom.xml | 6 +++--- .../org/baeldung/spring/PersistenceConfig.java | 15 ++++++--------- spring-hibernate4/pom.xml | 6 +++--- .../org/baeldung/spring/PersistenceConfig.java | 15 ++++++--------- spring-jpa/pom.xml | 6 +++--- .../org/baeldung/config/PersistenceJPAConfig.java | 14 +++++--------- spring-mvc-java/pom.xml | 6 +++--- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 6 +++--- spring-security-basic-auth/pom.xml | 6 +++--- spring-security-mvc-custom/pom.xml | 6 +++--- spring-security-mvc-digest-auth/pom.xml | 6 +++--- spring-security-mvc-login/pom.xml | 6 +++--- spring-security-mvc-session/pom.xml | 6 +++--- spring-security-rest-basic-auth/pom.xml | 6 +++--- spring-security-rest-custom/pom.xml | 6 +++--- spring-security-rest-digest-auth/pom.xml | 6 +++--- spring-security-rest-full/pom.xml | 6 +++--- .../org/baeldung/spring/PersistenceConfig.java | 14 +++++--------- spring-security-rest/pom.xml | 6 +++--- starting/spring-jpa/pom.xml | 2 +- 35 files changed, 124 insertions(+), 154 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 53cb493cadd7..7c1f413aef66 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -134,7 +134,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -152,7 +152,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -167,7 +167,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/experiments/pom.xml b/experiments/pom.xml index 126f3932656f..01806b430dad 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -256,7 +256,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -271,7 +271,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -286,7 +286,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/guava/pom.xml b/guava/pom.xml index e9636e023197..8cbde3aa58bb 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -95,7 +95,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -110,7 +110,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -125,7 +125,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index afe45b345f50..510208168167 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -131,7 +131,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -146,7 +146,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -161,7 +161,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/jackson/pom.xml b/jackson/pom.xml index eb969d1f2c22..04c150270cde 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -108,7 +108,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -126,7 +126,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -141,7 +141,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/mockito/pom.xml b/mockito/pom.xml index 73da5593390f..52d42bc266f6 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -90,7 +90,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -105,7 +105,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -120,7 +120,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index beaf8c93fe3a..c26b184be782 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -193,7 +193,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 3.18.1-GA 1.2 @@ -210,7 +210,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -221,12 +221,11 @@ 4.3.3 2.3.0 - 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 6a057fc0c741..d57151e25912 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -65,14 +65,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 2c3a16b51ff3..6322040af76e 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -205,7 +205,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 3.18.1-GA 1.2 @@ -223,7 +223,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -239,7 +239,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java index 98d2941db569..11dff24e48fd 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java @@ -66,14 +66,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java index 92d5f906a8e9..d1d6408934b6 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java @@ -68,14 +68,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java index 241c6c315ded..d4245e8e45b2 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java @@ -69,14 +69,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index fdf617904015..4fb3fdacd552 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -66,14 +66,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 23346cfc2ca9..ae11b910cc18 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -175,7 +175,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 3.18.1-GA @@ -192,7 +192,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -207,7 +207,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java index a6373f10ec2d..15752165cc94 100644 --- a/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate3/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -68,14 +68,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 91713ede6964..4e5fa0dcf1ee 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -183,7 +183,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 3.18.1-GA @@ -200,7 +200,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -216,7 +216,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index aad79bea000d..5df90c687f6b 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -68,14 +68,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties hibernateProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } + } \ No newline at end of file diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index f319e321c56b..6997796e7b5f 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -178,7 +178,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -193,7 +193,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -209,7 +209,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java index ea729fde0ca0..2e6882c684e4 100644 --- a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java @@ -73,15 +73,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties additionalProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } } \ No newline at end of file diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 820ab433f9af..9499d21ad767 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -142,7 +142,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -157,7 +157,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -172,7 +172,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index a2ba3d90e97c..a1ee1a575ef6 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -164,7 +164,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 141228662a47..9d1462ebd2d8 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -160,7 +160,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 1ec414553345..3c21515a1fbf 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -203,7 +203,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -218,7 +218,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -237,7 +237,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index aa50cde874b3..fb074b043cda 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -221,7 +221,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -236,7 +236,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -251,7 +251,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 33e1b64c3dd6..1b45172dd809 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -226,7 +226,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -241,7 +241,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -256,7 +256,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 6f91acf5931e..74fa34ba008e 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -221,7 +221,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -236,7 +236,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -251,7 +251,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index c6c935d3408b..019cdbd5aa87 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -218,7 +218,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -233,7 +233,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -248,7 +248,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 68c5fcf03699..4f7f4aeadf95 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -226,7 +226,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -241,7 +241,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -256,7 +256,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.7 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 06e5ef92b24c..82efe539072a 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,7 +287,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -306,7 +306,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -318,7 +318,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 708bcb467f70..06a2f5c2bb12 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -243,7 +243,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -258,7 +258,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -273,7 +273,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 6ee64ebb3210..31ce230c8a18 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -276,7 +276,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -295,7 +295,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -307,7 +307,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index a4f114b691fb..f4088eec2192 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -271,7 +271,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -291,7 +291,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -306,7 +306,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index 91e501b39089..bcb61033ca89 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -74,15 +74,11 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { } final Properties additionalProperties() { - return new Properties() { - { - setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - // setProperty("hibernate.globally_quoted_identifiers", "true"); - // note: necessary in launchpad-storage, but causing problems here - } - }; + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } } \ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 82b9762ec853..90b8e0f68f8c 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -209,7 +209,7 @@ 4.0.2.RELEASE - 3.2.2.RELEASE + 3.2.3.RELEASE 4.3.4.Final @@ -224,7 +224,7 @@ 16.0.1 - 3.3 + 3.3.1 1.3 @@ -239,7 +239,7 @@ 3.1 2.4 - 2.16 + 2.17 1.4.7 diff --git a/starting/spring-jpa/pom.xml b/starting/spring-jpa/pom.xml index 416b6f11e331..a8cd778faf8d 100644 --- a/starting/spring-jpa/pom.xml +++ b/starting/spring-jpa/pom.xml @@ -206,7 +206,7 @@ 3.1 2.4 - 2.16 + 2.17 2.6 1.4.6 From a2a052eebc171f02b538ac55d18f9a23dcab6c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio?= Date: Thu, 3 Apr 2014 15:22:09 -0300 Subject: [PATCH 452/796] Update web.xml with new package of config files --- spring-jpa/src/main/webapp/WEB-INF/web.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-jpa/src/main/webapp/WEB-INF/web.xml b/spring-jpa/src/main/webapp/WEB-INF/web.xml index 90f2abc2f6c9..881018134e2e 100644 --- a/spring-jpa/src/main/webapp/WEB-INF/web.xml +++ b/spring-jpa/src/main/webapp/WEB-INF/web.xml @@ -12,10 +12,10 @@ contextConfigLocation - org.baeldung.spring + org.baeldung.config org.springframework.web.context.ContextLoaderListener - \ No newline at end of file + From a039490b1012e2d4a210b6612db8c8e8a629fd26 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:04:28 +0300 Subject: [PATCH 453/796] new sandbox project --- sandbox/.classpath | 36 +++ ...e.wst.jsdt.core.javascriptValidator.launch | 7 + sandbox/.gitignore | 13 ++ sandbox/.project | 36 +++ sandbox/.settings/.jsdtscope | 5 + sandbox/.settings/org.eclipse.jdt.core.prefs | 95 ++++++++ sandbox/.settings/org.eclipse.jdt.ui.prefs | 55 +++++ sandbox/.settings/org.eclipse.m2e.core.prefs | 4 + sandbox/.settings/org.eclipse.m2e.wtp.prefs | 2 + .../org.eclipse.wst.common.component | 8 + ....eclipse.wst.common.project.facet.core.xml | 4 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 14 ++ .../org.eclipse.wst.ws.service.policy.prefs | 2 + sandbox/.springBeans | 14 ++ sandbox/README.md | 9 + sandbox/pom.xml | 176 +++++++++++++++ sandbox/src/main/resources/logback.xml | 16 ++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + sandbox/src/main/webapp/WEB-INF/web.xml | 42 ++++ .../org/baeldung/codility/CodilityTest1.java | 72 ++++++ .../org/baeldung/codility/CodilityTest2.java | 72 ++++++ .../org/baeldung/codility/CodilityTest3.java | 207 ++++++++++++++++++ sandbox/src/test/resources/.gitignore | 13 ++ 25 files changed, 910 insertions(+) create mode 100644 sandbox/.classpath create mode 100644 sandbox/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch create mode 100644 sandbox/.gitignore create mode 100644 sandbox/.project create mode 100644 sandbox/.settings/.jsdtscope create mode 100644 sandbox/.settings/org.eclipse.jdt.core.prefs create mode 100644 sandbox/.settings/org.eclipse.jdt.ui.prefs create mode 100644 sandbox/.settings/org.eclipse.m2e.core.prefs create mode 100644 sandbox/.settings/org.eclipse.m2e.wtp.prefs create mode 100644 sandbox/.settings/org.eclipse.wst.common.component create mode 100644 sandbox/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 sandbox/.settings/org.eclipse.wst.validation.prefs create mode 100644 sandbox/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 sandbox/.springBeans create mode 100644 sandbox/README.md create mode 100644 sandbox/pom.xml create mode 100644 sandbox/src/main/resources/logback.xml create mode 100644 sandbox/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 sandbox/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/src/test/java/org/baeldung/codility/CodilityTest1.java create mode 100644 sandbox/src/test/java/org/baeldung/codility/CodilityTest2.java create mode 100644 sandbox/src/test/java/org/baeldung/codility/CodilityTest3.java create mode 100644 sandbox/src/test/resources/.gitignore diff --git a/sandbox/.classpath b/sandbox/.classpath new file mode 100644 index 000000000000..0720e4851bd7 --- /dev/null +++ b/sandbox/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/sandbox/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/sandbox/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sandbox/.gitignore b/sandbox/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/sandbox/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/sandbox/.project b/sandbox/.project new file mode 100644 index 000000000000..f039cd270e3e --- /dev/null +++ b/sandbox/.project @@ -0,0 +1,36 @@ + + + sandbox + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/sandbox/.settings/.jsdtscope b/sandbox/.settings/.jsdtscope new file mode 100644 index 000000000000..7b3f0c8b9fae --- /dev/null +++ b/sandbox/.settings/.jsdtscope @@ -0,0 +1,5 @@ + + + + + diff --git a/sandbox/.settings/org.eclipse.jdt.core.prefs b/sandbox/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..723e5b12451a --- /dev/null +++ b/sandbox/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,95 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/sandbox/.settings/org.eclipse.jdt.ui.prefs b/sandbox/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000000..471e9b0d81fc --- /dev/null +++ b/sandbox/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,55 @@ +#Sat Jan 21 23:04:06 EET 2012 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/sandbox/.settings/org.eclipse.m2e.core.prefs b/sandbox/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000000..f897a7f1cb23 --- /dev/null +++ b/sandbox/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/sandbox/.settings/org.eclipse.m2e.wtp.prefs b/sandbox/.settings/org.eclipse.m2e.wtp.prefs new file mode 100644 index 000000000000..ef8608962237 --- /dev/null +++ b/sandbox/.settings/org.eclipse.m2e.wtp.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/sandbox/.settings/org.eclipse.wst.common.component b/sandbox/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000000..e98377cb0f7c --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sandbox/.settings/org.eclipse.wst.common.project.facet.core.xml b/sandbox/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000000..bc0009a45587 --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,4 @@ + + + + diff --git a/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.container b/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000000..3bd5d0a48039 --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.name b/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000000..05bd71b6ec2c --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/sandbox/.settings/org.eclipse.wst.validation.prefs b/sandbox/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 000000000000..cacf5451aef7 --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,14 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 +vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 +vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 +vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 +vf.version=3 diff --git a/sandbox/.settings/org.eclipse.wst.ws.service.policy.prefs b/sandbox/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 000000000000..9cfcabe16f73 --- /dev/null +++ b/sandbox/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/sandbox/.springBeans b/sandbox/.springBeans new file mode 100644 index 000000000000..a79097f40d30 --- /dev/null +++ b/sandbox/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/api-servlet.xml + + + + diff --git a/sandbox/README.md b/sandbox/README.md new file mode 100644 index 000000000000..772681ad57ce --- /dev/null +++ b/sandbox/README.md @@ -0,0 +1,9 @@ +========= + +## Core Java Cookbooks and Examples + +### Relevant Articles: +- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) +- [Java - Reading a Large File Efficiently](http://www.baeldung.com/java-read-lines-large-file) +- [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) + diff --git a/sandbox/pom.xml b/sandbox/pom.xml new file mode 100644 index 000000000000..7c1f413aef66 --- /dev/null +++ b/sandbox/pom.xml @@ -0,0 +1,176 @@ + + 4.0.0 + org.baeldung + spring-rest + 0.1-SNAPSHOT + + spring-rest + + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-collections4 + 4.0 + + + + commons-io + commons-io + 2.4 + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + core-java + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.2.RELEASE + 3.2.3.RELEASE + + + 4.3.4.Final + 5.1.29 + + + 2.3.0 + + + 1.7.5 + 1.0.11 + + + 5.0.3.Final + + + 16.0.1 + 3.3.1 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.0 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.7 + + + + \ No newline at end of file diff --git a/sandbox/src/main/resources/logback.xml b/sandbox/src/main/resources/logback.xml new file mode 100644 index 000000000000..62d0ea5037b2 --- /dev/null +++ b/sandbox/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/src/main/webapp/WEB-INF/api-servlet.xml b/sandbox/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 000000000000..a675fc6d954f --- /dev/null +++ b/sandbox/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/sandbox/src/main/webapp/WEB-INF/web.xml b/sandbox/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..48d4b8fe61af --- /dev/null +++ b/sandbox/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + Spring MVC Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + / + + + + + + + \ No newline at end of file diff --git a/sandbox/src/test/java/org/baeldung/codility/CodilityTest1.java b/sandbox/src/test/java/org/baeldung/codility/CodilityTest1.java new file mode 100644 index 000000000000..8bd957c51a48 --- /dev/null +++ b/sandbox/src/test/java/org/baeldung/codility/CodilityTest1.java @@ -0,0 +1,72 @@ +package org.baeldung.codility; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Random; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class CodilityTest1 { + + @Before + public final void before() { + // + } + + // tests + + @Test + public final void whenSolutionIsCalculated1_thenCorrect() { + final int[] A = new int[] { 1, 4, 3, 3, 1, 2 }; + final int solution = solution(A); + Assert.assertEquals(4, solution); + } + + @Test + public final void whenSolutionIsCalculated2_thenCorrect() { + final int[] A = new int[] { 6, 4, 4, 6 }; + final int solution = solution(A); + Assert.assertEquals(-1, solution); + } + + @Test + public final void whenSolutionIsCalculated3_thenCorrect() { + final int[] A = new int[100000]; + final Random random = new Random(); + for (final int index : A) { + A[index] = random.nextInt(); + } + + final long start = System.currentTimeMillis(); + final int solution = solution(A); + final long end = System.currentTimeMillis(); + System.out.println("Time: " + (end - start)); + System.out.println(solution); + } + + // + + final int solution(final int elements[]) { + final Map collector = new LinkedHashMap(); + Integer currentValue = null; + for (final int element : elements) { + currentValue = collector.get(element); + if (currentValue == null) { + collector.put(element, 1); + } else if (currentValue >= 1) { + collector.put(element, ++currentValue); + } + } + + for (final Map.Entry entry : collector.entrySet()) { + if (entry.getValue() == 1) { + return entry.getKey(); + } + } + + return -1; + } + +} diff --git a/sandbox/src/test/java/org/baeldung/codility/CodilityTest2.java b/sandbox/src/test/java/org/baeldung/codility/CodilityTest2.java new file mode 100644 index 000000000000..d92e9001f97e --- /dev/null +++ b/sandbox/src/test/java/org/baeldung/codility/CodilityTest2.java @@ -0,0 +1,72 @@ +package org.baeldung.codility; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Assert; +import org.junit.Test; + +public class CodilityTest2 { + + // tests + + @Test + public final void whenSolutionIsCalculated1_thenCorrect() { + final int solution = solution(955); + Assert.assertEquals(4, solution); + } + + @Test + public final void whenSolutionIsCalculated2_thenCorrect() { + final int solution = solution(102); + Assert.assertEquals(-1, solution); + } + + @Test + public final void whenSolutionIsCalculated3_thenCorrect() { + final int solution = solution(2); + Assert.assertEquals(-1, solution); + } + + @Test + public final void whenSolutionIsCalculated4_thenCorrect() { + final int solution = solution2("codilitycodilityco"); + Assert.assertEquals(8, solution); + } + + // + + public final int solution(final int decimal) { + final String binaryString = Integer.toBinaryString(decimal); + int lastPeriod = -1; + for (int period = 1; period < (binaryString.length() / 2 + 1); period++) { + final Matcher m = Pattern.compile("(\\S{" + period + ",})(?=.*?\\1)").matcher(binaryString); + final boolean found = m.find(); + if (found && m.groupCount() > 0) { + lastPeriod = period; + } + if (!found) { + break; + } + } + + return lastPeriod; + } + + public final int solution2(final String binaryString) { + int lastPeriod = -1; + for (int period = 1; period < (binaryString.length() / 2 + 1); period++) { + final Matcher m = Pattern.compile("(\\S{" + period + ",})(?=.*?\\1)").matcher(binaryString); + final boolean found = m.find(); + if (found && m.groupCount() > 0) { + lastPeriod = period; + } + if (!found) { + break; + } + } + + return lastPeriod; + } + +} diff --git a/sandbox/src/test/java/org/baeldung/codility/CodilityTest3.java b/sandbox/src/test/java/org/baeldung/codility/CodilityTest3.java new file mode 100644 index 000000000000..a7067be7b0d6 --- /dev/null +++ b/sandbox/src/test/java/org/baeldung/codility/CodilityTest3.java @@ -0,0 +1,207 @@ +package org.baeldung.codility; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + +public class CodilityTest3 { + + // tests + + @Test + public final void whenSolutionIsCalculated1_thenCorrect() { + final int[] moves = new int[] { 1, 3, 2, 5, 4, 4, 6, 3, 2 }; + final int solution = solution(moves); + Assert.assertEquals(7, solution); + } + + // + + public int solution(final int[] moves) { + final World world = new World(); + int nextMove = 0; + for (final int move : moves) { + switch (nextMove) { + case 0: + if (world.moveNorth(move)) { + nextMove = 1; + break; + } else { + return world.movesCount; + } + case 1: + if (world.moveEast(move)) { + nextMove = 2; + break; + } else { + return world.movesCount; + } + case 2: + if (world.moveSouth(move)) { + nextMove = 3; + break; + } else { + return world.movesCount; + } + case 3: + if (world.moveWest(move)) { + nextMove = 0; + break; + } else { + return world.movesCount; + } + default: + throw new IllegalStateException(); + } + } + + return world.movesCount; + } + +} + +class World { + int movesCount = 1; + int currentX = 0; + int currentY = 0; + Map minXAtY; + Map maxXAtY; + Map minYAtX; + Map maxYAtX; + + public World() { + minXAtY = new HashMap<>(); + maxXAtY = new HashMap<>(); + minYAtX = new HashMap<>(); + maxYAtX = new HashMap<>(); + } + + final boolean moveNorth(final int steps) { + if (isMoveNorthValid(steps)) { + storeMoveNorth(steps); + movesCount++; + return true; + } + return false; + } + + final boolean moveEast(final int steps) { + if (isMoveEastValid(steps)) { + storeMoveEast(steps); + movesCount++; + return true; + } + return false; + } + + final boolean moveSouth(final int steps) { + if (isMoveSouthValid(steps)) { + storeMoveSouth(steps); + movesCount++; + return true; + } + return false; + } + + final boolean moveWest(final int steps) { + if (isMoveWestValid(steps)) { + storeMoveWest(steps); + movesCount++; + return true; + } + return false; + } + + // + + private boolean isMoveNorthValid(final int steps) { + int currentPosition = currentY; + for (int i = 1; i <= steps; i++) { + currentPosition += 1; + if (minXAtY.get(currentPosition) != null && minXAtY.get(currentPosition) > currentX) { + return false; + } + if (maxXAtY.get(currentPosition) != null && maxXAtY.get(currentPosition) < currentX) { + return false; + } + } + return true; + } + + private boolean isMoveEastValid(final int steps) { // + int currentPosition = currentX; + for (int i = 1; i <= steps; i++) { + currentPosition += 1; + if (minYAtX.get(currentPosition) != null && minYAtX.get(currentPosition) < currentY) { + return false; + } + if (maxYAtX.get(currentPosition) != null && maxYAtX.get(currentPosition) > currentY) { + return false; + } + } + return true; + } + + private boolean isMoveSouthValid(final int steps) { + int currentPosition = currentY; + for (int i = 1; i <= steps; i++) { + currentPosition -= 1; + if (minXAtY.get(currentPosition) != null && minXAtY.get(currentPosition) < currentX) { + return false; + } + if (maxXAtY.get(currentPosition) != null && maxXAtY.get(currentPosition) > currentX) { + return false; + } + } + return true; + } + + private boolean isMoveWestValid(final int steps) { + int currentPosition = currentX; + for (int i = 1; i <= steps; i++) { + currentPosition -= 1; + if (minYAtX.get(currentPosition) != null && minYAtX.get(currentPosition) > currentY) { + return false; + } + if (maxYAtX.get(currentPosition) != null && maxYAtX.get(currentPosition) < currentY) { + return false; + } + } + return true; + } + + private void storeMoveNorth(final int steps) { + currentY = currentY + steps; + final Integer currentMaxYAtThisLevel = maxYAtX.get(currentX); + if (currentMaxYAtThisLevel == null || currentMaxYAtThisLevel == null && currentMaxYAtThisLevel < currentY) { + maxYAtX.put(currentX, currentY); + } + } + + private void storeMoveEast(final int steps) { + currentX = currentX + steps; + final Integer currentMaxXAtThisLevel = maxXAtY.get(currentY); + if (currentMaxXAtThisLevel == null || currentMaxXAtThisLevel == null && currentMaxXAtThisLevel < currentX) { + maxXAtY.put(currentY, currentX); + } + } + + private void storeMoveSouth(final int steps) { + currentY = currentY - steps; + final Integer currentMinYAtThisLevel = minYAtX.get(currentX); + if (currentMinYAtThisLevel == null || currentMinYAtThisLevel == null && currentMinYAtThisLevel > currentY) { + minYAtX.put(currentX, currentY); + } + } + + private void storeMoveWest(final int steps) { + currentX = currentX - steps; + final Integer currentMinXAtThisLevel = minXAtY.get(currentY); + if (currentMinXAtThisLevel == null || currentMinXAtThisLevel == null && currentMinXAtThisLevel > currentX) { + minXAtY.put(currentY, currentX); + } + } + +} diff --git a/sandbox/src/test/resources/.gitignore b/sandbox/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/sandbox/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 9ab1ef8dfa0b65e8865cd5729629d92eaeea6f6d Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:14:48 +0300 Subject: [PATCH 454/796] maven upgrades --- core-java/pom.xml | 16 ++++++++-------- experiments/pom.xml | 10 +++++----- guava/pom.xml | 10 +++++----- httpclient/pom.xml | 10 +++++----- jackson/pom.xml | 12 ++++++------ mockito/pom.xml | 10 +++++----- rest-testing/pom.xml | 10 +++++----- sandbox/pom.xml | 12 ++++++------ spring-all/pom.xml | 10 +++++----- spring-exceptions/pom.xml | 10 +++++----- spring-hibernate3/pom.xml | 8 ++++---- spring-hibernate4/pom.xml | 10 +++++----- spring-jpa/pom.xml | 10 +++++----- spring-mvc-java/pom.xml | 10 +++++----- spring-mvc-no-xml/pom.xml | 8 ++++---- spring-mvc-xml/pom.xml | 8 ++++---- spring-rest/pom.xml | 12 ++++++------ spring-security-basic-auth/pom.xml | 10 +++++----- spring-security-mvc-custom/pom.xml | 10 +++++----- spring-security-mvc-digest-auth/pom.xml | 10 +++++----- spring-security-mvc-login/pom.xml | 10 +++++----- spring-security-mvc-session/pom.xml | 10 +++++----- spring-security-rest-basic-auth/pom.xml | 10 +++++----- spring-security-rest-custom/pom.xml | 10 +++++----- spring-security-rest-digest-auth/pom.xml | 10 +++++----- spring-security-rest-full/pom.xml | 12 ++++++------ spring-security-rest/pom.xml | 10 +++++----- 27 files changed, 139 insertions(+), 139 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 7c1f413aef66..fc621e362df6 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-rest + core-java 0.1-SNAPSHOT - spring-rest + core-java @@ -133,19 +133,19 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 2.3.0 + 2.3.2 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -162,7 +162,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/experiments/pom.xml b/experiments/pom.xml index 01806b430dad..d54efcec8034 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,16 +255,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -281,7 +281,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/guava/pom.xml b/guava/pom.xml index 8cbde3aa58bb..349eaa5c7db5 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,16 +94,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -120,7 +120,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 510208168167..1da5fe5166f0 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -130,16 +130,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -156,7 +156,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/jackson/pom.xml b/jackson/pom.xml index 04c150270cde..c48d13d0a424 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,19 +107,19 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 2.3.0 + 2.3.2 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -136,7 +136,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/mockito/pom.xml b/mockito/pom.xml index 52d42bc266f6..475ad51d6689 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,16 +89,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -115,7 +115,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index ba659764a412..4a866cea02a8 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -138,14 +138,14 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE - 2.3.0 + 2.3.2 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -162,7 +162,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 7c1f413aef66..d0bd1aae3108 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -133,19 +133,19 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 2.3.0 + 2.3.2 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -162,7 +162,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index c26b184be782..0a9b6033fcda 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,18 +192,18 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE 3.18.1-GA 1.2 - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -220,7 +220,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 6322040af76e..472279056b35 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,19 +204,19 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE 3.18.1-GA 1.2 - 4.3.4.Final + 4.3.5.Final 5.1.29 7.0.42 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -233,7 +233,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 1.8.9 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index ae11b910cc18..272db2b63e24 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,7 +174,7 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE 3.18.1-GA @@ -184,8 +184,8 @@ 7.0.47 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -202,7 +202,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 4e5fa0dcf1ee..ffd4202452a1 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,18 +182,18 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE 3.18.1-GA - 4.3.4.Final + 4.3.5.Final 5.1.29 7.0.42 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -210,7 +210,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 6997796e7b5f..81f7b8b0707c 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,16 +177,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -203,7 +203,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 9499d21ad767..fde7cc4ffa34 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,16 +141,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -167,7 +167,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index a1ee1a575ef6..11fb31e3ff36 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,11 +145,11 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 1.3 @@ -159,7 +159,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 9d1462ebd2d8..2bd23fdb81dc 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,11 +141,11 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 1.3 @@ -155,7 +155,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 3c21515a1fbf..a2095f8a6240 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,16 +202,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 2.3.0 + 2.3.2 5.0.3.Final @@ -228,11 +228,11 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 3.1 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index fb074b043cda..a944c37ac465 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -220,16 +220,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -246,7 +246,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 1b45172dd809..56fa66811e96 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -225,16 +225,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -251,7 +251,7 @@ 4.3.3 4.3.2 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 74fa34ba008e..eed8379020cb 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -220,16 +220,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -246,7 +246,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 019cdbd5aa87..fffea2dfc542 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -217,16 +217,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -243,7 +243,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 4f7f4aeadf95..80ede48aff74 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -225,16 +225,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -251,7 +251,7 @@ 4.3.3 4.3.2 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 82efe539072a..f3fa27447a22 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -286,11 +286,11 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 @@ -298,8 +298,8 @@ 4.3.3 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -313,7 +313,7 @@ 4.11 1.9.5 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 06a2f5c2bb12..37420f175a7e 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -242,16 +242,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -268,7 +268,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 31ce230c8a18..4ddab86ee93d 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,11 +275,11 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 @@ -287,8 +287,8 @@ 4.3.3 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -302,7 +302,7 @@ 4.11 1.9.5 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index f4088eec2192..b2021aa6395f 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -270,21 +270,21 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 1.4.3.RELEASE - 2.3.0 + 2.3.2 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -301,7 +301,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 90b8e0f68f8c..8ee13bc97e4e 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -208,16 +208,16 @@ - 4.0.2.RELEASE + 4.0.3.RELEASE 3.2.3.RELEASE - 4.3.4.Final + 4.3.5.Final 5.1.29 - 1.7.5 - 1.0.11 + 1.7.6 + 1.1.1 5.0.3.Final @@ -234,7 +234,7 @@ 4.3.2 4.3.3 - 2.3.0 + 2.3.1 3.1 From a45c5f1ce783b64b55f2d51b40796096f01903fd Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:21:15 +0300 Subject: [PATCH 455/796] maven fixes and parent pom --- .project | 11 +++++++++++ guava/pom.xml | 6 +++--- mockito/pom.xml | 6 +++--- pom.xml | 39 +++++++++++++++++++++++++++++++++++++++ sandbox/pom.xml | 4 ++-- 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .project create mode 100644 pom.xml diff --git a/.project b/.project new file mode 100644 index 000000000000..2d04570bfee8 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + parent + + + + + + + + diff --git a/guava/pom.xml b/guava/pom.xml index 349eaa5c7db5..f15b011ce8e2 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-rest + guava 0.1-SNAPSHOT - spring-rest + guava @@ -62,7 +62,7 @@ - spring-rest + guava src/main/resources diff --git a/mockito/pom.xml b/mockito/pom.xml index 475ad51d6689..b5aeb6be8df9 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-rest + mockito 0.1-SNAPSHOT - spring-rest + mockito @@ -57,7 +57,7 @@ - spring-rest + mockito src/main/resources diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000000..aa8bc53c5f02 --- /dev/null +++ b/pom.xml @@ -0,0 +1,39 @@ + + 4.0.0 + org.baeldung + parent + 0.1-SNAPSHOT + parent + pom + + + core-java + experiments + guava + httpclient + jackson + mockito + rest-testing + sandbox + spring-all + spring-exceptions + spring-hibernate3 + spring-hibernate4 + spring-jpa + spring-mvc-java + spring-mvc-no-xml + spring-mvc-xml + spring-rest + spring-security-basic-auth + spring-security-mvc-custom + spring-security-mvc-digest-auth + spring-security-mvc-login + spring-security-mvc-session + spring-security-rest + spring-security-rest-basic-auth + spring-security-rest-custom + spring-security-rest-digest-auth + spring-security-rest-full + + + \ No newline at end of file diff --git a/sandbox/pom.xml b/sandbox/pom.xml index d0bd1aae3108..2028a4b44295 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.baeldung - spring-rest + sandbox 0.1-SNAPSHOT - spring-rest + sandbox From 9b4e748a3aff62a4a32734f33ad0c8fe60380339 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:31:31 +0300 Subject: [PATCH 456/796] maven fixes --- pom.xml | 4 ++-- spring-security-basic-auth/pom.xml | 6 +++++ spring-security-mvc-custom/pom.xml | 6 +++++ spring-security-mvc-digest-auth/pom.xml | 6 +++++ spring-security-mvc-login/pom.xml | 6 +++++ spring-security-mvc-session/pom.xml | 6 +++++ spring-security-rest-custom/pom.xml | 6 +++++ spring-security-rest-full/pom.xml | 31 +++++++++++++++++++++++++ spring-security-rest/pom.xml | 6 +++++ 9 files changed, 75 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index aa8bc53c5f02..5a9e85ddf6c9 100644 --- a/pom.xml +++ b/pom.xml @@ -31,9 +31,9 @@ spring-security-mvc-session spring-security-rest spring-security-rest-basic-auth - spring-security-rest-custom + spring-security-rest-digest-auth - spring-security-rest-full + \ No newline at end of file diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index a944c37ac465..2c8d949b642e 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -29,6 +29,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 56fa66811e96..945810b4d1c5 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -34,6 +34,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index eed8379020cb..2135c42234e1 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -29,6 +29,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index fffea2dfc542..c4e654616fba 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -34,6 +34,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 80ede48aff74..dd3fb4c5f348 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -34,6 +34,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 37420f175a7e..cff807868ce1 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -29,6 +29,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index b2021aa6395f..d17388f5395e 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -28,6 +28,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework @@ -71,6 +77,25 @@ ${org.springframework.version} + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + @@ -198,6 +223,12 @@ rest-assured 2.3.0 test + + + commons-logging + commons-logging + + diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 8ee13bc97e4e..da5ed3d24e6e 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -29,6 +29,12 @@ org.springframework spring-core ${org.springframework.version} + + + commons-logging + commons-logging + + org.springframework From 6480dde121110ebae9e0f0fefc36357eaf6456b2 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:33:23 +0300 Subject: [PATCH 457/796] maven fix --- pom.xml | 4 ++-- spring-security-rest-custom/pom.xml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5a9e85ddf6c9..126124046f41 100644 --- a/pom.xml +++ b/pom.xml @@ -31,9 +31,9 @@ spring-security-mvc-session spring-security-rest spring-security-rest-basic-auth - + spring-security-rest-custom spring-security-rest-digest-auth - + \ No newline at end of file diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index cff807868ce1..43f14d0b3208 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -205,6 +205,9 @@ org.apache.maven.plugins maven-war-plugin ${maven-war-plugin.version} + + false + From 55993de159e81de14518ed5a340fcdd4f6d733b7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 4 Apr 2014 17:34:30 +0300 Subject: [PATCH 458/796] activating all modules in the parent pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 126124046f41..aa8bc53c5f02 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ spring-security-rest-basic-auth spring-security-rest-custom spring-security-rest-digest-auth - + spring-security-rest-full \ No newline at end of file From a086b8ff7f6ddc4f59e78bdf0b47906d530e2f55 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 8 Apr 2014 01:25:24 +0200 Subject: [PATCH 459/796] JPA pagination examples --- .../persistence/service/FooService.java | 6 + ...oPaginationPersistenceIntegrationTest.java | 152 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java index b72e40a43085..6d1bb0adbecd 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java @@ -1,5 +1,7 @@ package org.baeldung.persistence.service; +import java.util.List; + import org.baeldung.persistence.dao.IFooDao; import org.baeldung.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; @@ -27,4 +29,8 @@ public Foo findOne(final long id) { return dao.findOne(id); } + public List findAll() { + return dao.findAll(); + } + } diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java new file mode 100644 index 000000000000..73c36190f98c --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java @@ -0,0 +1,152 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Foo; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooPaginationPersistenceIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private FooService fooService; + + @Before + public final void before() { + final int minimalNumberOfEntities = 25; + if (fooService.findAll().size() <= minimalNumberOfEntities) { + for (int i = 0; i < minimalNumberOfEntities; i++) { + fooService.create(new Foo(randomAlphabetic(6))); + } + } + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingFirstPage_thenCorrect() { + final int pageSize = 10; + + final Query query = entityManager.createQuery("From Foo"); + configurePagination(query, 1, pageSize); + + // When + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingLastPage_thenCorrect() { + final int pageSize = 10; + final Query queryTotal = entityManager.createQuery("Select count(f.id) from Foo f"); + final long countResult = (long) queryTotal.getSingleResult(); + + final Query query = entityManager.createQuery("Select f from Foo as f order by f.id"); + final int lastPage = (int) ((countResult / pageSize) + 1); + configurePagination(query, lastPage, pageSize); + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(lessThan(pageSize + 1))); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingPage_thenCorrect() { + final int pageSize = 10; + + final Query queryIds = entityManager.createQuery("Select f.id from Foo f order by f.lastName"); + final List fooIds = queryIds.getResultList(); + + final Query query = entityManager.createQuery("Select f from Foo e whet f.id in :ids"); + query.setParameter("ids", fooIds.subList(0, pageSize)); + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @Test + public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenCorrect() { + final int pageSize = 10; + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + final TypedQuery typedQuery = entityManager.createQuery(select); + typedQuery.setFirstResult(0); + typedQuery.setMaxResults(pageSize); + final List fooList = typedQuery.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @Test + public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenNoExceptions() { + int pageNumber = 1; + final int pageSize = 10; + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + + final CriteriaQuery countQuery = criteriaBuilder.createQuery(Long.class); + countQuery.select(criteriaBuilder.count(countQuery.from(Foo.class))); + final Long count = entityManager.createQuery(countQuery).getSingleResult(); + + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + + final TypedQuery typedQuery = entityManager.createQuery(select); + while (pageNumber < count.intValue()) { + typedQuery.setFirstResult(pageNumber - 1); + typedQuery.setMaxResults(pageSize); + System.out.println("Current page: " + typedQuery.getResultList()); + pageNumber += pageSize; + } + } + + // UTIL + + final int determineLastPage(final int pageSize, final long countResult) { + return (int) (countResult / pageSize) + 1; + } + + final void configurePagination(final Query query, final int pageNumber, final int pageSize) { + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + } + +} From 3e87601c1774870cbee25c1f8370f449bfb7898d Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 9 Apr 2014 22:06:54 +0200 Subject: [PATCH 460/796] early hibernate example work --- .../baeldung/spring/PersistenceConfig.java | 4 + .../src/main/resources/logback.xml | 2 + ...ePaginationPersistenceIntegrationTest.java | 205 ++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index 5df90c687f6b..000c67d62573 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -71,7 +71,11 @@ final Properties hibernateProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + hibernateProperties.setProperty("hibernate.show_sql", "true"); + // hibernateProperties.setProperty("hibernate.format_sql", "true"); // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } diff --git a/spring-hibernate4/src/main/resources/logback.xml b/spring-hibernate4/src/main/resources/logback.xml index 1146dade632e..71a6d50a58ae 100644 --- a/spring-hibernate4/src/main/resources/logback.xml +++ b/spring-hibernate4/src/main/resources/logback.xml @@ -7,6 +7,8 @@ + + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java new file mode 100644 index 000000000000..a66564f548df --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java @@ -0,0 +1,205 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.ScrollMode; +import org.hibernate.ScrollableResults; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.google.common.collect.Lists; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePaginationPersistenceIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private IFooService fooService; + + private Session session; + + // tests + + @Before + public final void before() { + final int minimalNumberOfEntities = 25; + if (fooService.findAll().size() <= minimalNumberOfEntities) { + for (int i = 0; i < minimalNumberOfEntities; i++) { + fooService.create(new Foo(randomAlphabetic(6))); + } + } + + session = sessionFactory.openSession(); + } + + @After + public final void after() { + session.close(); + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingPaginatedEntities_thenCorrectSize() { + final int pageNumber = 1; + final int pageSize = 10; + + final Query query = session.createQuery("From Foo"); + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + final List fooList = query.list(); + + assertThat(fooList, hasSize(pageSize)); + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingAllPages_thenCorrect() { + int pageNumber = 1; + final int pageSize = 10; + + final String countQ = "Select count (f.id) from Foo f"; + final Query countQuery = session.createQuery(countQ); + final Long countResult = (Long) countQuery.uniqueResult(); + + final List fooList = Lists.newArrayList(); + int totalEntities = 0; + final Query query = session.createQuery("From Foo"); + while (totalEntities < countResult) { + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + fooList.addAll(query.list()); + totalEntities = fooList.size(); + pageNumber++; + } + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingLastPage_thenCorrectSize() { + final int pageSize = 10; + + final String countQ = "Select count (f.id) from Foo f"; + final Query countQuery = session.createQuery(countQ); + final Long countResults = (Long) countQuery.uniqueResult(); + final int lastPageNumber = (int) ((countResults / pageSize) + 1); + + final Query selectQuery = session.createQuery("From Foo"); + selectQuery.setFirstResult((lastPageNumber - 1) * pageSize); + selectQuery.setMaxResults(pageSize); + final List lastPage = selectQuery.list(); + + assertThat(lastPage, hasSize(lessThan(pageSize + 1))); + } + + // testing - scrollable + + @Test + public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect() { + final int pageSize = 10; + final String hql = "FROM Foo f order by f.name"; + final Query query = session.createQuery(hql); + + final ScrollableResults resultScroll = query.scroll(ScrollMode.FORWARD_ONLY); + + // resultScroll.last(); + // final int totalResults = resultScroll.getRowNumber() + 1; + + resultScroll.first(); + resultScroll.scroll(0); + final List fooPage = Lists.newArrayList(); + int i = 0; + while (pageSize > i++) { + fooPage.add((Foo) resultScroll.get(0)); + if (!resultScroll.next()) + break; + } + + assertThat(fooPage, hasSize(lessThan(10 + 1))); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect2() { + final int minId = 0; + final int maxId = 10; + + final Criteria criteriaCount = session.createCriteria(Foo.class, "FOO"); + criteriaCount.add(Restrictions.between("id", minId, maxId)); + criteriaCount.addOrder(Order.asc("id")); + criteriaCount.setProjection(Projections.rowCount()); + final Long count = (Long) criteriaCount.uniqueResult(); + + int pageNumber = 1; + final int pageSize = 10; + final List fooList = Lists.newArrayList(); + + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + criteria.add(Restrictions.between("id", minId, maxId)); + criteria.addOrder(Order.asc("id")); + int totalEntities = 0; + while (totalEntities < count.intValue()) { + criteria.setFirstResult((pageNumber - 1) * pageSize); + criteria.setMaxResults(pageSize); + fooList.addAll(criteria.list()); + totalEntities = fooList.size(); + pageNumber++; + } + } + + @Test + public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect3() { + final int minId = 0; + final int maxId = 10; + int pageNumber = 1; + final int pageSize = 10; + final List fooList = Lists.newArrayList(); + + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + final Criteria criteriaCount = session.createCriteria(Foo.class, "FOO"); + criteria.add(Restrictions.between("id", minId, maxId)); + criteria.addOrder(Order.asc("id")); + criteriaCount.add(Restrictions.between("id", minId, maxId)); + criteriaCount.addOrder(Order.asc("id")); + criteriaCount.setProjection(Projections.rowCount()); + final Long count = (Long) criteriaCount.uniqueResult(); + int totalEntities = 0; + while (totalEntities < count.intValue()) { + criteria.setFirstResult((pageNumber - 1) * pageSize); + criteria.setMaxResults(pageSize); + fooList.addAll(criteria.list()); + totalEntities = fooList.size(); + pageNumber++; + } + } + +} From 055236309814d0f2407a322dd9b380a622c769f0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 10 Apr 2014 20:21:05 +0200 Subject: [PATCH 461/796] further pagination testing work --- ...ePaginationPersistenceIntegrationTest.java | 48 ++++++------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java index a66564f548df..1204b8ed1302 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java @@ -17,7 +17,6 @@ import org.hibernate.SessionFactory; import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -149,49 +148,32 @@ public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCor @SuppressWarnings("unchecked") @Test - public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect2() { - final int minId = 0; - final int maxId = 10; - - final Criteria criteriaCount = session.createCriteria(Foo.class, "FOO"); - criteriaCount.add(Restrictions.between("id", minId, maxId)); - criteriaCount.addOrder(Order.asc("id")); - criteriaCount.setProjection(Projections.rowCount()); - final Long count = (Long) criteriaCount.uniqueResult(); - - int pageNumber = 1; + public final void givenUsingTheCriteriaApi_whenRetrievingFirstPage_thenCorrect() { final int pageSize = 10; - final List fooList = Lists.newArrayList(); - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.add(Restrictions.between("id", minId, maxId)); + final Criteria criteria = session.createCriteria(Foo.class); criteria.addOrder(Order.asc("id")); - int totalEntities = 0; - while (totalEntities < count.intValue()) { - criteria.setFirstResult((pageNumber - 1) * pageSize); - criteria.setMaxResults(pageSize); - fooList.addAll(criteria.list()); - totalEntities = fooList.size(); - pageNumber++; - } + criteria.setFirstResult(0); + criteria.setMaxResults(pageSize); + final List firstPage = criteria.list(); + + assertThat(firstPage, hasSize(pageSize)); } + @SuppressWarnings("unchecked") @Test - public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect3() { - final int minId = 0; - final int maxId = 10; + public final void givenUsingTheCriteriaApi_whenRetrievingPaginatedData_thenCorrect() { + final Criteria criteriaCount = session.createCriteria(Foo.class); + criteriaCount.addOrder(Order.asc("id")); + criteriaCount.setProjection(Projections.rowCount()); + final Long count = (Long) criteriaCount.uniqueResult(); + int pageNumber = 1; final int pageSize = 10; final List fooList = Lists.newArrayList(); - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - final Criteria criteriaCount = session.createCriteria(Foo.class, "FOO"); - criteria.add(Restrictions.between("id", minId, maxId)); + final Criteria criteria = session.createCriteria(Foo.class); criteria.addOrder(Order.asc("id")); - criteriaCount.add(Restrictions.between("id", minId, maxId)); - criteriaCount.addOrder(Order.asc("id")); - criteriaCount.setProjection(Projections.rowCount()); - final Long count = (Long) criteriaCount.uniqueResult(); int totalEntities = 0; while (totalEntities < count.intValue()) { criteria.setFirstResult((pageNumber - 1) * pageSize); From 1c2e4f37f27caf3b5feb45b9551de2c9311da3a9 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sun, 13 Apr 2014 19:51:00 -0500 Subject: [PATCH 462/796] SortingTestsForArticle --- .../service/FooServiceSortingTests.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java new file mode 100644 index 000000000000..85d158c1ad96 --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -0,0 +1,72 @@ +package org.baeldung.persistence.service; + +import static org.junit.Assert.*; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; +import javax.persistence.Query; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.cc.jpa.example.Foo; +public class FooServiceSortingTests { +private EntityManager entityManager; + + @BeforeClass + public static void before(){ + + + } + + @After + public final void after() { + + } + + @Test + public final void whenSortingByOneAttributeDefault_thenSortedResult() { + + + Query sortQuery = entityManager.createQuery + ("Select f from Foo as f order by f.id"); + List fooList = sortQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + + } + + @Test + public final void whenSortingByOneAttribute_thenSortedResult() { + + Query sortQuery = entityManager.createQuery + ("Select f from Foo as f order by f.id desc"); + List fooList = sortQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + + } + + @Test + public final void whenSortingByTwoAttributes_thenSortedResult() { + + Query sortQuery = entityManager.createQuery + ("Select f from Foo as f order by f.name asc, f.id desc"); + List fooList = sortQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + + } + +} From d244b373b8812df0d5d29e387b935d25d34afd63 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sat, 19 Apr 2014 17:52:21 -0500 Subject: [PATCH 463/796] All Tets --- .../service/FooServiceSortingTests.java | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index 85d158c1ad96..32c5fd3789b1 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -32,16 +32,15 @@ public final void after() { } - @Test - public final void whenSortingByOneAttributeDefault_thenSortedResult() { + @Test + public final void whenSortingByOneAttributeDefault_thenSortedResult() { - - Query sortQuery = entityManager.createQuery - ("Select f from Foo as f order by f.id"); - List fooList = sortQuery.getResultList(); - for(Foo foo:fooList){ + Query sortQuery = entityManager.createQuery + ("Select f from Foo as f order by f.id"); + List fooList = sortQuery.getResultList(); + for(Foo foo:fooList){ System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } + } } @@ -68,5 +67,34 @@ public final void whenSortingByTwoAttributes_thenSortedResult() { } } + + @Test + public final void whenSortingFooWithCriteria_thenSortedFoos(){ + + Root from = criteriaQuery.from(Foo.class); + CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); + TypedQuery typedQuery = entityManager.createQuery(select); + ListfooList = typedQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"--------Id:"+foo.getId()); + } + + } + + @Test + public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenSortedFoos(){ + + Root from = criteriaQuery.from(Foo.class); + CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); + TypedQuery typedQuery = entityManager.createQuery(select); + ListfooList = typedQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + } + + } From c5ddb0b5ac58eb0ffb9399ea67a5b8140c7ba8c6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 23 Apr 2014 18:22:14 +0300 Subject: [PATCH 464/796] httpclient updates --- ...entsClientHttpRequestFactoryBasicAuth.java | 42 ------------------- .../baeldung/client/RestTemplateFactory.java | 37 +++++++--------- .../org/baeldung/client/ClientLiveTest.java | 18 ++++---- .../baeldung/client/RawClientLiveTest.java | 4 +- 4 files changed, 25 insertions(+), 76 deletions(-) delete mode 100644 spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java diff --git a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java deleted file mode 100644 index 5f808413ce8d..000000000000 --- a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.baeldung.client; - -import java.net.URI; - -import org.apache.http.HttpHost; -import org.apache.http.client.AuthCache; -import org.apache.http.client.protocol.ClientContext; -import org.apache.http.impl.auth.BasicScheme; -import org.apache.http.impl.client.BasicAuthCache; -import org.apache.http.protocol.BasicHttpContext; -import org.apache.http.protocol.HttpContext; -import org.springframework.http.HttpMethod; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; - -public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { - HttpHost host; - - public HttpComponentsClientHttpRequestFactoryBasicAuth(final HttpHost host) { - super(); - this.host = host; - } - - // - - @Override - protected HttpContext createHttpContext(final HttpMethod httpMethod, final URI uri) { - return createHttpContext(); - } - - private HttpContext createHttpContext() { - // Create AuthCache instance - final AuthCache authCache = new BasicAuthCache(); - // Generate BASIC scheme object and add it to the local auth cache - final BasicScheme basicAuth = new BasicScheme(); - authCache.put(host, basicAuth); - // Add AuthCache to the execution context - final BasicHttpContext localcontext = new BasicHttpContext(); - localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); - return localcontext; - } - -} \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java index 3eaa9e64eca0..f369e96ca99e 100644 --- a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -1,13 +1,15 @@ package org.baeldung.client; -import org.apache.http.HttpHost; -import org.apache.http.client.HttpClient; -import org.apache.http.client.params.ClientPNames; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -38,27 +40,16 @@ public boolean isSingleton() { @Override public void afterPropertiesSet() { - final HttpHost host = new HttpHost("localhost", 8080, "http"); - final HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); - restTemplate = new RestTemplate(requestFactory); - final int timeout = 5; - final HttpClient httpClient = requestFactory.getHttpClient(); - // - note: timeout via raw String parameters - // httpClient.getParams().setParameter("http.connection.timeout", timeout * 1000); - // httpClient.getParams().setParameter("http.socket.timeout", timeout * 1000); - // httpClient.getParams().setParameter("http.connection-manager.timeout", new Long(timeout * 1000)); - // httpClient.getParams().setParameter("http.protocol.head-body-timeout", timeout * 1000); + final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); - // - note: timeout via the API - final HttpParams httpParams = httpClient.getParams(); - httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000); - httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000); - httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000)); + final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user1", "user1Pass")); + final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).setDefaultCredentialsProvider(credentialsProvider).build(); - HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout - HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout + final ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(client); + restTemplate = new RestTemplate(requestFactory); } } \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index 4ca5ca9e64d0..6b1bfc3dce24 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -2,17 +2,16 @@ import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.security.GeneralSecurityException; import java.security.cert.X509Certificate; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; import org.baeldung.client.spring.ClientConfig; import org.baeldung.web.dto.Foo; import org.junit.Ignore; @@ -38,13 +37,14 @@ public class ClientLiveTest { // tests @Test - public final void whenSecuredRestApiIsConsumed_then200OK() { - final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) secureRestTemplate.getRequestFactory(); - final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); - httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass")); + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + @Test + public final void whenSecuredRestApiIsConsumed_then200OK() { final ResponseEntity responseEntity = secureRestTemplate.exchange("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1", HttpMethod.GET, null, Foo.class); - System.out.println(responseEntity.getStatusCode()); + assertThat(responseEntity.getStatusCode().value(), is(200)); } @Test(expected = ResourceAccessException.class) @@ -58,7 +58,7 @@ public final void whenHttpsUrlIsConsumed_thenException() { @Ignore("Only to run against a Server with HTTPS enabled (on 8443)") public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient(); + final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @Override diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index 312222d9bb33..fcd56b2f11ea 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -35,12 +35,12 @@ public class RawClientLiveTest { public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); - final int timeout = 20; // seconds + final int timeout = 30; // seconds final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build(); final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1"); getMethod.setConfig(requestConfig); - final int hardTimeout = 5; // seconds + final int hardTimeout = 10; // seconds final TimerTask task = new TimerTask() { @Override public void run() { From ca815da996da82a65e2bb293cff08e365927a422 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 23 Apr 2014 18:41:41 +0300 Subject: [PATCH 465/796] self signed certificates with new api --- .../baeldung/client/RawClientLiveTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java index fcd56b2f11ea..e99745c3d3e7 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java @@ -18,11 +18,15 @@ import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.junit.Ignore; import org.junit.Test; @@ -67,7 +71,7 @@ public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolEx } @Test - public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws IOException, GeneralSecurityException { + public final void givenHttpClientPre4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @Override public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { @@ -87,4 +91,19 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } + @Test + public final void givenHttpClientPost4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { + final SSLContextBuilder builder = new SSLContextBuilder(); + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); + final CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + + // new + + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final HttpGet getMethod = new HttpGet(urlOverHttps); + final HttpResponse response = httpClient.execute(getMethod); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + } From 845cad104e830095beff20ab747b0c50dd287aff Mon Sep 17 00:00:00 2001 From: egmp777 Date: Wed, 30 Apr 2014 12:58:51 -0500 Subject: [PATCH 466/796] All JPA Sorting Tests --- .../service/FooServiceSortingTests.java | 236 +++++++++++++----- 1 file changed, 179 insertions(+), 57 deletions(-) diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index 32c5fd3789b1..d7af8f4ddad4 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -7,94 +7,216 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; +import javax.persistence.OrderBy; import javax.persistence.Persistence; import javax.persistence.Query; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Order; +import javax.persistence.criteria.Root; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.annotations.common.util.StringHelper; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.cc.jpa.example.Foo; +import com.cc.jpa.example.Bar; + + public class FooServiceSortingTests { -private EntityManager entityManager; - + private EntityManager entityManager; + @BeforeClass public static void before(){ - - + + } + + @After + public final void after() { + } - @After - public final void after() { - - } - - @Test - public final void whenSortingByOneAttributeDefault_thenSortedResult() { - - Query sortQuery = entityManager.createQuery - ("Select f from Foo as f order by f.id"); - List fooList = sortQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - + @Test + public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.id"; + Query sortQuery = entityManager.createQuery + (jql); + List fooList = sortQuery.getResultList(); + assertEquals(1,fooList.get(0).getId()); + assertEquals(100,fooList.get(fooList.toArray().length-1).getId()); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + } - + @Test - public final void whenSortingByOneAttribute_thenSortedResult() { - + public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.id desc"; Query sortQuery = entityManager.createQuery - ("Select f from Foo as f order by f.id desc"); + (jql); List fooList = sortQuery.getResultList(); + assertEquals(100,fooList.get(0).getId()); + assertEquals(1,fooList.get(fooList.toArray().length-1).getId()); for(Foo foo:fooList){ System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); } - + } - + @Test - public final void whenSortingByTwoAttributes_thenSortedResult() { - + public final void whenSortingByTwoAttributes_thenPrintSortedResult() { + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.name asc, f.id desc"; Query sortQuery = entityManager.createQuery - ("Select f from Foo as f order by f.name asc, f.id desc"); + (jql); List fooList = sortQuery.getResultList(); for(Foo foo:fooList){ System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); } + + } + + @Test + public final void whenSortinfBar_thenPrintBarsSortedWithFoos(){ + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select b from Bar as b order by b.id"; + Query barQuery = entityManager.createQuery(jql); + ListbarList = barQuery.getResultList(); + for(Bar bar:barList){ + System.out.println("Bar Id:"+bar.getId()); + for(Foo foo:bar.getFooList()){ + System.out.println("FooName:"+foo.getName()); + } + } + } - - @Test - public final void whenSortingFooWithCriteria_thenSortedFoos(){ - - Root from = criteriaQuery.from(Foo.class); - CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); - TypedQuery typedQuery = entityManager.createQuery(select); - ListfooList = typedQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"--------Id:"+foo.getId()); - } - - } - - @Test - public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenSortedFoos(){ - - Root from = criteriaQuery.from(Foo.class); - CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); - TypedQuery typedQuery = entityManager.createQuery(select); - ListfooList = typedQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - } - - + + @Test + public final void whenSortingByStringNullLast_thenLastNull() { + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; + Query sortQuery = entityManager.createQuery + (jql); + List fooList = sortQuery.getResultList(); + assertNull(fooList.get(fooList.toArray().length-1).getName()); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()); + } + } + @Test + public final void whenSortingByStringNullFirst_thenFirstNull() { + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; + Query sortQuery = entityManager.createQuery + (jql); + List fooList = sortQuery.getResultList(); + assertNull(fooList.get(0).getName()); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getTest_Null()); + } + } + @Test + public final void whenSortingByIntNull_thenException() { + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + EntityTransaction entityTransaction = entityManager + .getTransaction(); + entityTransaction.begin(); + String jql = "Select f from Foo as f order by f.test_Null desc NULLS FIRST"; + Query sortQuery = entityManager.createQuery + (jql); + boolean thrown = false; + try { + List fooList = sortQuery.getResultList(); + } catch (javax.persistence.PersistenceException e) { + thrown = true; + } + assertTrue(thrown); + } + + @Test + public final void whenSortingFooWithCriteria_thenPrintSortedFoos(){ + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = criteriaBuilder + .createQuery(Foo.class); + Root from = criteriaQuery.from(Foo.class); + CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); + TypedQuery typedQuery = entityManager.createQuery(select); + ListfooList = typedQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"--------Id:"+foo.getId()); + } + + } + + @Test + public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos(){ + + EntityManagerFactory emf = Persistence + .createEntityManagerFactory("punit"); + EntityManager entityManager = emf.createEntityManager(); + CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = criteriaBuilder + .createQuery(Foo.class); + Root from = criteriaQuery.from(Foo.class); + CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); + TypedQuery typedQuery = entityManager.createQuery(select); + ListfooList = typedQuery.getResultList(); + for(Foo foo:fooList){ + System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); + } + } + } From 5dc96ceda43e86af352fc42e284ba00aec83dad0 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Wed, 30 Apr 2014 20:50:08 -0500 Subject: [PATCH 467/796] All Hibernate Criteria and HQL Tests --- .../service/FooSortingServiceTest.java | 468 ++++++++++++++++++ 1 file changed, 468 insertions(+) create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java new file mode 100644 index 000000000000..55daf93ed6a2 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -0,0 +1,468 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; +import org.baeldung.spring.PersistenceConfig; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +package com.cc.code.samples.hibernate.sorting; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; + +import org.hibernate.Criteria; +import org.hibernate.NullPrecedence; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.annotations.common.util.StringHelper; +import org.hibernate.cfg.Configuration; +import org.hibernate.criterion.Order; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.cc.example.hibernate.Foo; +import com.cc.example.hibernate.Bar; + +public class FooSortingServiceTest { + + + @Test + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + Session sess = null; + List fooList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name"; + Query query = sess.createQuery(hql); + fooList = query.list(); + for(Foo foo: fooList){ + System.out.println( + "Name: " + foo.getName() + + ", Id: " + foo.getId() + + ); + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + } + @Test + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { + Session sess = null; + List fooList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name ASC"; + Query query = sess.createQuery(hql); + fooList = query.list(); + for(Foo foo: fooList){ + System.out.println( + "Name: " + foo.getName() + + ", Id: " + foo.getId() + + ); + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + } + + @Test + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { + Session sess = null; + List fooList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name, f.id"; + Query query = sess.createQuery(hql); + fooList = query.list(); + for(Foo foo: fooList){ + System.out.println( + "Name: " + foo.getName() + + ", Id: " + foo.getId() + + ); + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + } + + @Test + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedOrderedResults() { + Session sess = null; + List fooList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + Query query = sess.createQuery(hql); + fooList = query.list(); + for(Foo foo: fooList){ + System.out.println( + "Name: " + foo.getName() + + ", Id: " + foo.getId() + + ); + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + } + @Test + public final void whenCriteriaSortingByOneAttr_thenPrintSortedResults() { + Session sess = null; + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = new ArrayList(); + try{ + sess.beginTransaction(); + Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + fooList = criteria.list(); + assertEquals(1,fooList.get(0).getId()); + assertEquals(100,fooList.get(fooList.toArray().length-1).getId()); + for(Foo foo: fooList){ + System.out.println( + "Id: " + foo.getId() + + ", FirstName: " + foo.getName() + + ); + } + + sess.getTransaction().commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + } + @Test + public final void whenCriteriaSortingByMultipAttr_thenSortedResults() { + Session sess = null; + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = new ArrayList(); + try{ + sess.beginTransaction(); + Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + fooList = criteria.list(); + for(Foo foo: fooList){ + System.out.println( + "Id: " + foo.getId() + + ", FirstName: " + foo.getName() + + ); + + } + + sess.getTransaction().commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + } + @Test + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + Session sess = null; + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = new ArrayList(); + try{ + sess.beginTransaction(); + Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length-1).getName()); + for(Foo foo: fooList){ + System.out.println( + "Id: " + foo.getId() + + ", FirstName: " + foo.getName() + + ); + + } + sess.getTransaction().commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + } + @Test + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { + Session sess = null; + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = new ArrayList(); + try{ + sess.beginTransaction(); + Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for(Foo foo: fooList){ + System.out.println( + "Id: " + foo.getId() + + ", FirstName: " + foo.getName() + + ); + + } + sess.getTransaction().commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + } + @Test + public final void whenHQlSortingByStringNullLast_thenLastNull() { + Session sess = null; + List fooList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + + Query query = sess.createQuery(hql); + fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length-1).getName()); + for(Foo foo: fooList){ + System.out.println( + "Name: " + foo.getName() + + ", Id: " + foo.getId() + + ); + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + } + + + @Test + public final void whenSortingBars_thenBarsWithSortedFoos(){ + Session sess = null; + Set fooList = new TreeSet(); + List barList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Bar b ORDER BY b.id"; + Query query = sess.createQuery(hql); + barList = query.list(); + + for(Bar bar:barList){ + + System.out.println("Bar Id:"+bar.getId()); + for(Foo foo:bar.getFooList()){ + System.out.println("FooName:"+foo.getName()); + + } + } + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + + } + @Test + public final void whenSortingPrimitiveNulls_thenException(){ + Session sess = null; + List fooList = new ArrayList(); + List barList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.idx"; + Query query = sess.createQuery(hql); + boolean thrown = false; + try { + fooList = criteria.list(); + } catch (org.hibernate.PropertyAccessException e) { + thrown = true; + } + assertTrue(thrown); + + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + + } + @Test + public final void whenSortingStringNullsLast_thenReturnNullsLast(){ + Session sess = null; + List fooList = new ArrayList(); + List barList = new ArrayList(); + + try{ + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + Query query = sess.createQuery(hql); + fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length-1).getName()); + for(Foo foo:fooList){ + System.out.println("FooIDX:"+foo.getName()); + + } + + Transaction tr = sess.beginTransaction(); + tr.commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + + + } + @Test + public final void whenNullPrimitiveValueCriteriaSortingByMultipAttr_thenException() { + Session sess = null; + SessionFactory sf = new Configuration(). + configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = new ArrayList(); + try{ + sess.beginTransaction(); + Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + criteria.addOrder(Order.asc("idx")); + boolean thrown = false; + try { + fooList = criteria.list(); + } catch (org.hibernate.PropertyAccessException e) { + thrown = true; + } + assertTrue(thrown); + + + sess.getTransaction().commit(); + }catch(Exception ex){ + ex.printStackTrace(); + }finally{ + if(sess != null){ + sess.close(); + } + } + } +} + +} From 782af18d95a307b77dd3544c7ead3f6ce720ac81 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Wed, 30 Apr 2014 20:56:35 -0500 Subject: [PATCH 468/796] Deleted Local Package and imports --- .../persistence/service/FooSortingServiceTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 55daf93ed6a2..0ba6ccff9def 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -16,10 +16,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -package com.cc.code.samples.hibernate.sorting; - import static org.junit.Assert.*; import org.junit.Before; @@ -51,9 +47,10 @@ import org.hibernate.criterion.Order; import org.junit.BeforeClass; import org.junit.Test; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) + -import com.cc.example.hibernate.Foo; -import com.cc.example.hibernate.Bar; public class FooSortingServiceTest { From 3886a06aed7935fa6ca0ecbbe01dbd7b4875351e Mon Sep 17 00:00:00 2001 From: egmp777 Date: Wed, 30 Apr 2014 20:59:38 -0500 Subject: [PATCH 469/796] Final Hibernate HQL and Criteria Tests --- .../baeldung/persistence/service/FooSortingServiceTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 0ba6ccff9def..e4011702b3a8 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -70,8 +70,7 @@ public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { for(Foo foo: fooList){ System.out.println( "Name: " + foo.getName() - + ", Id: " + foo.getId() - + + ", Id: " + foo.getId() ); } Transaction tr = sess.beginTransaction(); From 108eb600edd4f1abeef9c87973b924335cecc7a7 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 5 May 2014 16:11:55 +0300 Subject: [PATCH 470/796] Update README.md Quick documentation work (in progress). --- README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 92e85d956fd3..a8e8ddffbd87 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,13 @@ Spring Tutorials -========= - -Spring MVC -========= -[Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) - - -Spring Persistence -========= -[Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) - - -Spring Security -========= -[Spring Security Login](http://www.baeldung.com/spring-security-login) - +================ +This project is a collection of small and focused tutorials each covering a single and well defined area of development. +Most of the tutorial projects are focused on the `Spring Framework` (and `Spring Security`). +In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`. +Working with the code in Eclipse +================================ +Any IDE can be used to work with the projects, but if you're using Eclipse, consider the following. +- use the included formatter: From 213f456e4583d2309652bf4a236f598fd46c9b9c Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 5 May 2014 16:13:29 +0300 Subject: [PATCH 471/796] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8e8ddffbd87..0057b144a5a0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ Spring Tutorials ================ -This project is a collection of small and focused tutorials each covering a single and well defined area of development. +This project is **a collection of small and focused tutorials** each covering a single and well defined area of development. Most of the tutorial projects are focused on the `Spring Framework` (and `Spring Security`). In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`. + Working with the code in Eclipse ================================ Any IDE can be used to work with the projects, but if you're using Eclipse, consider the following. -- use the included formatter: - +- import the included formatter in Eclipse: +`https://github.com/eugenp/tutorials/tree/master/eclipse` From 65be29b43f198376080bd200d65d534bde5c4e04 Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 5 May 2014 16:14:11 +0300 Subject: [PATCH 472/796] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0057b144a5a0..2da54bde1cdc 100644 --- a/README.md +++ b/README.md @@ -10,5 +10,5 @@ Working with the code in Eclipse ================================ Any IDE can be used to work with the projects, but if you're using Eclipse, consider the following. -- import the included formatter in Eclipse: +- import the included **formatter** in Eclipse: `https://github.com/eugenp/tutorials/tree/master/eclipse` From 15f753ce553bf926eb8d41d6eeacb573268e0bc7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 5 May 2014 16:34:10 +0300 Subject: [PATCH 473/796] hibernate 4 testing work --- .../org/baeldung/persistence/model/Bar.java | 90 ++ .../FooServicePersistenceIntegrationTest.java | 1 - .../service/FooSortingServiceTest.java | 806 ++++++++---------- 3 files changed, 456 insertions(+), 441 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java new file mode 100644 index 000000000000..ddc60bf0c9e2 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -0,0 +1,90 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Bar implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + private List foos; + + public Bar() { + super(); + } + + public Bar(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public List getFooList() { + return foos; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Bar other = (Bar) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 5b45d65e579d..84e5d39d1540 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -3,7 +3,6 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index e4011702b3a8..9fc80b8621ed 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -1,464 +1,390 @@ package org.baeldung.persistence.service; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; -import org.baeldung.spring.PersistenceConfig; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.SortedSet; import java.util.TreeSet; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; - +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; import org.hibernate.Criteria; import org.hibernate.NullPrecedence; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; -import org.hibernate.annotations.common.util.StringHelper; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; -import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.google.common.collect.Lists; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooSortingServiceTest { + // tests + @Test + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + Session sess = null; + List fooList = Lists.newArrayList(); -public class FooSortingServiceTest { + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name"; + final Query query = sess.createQuery(hql); + fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } - - @Test - public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - Session sess = null; - List fooList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name"; - Query query = sess.createQuery(hql); - fooList = query.list(); - for(Foo foo: fooList){ - System.out.println( - "Name: " + foo.getName() - + ", Id: " + foo.getId() - ); - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - } - @Test - public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - Session sess = null; - List fooList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name ASC"; - Query query = sess.createQuery(hql); - fooList = query.list(); - for(Foo foo: fooList){ - System.out.println( - "Name: " + foo.getName() - + ", Id: " + foo.getId() - - ); - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - } - - @Test - public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - Session sess = null; - List fooList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name, f.id"; - Query query = sess.createQuery(hql); - fooList = query.list(); - for(Foo foo: fooList){ - System.out.println( - "Name: " + foo.getName() - + ", Id: " + foo.getId() - - ); - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - } - - @Test - public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedOrderedResults() { - Session sess = null; - List fooList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - Query query = sess.createQuery(hql); - fooList = query.list(); - for(Foo foo: fooList){ - System.out.println( - "Name: " + foo.getName() - + ", Id: " + foo.getId() - - ); - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - } - @Test - public final void whenCriteriaSortingByOneAttr_thenPrintSortedResults() { - Session sess = null; - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = new ArrayList(); - try{ - sess.beginTransaction(); - Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("id")); - fooList = criteria.list(); - assertEquals(1,fooList.get(0).getId()); - assertEquals(100,fooList.get(fooList.toArray().length-1).getId()); - for(Foo foo: fooList){ - System.out.println( - "Id: " + foo.getId() - + ", FirstName: " + foo.getName() - - ); - } - - sess.getTransaction().commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - } - @Test - public final void whenCriteriaSortingByMultipAttr_thenSortedResults() { - Session sess = null; - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = new ArrayList(); - try{ - sess.beginTransaction(); - Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name")); - criteria.addOrder(Order.asc("id")); - fooList = criteria.list(); - for(Foo foo: fooList){ - System.out.println( - "Id: " + foo.getId() - + ", FirstName: " + foo.getName() - - ); - - } - - sess.getTransaction().commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - } - @Test - public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - Session sess = null; - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = new ArrayList(); - try{ - sess.beginTransaction(); - Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); - fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length-1).getName()); - for(Foo foo: fooList){ - System.out.println( - "Id: " + foo.getId() - + ", FirstName: " + foo.getName() - - ); - - } - sess.getTransaction().commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - } - @Test - public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - Session sess = null; - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = new ArrayList(); - try{ - sess.beginTransaction(); - Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - fooList = criteria.list(); - assertNull(fooList.get(0).getName()); - for(Foo foo: fooList){ - System.out.println( - "Id: " + foo.getId() - + ", FirstName: " + foo.getName() - - ); - - } - sess.getTransaction().commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - } - @Test - public final void whenHQlSortingByStringNullLast_thenLastNull() { - Session sess = null; - List fooList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - - Query query = sess.createQuery(hql); - fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length-1).getName()); - for(Foo foo: fooList){ - System.out.println( - "Name: " + foo.getName() - + ", Id: " + foo.getId() - - ); - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - } - - - @Test - public final void whenSortingBars_thenBarsWithSortedFoos(){ - Session sess = null; - Set fooList = new TreeSet(); - List barList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Bar b ORDER BY b.id"; - Query query = sess.createQuery(hql); - barList = query.list(); - - for(Bar bar:barList){ - - System.out.println("Bar Id:"+bar.getId()); - for(Foo foo:bar.getFooList()){ - System.out.println("FooName:"+foo.getName()); - - } - } - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - - } - @Test - public final void whenSortingPrimitiveNulls_thenException(){ - Session sess = null; - List fooList = new ArrayList(); - List barList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.idx"; - Query query = sess.createQuery(hql); - boolean thrown = false; - try { - fooList = criteria.list(); - } catch (org.hibernate.PropertyAccessException e) { - thrown = true; - } - assertTrue(thrown); - - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - - } - @Test - public final void whenSortingStringNullsLast_thenReturnNullsLast(){ - Session sess = null; - List fooList = new ArrayList(); - List barList = new ArrayList(); - - try{ - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - Query query = sess.createQuery(hql); - fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length-1).getName()); - for(Foo foo:fooList){ - System.out.println("FooIDX:"+foo.getName()); - - } - - Transaction tr = sess.beginTransaction(); - tr.commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - - - } - @Test - public final void whenNullPrimitiveValueCriteriaSortingByMultipAttr_thenException() { - Session sess = null; - SessionFactory sf = new Configuration(). - configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = new ArrayList(); - try{ - sess.beginTransaction(); - Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - criteria.addOrder(Order.asc("idx")); - boolean thrown = false; - try { - fooList = criteria.list(); - } catch (org.hibernate.PropertyAccessException e) { - thrown = true; - } - assertTrue(thrown); - - - sess.getTransaction().commit(); - }catch(Exception ex){ - ex.printStackTrace(); - }finally{ - if(sess != null){ - sess.close(); - } - } - } -} + } + + @Test + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { + Session sess = null; + List fooList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name ASC"; + final Query query = sess.createQuery(hql); + fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + @Test + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { + Session sess = null; + List fooList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name, f.id"; + final Query query = sess.createQuery(hql); + fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + @Test + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedOrderedResults() { + Session sess = null; + List fooList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + final Query query = sess.createQuery(hql); + fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + @Test + public final void whenCriteriaSortingByOneAttr_thenPrintSortedResults() { + Session sess = null; + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = Lists.newArrayList(); + try { + sess.beginTransaction(); + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + fooList = criteria.list(); + assertEquals(1, fooList.get(0).getId()); + assertEquals(100, fooList.get(fooList.toArray().length - 1).getId()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + + sess.getTransaction().commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + } + + @Test + public final void whenCriteriaSortingByMultipAttr_thenSortedResults() { + Session sess = null; + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = Lists.newArrayList(); + try { + sess.beginTransaction(); + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + + sess.getTransaction().commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + } + + @Test + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + Session sess = null; + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = Lists.newArrayList(); + try { + sess.beginTransaction(); + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + } + + @Test + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { + Session sess = null; + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = Lists.newArrayList(); + try { + sess.beginTransaction(); + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + } + + @Test + public final void whenHQlSortingByStringNullLast_thenLastNull() { + Session sess = null; + List fooList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + + final Query query = sess.createQuery(hql); + fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + @Test + public final void whenSortingBars_thenBarsWithSortedFoos() { + Session sess = null; + final Set fooList = new TreeSet(); + List barList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Bar b ORDER BY b.id"; + final Query query = sess.createQuery(hql); + barList = query.list(); + + for (final Bar bar : barList) { + System.out.println("Bar Id:" + bar.getId()); + for (final Foo foo : bar.getFooList()) { + System.out.println("FooName:" + foo.getName()); + } + } + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + // @Test + // public final void whenSortingPrimitiveNulls_thenException() { + // Session sess = null; + // List fooList = new ArrayList(); + // final List barList = new ArrayList(); + // + // try { + // final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + // sess = sf.openSession(); + // final String hql = "FROM Foo f ORDER BY f.idx"; + // final Query query = sess.createQuery(hql); + // boolean thrown = false; + // try { + // fooList = criteria.list(); + // } catch (final org.hibernate.PropertyAccessException e) { + // thrown = true; + // } + // assertTrue(thrown); + // + // final Transaction tr = sess.beginTransaction(); + // tr.commit(); + // } catch (final Exception ex) { + // ex.printStackTrace(); + // } finally { + // if (sess != null) { + // sess.close(); + // } + // } + // } + + @Test + public final void whenSortingStringNullsLast_thenReturnNullsLast() { + Session sess = null; + List fooList = Lists.newArrayList(); + final List barList = Lists.newArrayList(); + + try { + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + final Query query = sess.createQuery(hql); + fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("FooIDX:" + foo.getName()); + + } + + final Transaction tr = sess.beginTransaction(); + tr.commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + + } + + @Test + public final void whenNullPrimitiveValueCriteriaSortingByMultipAttr_thenException() { + Session sess = null; + final SessionFactory sf = new Configuration().configure().buildSessionFactory(); + sess = sf.openSession(); + List fooList = Lists.newArrayList(); + try { + sess.beginTransaction(); + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + criteria.addOrder(Order.asc("idx")); + boolean thrown = false; + try { + fooList = criteria.list(); + } catch (final org.hibernate.PropertyAccessException e) { + thrown = true; + } + assertTrue(thrown); + sess.getTransaction().commit(); + } catch (final Exception ex) { + ex.printStackTrace(); + } finally { + if (sess != null) { + sess.close(); + } + } + } } From a4f71ef281ba6883360a58d683851e955db4c143 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 6 May 2014 00:39:49 +0300 Subject: [PATCH 474/796] testing fixes --- .../org/baeldung/persistence/model/Bar.java | 90 +++++ .../service/FooServiceSortingTests.java | 365 ++++++++---------- 2 files changed, 254 insertions(+), 201 deletions(-) create mode 100644 spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java new file mode 100644 index 000000000000..ddc60bf0c9e2 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -0,0 +1,90 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Bar implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + private List foos; + + public Bar() { + super(); + } + + public Bar(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public List getFooList() { + return foos; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Bar other = (Bar) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index d7af8f4ddad4..0cc8645af8bb 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -1,222 +1,185 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; -import javax.persistence.OrderBy; import javax.persistence.Persistence; import javax.persistence.Query; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Order; import javax.persistence.criteria.Root; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.annotations.common.util.StringHelper; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; import org.junit.After; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import com.cc.jpa.example.Foo; -import com.cc.jpa.example.Bar; - - public class FooServiceSortingTests { - private EntityManager entityManager; - - @BeforeClass - public static void before(){ - - } - - @After - public final void after() { - - } - - @Test - public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.id"; - Query sortQuery = entityManager.createQuery - (jql); - List fooList = sortQuery.getResultList(); - assertEquals(1,fooList.get(0).getId()); - assertEquals(100,fooList.get(fooList.toArray().length-1).getId()); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - - } - - @Test - public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.id desc"; - Query sortQuery = entityManager.createQuery - (jql); - List fooList = sortQuery.getResultList(); - assertEquals(100,fooList.get(0).getId()); - assertEquals(1,fooList.get(fooList.toArray().length-1).getId()); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - - } - - @Test - public final void whenSortingByTwoAttributes_thenPrintSortedResult() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.name asc, f.id desc"; - Query sortQuery = entityManager.createQuery - (jql); - List fooList = sortQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - - } - - @Test - public final void whenSortinfBar_thenPrintBarsSortedWithFoos(){ - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select b from Bar as b order by b.id"; - - Query barQuery = entityManager.createQuery(jql); - ListbarList = barQuery.getResultList(); - for(Bar bar:barList){ - System.out.println("Bar Id:"+bar.getId()); - for(Foo foo:bar.getFooList()){ - System.out.println("FooName:"+foo.getName()); - } - } - - } - - @Test - public final void whenSortingByStringNullLast_thenLastNull() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; - Query sortQuery = entityManager.createQuery - (jql); - List fooList = sortQuery.getResultList(); - assertNull(fooList.get(fooList.toArray().length-1).getName()); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()); - } - } - @Test - public final void whenSortingByStringNullFirst_thenFirstNull() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; - Query sortQuery = entityManager.createQuery - (jql); - List fooList = sortQuery.getResultList(); - assertNull(fooList.get(0).getName()); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getTest_Null()); - } - } - @Test - public final void whenSortingByIntNull_thenException() { - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - EntityTransaction entityTransaction = entityManager - .getTransaction(); - entityTransaction.begin(); - String jql = "Select f from Foo as f order by f.test_Null desc NULLS FIRST"; - Query sortQuery = entityManager.createQuery - (jql); - boolean thrown = false; - try { - List fooList = sortQuery.getResultList(); - } catch (javax.persistence.PersistenceException e) { - thrown = true; - } - assertTrue(thrown); - } - - @Test - public final void whenSortingFooWithCriteria_thenPrintSortedFoos(){ - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - CriteriaQuery criteriaQuery = criteriaBuilder - .createQuery(Foo.class); - Root from = criteriaQuery.from(Foo.class); - CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); - TypedQuery typedQuery = entityManager.createQuery(select); - ListfooList = typedQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"--------Id:"+foo.getId()); - } - - } - - @Test - public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos(){ - - EntityManagerFactory emf = Persistence - .createEntityManagerFactory("punit"); - EntityManager entityManager = emf.createEntityManager(); - CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - CriteriaQuery criteriaQuery = criteriaBuilder - .createQuery(Foo.class); - Root from = criteriaQuery.from(Foo.class); - CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); - TypedQuery typedQuery = entityManager.createQuery(select); - ListfooList = typedQuery.getResultList(); - for(Foo foo:fooList){ - System.out.println("Name:"+foo.getName()+"-------Id:"+foo.getId()); - } - } - + private EntityManager entityManager; + + @BeforeClass + public static void before() { + // + } + + @After + public final void after() { + // + } + + @Test + public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { + + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.id"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertEquals(1, fooList.get(0).getId()); + assertEquals(100, fooList.get(fooList.toArray().length - 1).getId()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { + + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.id desc"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertEquals(100, fooList.get(0).getId()); + assertEquals(1, fooList.get(fooList.toArray().length - 1).getId()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingByTwoAttributes_thenPrintSortedResult() { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.name asc, f.id desc"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select b from Bar as b order by b.id"; + + final Query barQuery = entityManager.createQuery(jql); + final List barList = barQuery.getResultList(); + for (final Bar bar : barList) { + System.out.println("Bar Id:" + bar.getId()); + for (final Foo foo : bar.getFooList()) { + System.out.println("FooName:" + foo.getName()); + } + } + } + + @Test + public final void whenSortingByStringNullLast_thenLastNull() { + + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + } + + // @Test + // public final void whenSortingByStringNullFirst_thenFirstNull() { + // final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + // final EntityManager entityManager = emf.createEntityManager(); + // final EntityTransaction entityTransaction = entityManager.getTransaction(); + // entityTransaction.begin(); + // final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; + // final Query sortQuery = entityManager.createQuery(jql); + // final List fooList = sortQuery.getResultList(); + // assertNull(fooList.get(0).getName()); + // for (final Foo foo : fooList) { + // System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getTest_Null()); + // } + // } + + @Test + public final void whenSortingByIntNull_thenException() { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final EntityTransaction entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.test_Null desc NULLS FIRST"; + final Query sortQuery = entityManager.createQuery(jql); + boolean thrown = false; + try { + final List fooList = sortQuery.getResultList(); + } catch (final javax.persistence.PersistenceException e) { + thrown = true; + } + assertTrue(thrown); + } + + @Test + public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); + final TypedQuery typedQuery = entityManager.createQuery(select); + final List fooList = typedQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "--------Id:" + foo.getId()); + } + + } + + @Test + public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); + final EntityManager entityManager = emf.createEntityManager(); + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); + final TypedQuery typedQuery = entityManager.createQuery(select); + final List fooList = typedQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + } From 80c3ca190f61ade184a4a2eaff19e7038c10eb81 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 7 May 2014 11:55:30 +0300 Subject: [PATCH 475/796] maven upgrades, quick testing work --- core-java/pom.xml | 8 ++++---- experiments/pom.xml | 8 ++++---- guava/pom.xml | 8 ++++---- httpclient/pom.xml | 8 ++++---- jackson/pom.xml | 8 ++++---- mockito/pom.xml | 8 ++++---- spring-all/pom.xml | 8 ++++---- spring-exceptions/pom.xml | 8 ++++---- spring-hibernate3/pom.xml | 8 ++++---- spring-hibernate4/pom.xml | 8 ++++---- spring-jpa/pom.xml | 8 ++++---- spring-mvc-java/pom.xml | 8 ++++---- spring-mvc-no-xml/pom.xml | 4 ++-- spring-mvc-xml/pom.xml | 4 ++-- spring-rest/pom.xml | 8 ++++---- spring-security-basic-auth/pom.xml | 8 ++++---- spring-security-mvc-custom/pom.xml | 8 ++++---- spring-security-mvc-digest-auth/pom.xml | 8 ++++---- spring-security-mvc-login/pom.xml | 8 ++++---- spring-security-mvc-session/pom.xml | 8 ++++---- spring-security-rest-basic-auth/pom.xml | 12 ++++++------ ...tLiveTest.java => HttpsClientLiveManualTest.java} | 9 ++++++++- spring-security-rest-custom/pom.xml | 8 ++++---- spring-security-rest-digest-auth/pom.xml | 8 ++++---- spring-security-rest-full/pom.xml | 8 ++++---- spring-security-rest/pom.xml | 8 ++++---- 26 files changed, 106 insertions(+), 99 deletions(-) rename spring-security-rest-basic-auth/src/test/java/org/baeldung/client/{RawClientLiveTest.java => HttpsClientLiveManualTest.java} (95%) diff --git a/core-java/pom.xml b/core-java/pom.xml index fc621e362df6..ab40590cb3d9 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -133,12 +133,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 2.3.2 @@ -151,7 +151,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -169,7 +169,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/experiments/pom.xml b/experiments/pom.xml index d54efcec8034..606b1bfc49cc 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,12 +255,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -270,7 +270,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -288,7 +288,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/guava/pom.xml b/guava/pom.xml index f15b011ce8e2..b4abd03dc607 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,12 +94,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -109,7 +109,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -127,7 +127,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 1da5fe5166f0..c5cce96fafcb 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -130,12 +130,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -145,7 +145,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -163,7 +163,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/jackson/pom.xml b/jackson/pom.xml index c48d13d0a424..86ea96dceb48 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,12 +107,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 2.3.2 @@ -125,7 +125,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -143,7 +143,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/mockito/pom.xml b/mockito/pom.xml index b5aeb6be8df9..5f20d113fec6 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,12 +89,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -104,7 +104,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -122,7 +122,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 0a9b6033fcda..d7360668613d 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,14 +192,14 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 3.18.1-GA 1.2 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -209,7 +209,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -227,7 +227,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 472279056b35..9fa76afdf496 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,14 +204,14 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 3.18.1-GA 1.2 4.3.5.Final - 5.1.29 + 5.1.30 7.0.42 @@ -222,7 +222,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -241,7 +241,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 272db2b63e24..4b506d95e715 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,13 +174,13 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 3.18.1-GA 3.6.10.Final - 5.1.29 + 5.1.30 7.0.47 @@ -191,7 +191,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -209,7 +209,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index ffd4202452a1..c6438f00761b 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,13 +182,13 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 3.18.1-GA 4.3.5.Final - 5.1.29 + 5.1.30 7.0.42 @@ -199,7 +199,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -218,7 +218,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 81f7b8b0707c..8ec998095e77 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,12 +177,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -192,7 +192,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -211,7 +211,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index fde7cc4ffa34..456b4e095e6c 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,12 +141,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -156,7 +156,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -174,7 +174,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 11fb31e3ff36..f4db08254109 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 1.7.6 @@ -166,7 +166,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 2bd23fdb81dc..449bb0ded266 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,7 +141,7 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 1.7.6 @@ -162,7 +162,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index a2095f8a6240..f1d105d0490b 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,12 +202,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 @@ -217,7 +217,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -238,7 +238,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 2c8d949b642e..4b4cec8f15a0 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -226,12 +226,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -241,7 +241,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -259,7 +259,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 945810b4d1c5..48b9b8e4c1c8 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -231,12 +231,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -246,7 +246,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -264,7 +264,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 2135c42234e1..91aab8b220d5 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -226,12 +226,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -241,7 +241,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -259,7 +259,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index c4e654616fba..556e6eb086c6 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -223,12 +223,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -238,7 +238,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -256,7 +256,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index dd3fb4c5f348..c0a91edc7bd4 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -231,12 +231,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -246,7 +246,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -264,7 +264,7 @@ 2.4 2.17 2.6 - 1.4.7 + 1.4.8 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index f3fa27447a22..64d5015a7b10 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.baeldung spring-security-rest-basic-auth - 0.1-SNAPSHOT + 0.2-SNAPSHOT spring-security-rest-basic-auth war @@ -88,7 +88,7 @@ com.fasterxml.jackson.core jackson-databind - 2.2.2 + 2.2.3 @@ -286,12 +286,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 4.3.2 @@ -305,7 +305,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -319,7 +319,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java similarity index 95% rename from spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java rename to spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java index e99745c3d3e7..370ac79f6f80 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RawClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java @@ -31,7 +31,11 @@ import org.junit.Ignore; import org.junit.Test; -public class RawClientLiveTest { +/** + * This test requires a localhost server over HTTPS
+ * It should only be manually run, not part of the automated build + * */ +public class HttpsClientLiveManualTest { // tests @@ -70,6 +74,7 @@ public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolEx assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } + @SuppressWarnings("deprecation") @Test public final void givenHttpClientPre4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @@ -89,6 +94,8 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String final HttpGet getMethod = new HttpGet(urlOverHttps); final HttpResponse response = httpClient.execute(getMethod); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + + httpClient.close(); } @Test diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 43f14d0b3208..d5631e41212d 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -251,12 +251,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -266,7 +266,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -283,7 +283,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 4ddab86ee93d..e97df2100ce9 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,12 +275,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 4.3.2 @@ -294,7 +294,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -308,7 +308,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index d17388f5395e..4f702de82957 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -301,12 +301,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.4.3.RELEASE @@ -321,7 +321,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -338,7 +338,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index da5ed3d24e6e..b6a9ebbbb41a 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -214,12 +214,12 @@ - 4.0.3.RELEASE + 4.0.4.RELEASE 3.2.3.RELEASE 4.3.5.Final - 5.1.29 + 5.1.30 1.7.6 @@ -229,7 +229,7 @@ 5.0.3.Final - 16.0.1 + 17.0 3.3.1 @@ -246,7 +246,7 @@ 3.1 2.4 2.17 - 1.4.7 + 1.4.8 From c17010d956c3109cd810d904efd7c7efd8e3f84d Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 7 May 2014 11:57:46 +0300 Subject: [PATCH 476/796] testing work --- spring-security-rest-basic-auth/pom.xml | 1 + .../org/baeldung/client/ClientLiveTest.java | 30 ----------- .../client/HttpsClientLiveManualTest.java | 51 +++++++++---------- 3 files changed, 25 insertions(+), 57 deletions(-) diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 64d5015a7b10..79965a553c43 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -252,6 +252,7 @@ **/*LiveTest.java + **/*ManualTest.java diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java index 6b1bfc3dce24..817e818b588b 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -1,26 +1,16 @@ package org.baeldung.client; -import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import java.security.GeneralSecurityException; -import java.security.cert.X509Certificate; - -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.impl.client.CloseableHttpClient; import org.baeldung.client.spring.ClientConfig; import org.baeldung.web.dto.Foo; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -54,24 +44,4 @@ public final void whenHttpsUrlIsConsumed_thenException() { assertThat(response.getStatusCode().value(), equalTo(200)); } - @Test - @Ignore("Only to run against a Server with HTTPS enabled (on 8443)") - public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { - final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); - - final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { - return true; - } - }; - final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER); - httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); - - final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; - final ResponseEntity response = new RestTemplate(requestFactory).exchange(urlOverHttps, HttpMethod.GET, null, String.class); - assertThat(response.getStatusCode().value(), equalTo(200)); - } - } diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java index 370ac79f6f80..4d371dc1f069 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/HttpsClientLiveManualTest.java @@ -1,19 +1,17 @@ package org.baeldung.client; +import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.cert.X509Certificate; -import java.util.Timer; -import java.util.TimerTask; import javax.net.ssl.SSLPeerUnverifiedException; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; @@ -30,6 +28,10 @@ import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.junit.Ignore; import org.junit.Test; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; /** * This test requires a localhost server over HTTPS
@@ -39,30 +41,6 @@ public class HttpsClientLiveManualTest { // tests - @Test - public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException { - final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); - - final int timeout = 30; // seconds - final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build(); - final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1"); - getMethod.setConfig(requestConfig); - - final int hardTimeout = 10; // seconds - final TimerTask task = new TimerTask() { - @Override - public void run() { - if (getMethod != null) { - getMethod.abort(); - } - } - }; - new Timer(true).schedule(task, hardTimeout * 1000); - - final HttpResponse response = httpClient.execute(getMethod); - System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode()); - } - @Test(expected = SSLPeerUnverifiedException.class) @Ignore("Only for a server that has HTTPS enabled (on 8443)") public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolException, IOException { @@ -98,6 +76,25 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String httpClient.close(); } + @Test + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { + final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); + final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); + + final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { + @Override + public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { + return true; + } + }; + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER); + httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); + + final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final ResponseEntity response = new RestTemplate(requestFactory).exchange(urlOverHttps, HttpMethod.GET, null, String.class); + assertThat(response.getStatusCode().value(), equalTo(200)); + } + @Test public final void givenHttpClientPost4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { final SSLContextBuilder builder = new SSLContextBuilder(); From 87b25ea4d7be9d2d09c51ddd3e93a03d6e7f7e03 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 7 May 2014 14:46:22 +0300 Subject: [PATCH 477/796] maven upgrade --- spring-security-rest-full/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 4f702de82957..9c0e590ce462 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -266,7 +266,7 @@ ${maven-surefire-plugin.version} - + **/*LiveTest.java @@ -307,7 +307,7 @@ 4.3.5.Final 5.1.30 - 1.4.3.RELEASE + 1.5.2.RELEASE From 730ebd57afc3b8f71bf360a24b47b7df57415368 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 9 May 2014 15:45:46 -0500 Subject: [PATCH 478/796] Update FooSortingServiceTest.java --- .../service/FooSortingServiceTest.java | 458 ++++++------------ 1 file changed, 144 insertions(+), 314 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 9fc80b8621ed..9d6f3c355a17 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -1,390 +1,220 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import static org.junit.Assert.*; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.After; +import java.util.List; +import java.util.Set; import org.hibernate.Criteria; import org.hibernate.NullPrecedence; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.Transaction; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.google.common.collect.Lists; +import com.cc.example.hibernate.Foo; +import com.cc.example.hibernate.Bar; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) + + + public class FooSortingServiceTest { + private static Configuration configuration; + private static StandardServiceRegistryBuilder builder; + private static SessionFactory sf; + private static Session sess; - // tests + @BeforeClass + public static void before() { - @Test - public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - Session sess = null; - List fooList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name"; - final Query query = sess.createQuery(hql); - fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } - } + configuration = new Configuration().configure(); + builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); + sf = configuration.buildSessionFactory(builder.build()); + sess = sf.openSession(); + sess.beginTransaction(); + } + @After + public void after() { } @Test - public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - Session sess = null; - List fooList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name ASC"; - final Query query = sess.createQuery(hql); - fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } + sess.getTransaction().commit(); } @Test - public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - Session sess = null; - List fooList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name, f.id"; - final Query query = sess.createQuery(hql); - fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenHQlSortingByStringNullLast_thenLastNull() { + + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } + sess.getTransaction().commit(); } @Test - public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedOrderedResults() { - Session sess = null; - List fooList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - final Query query = sess.createQuery(hql); - fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { + + final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + sess.getTransaction().commit(); } @Test - public final void whenCriteriaSortingByOneAttr_thenPrintSortedResults() { - Session sess = null; - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = Lists.newArrayList(); - try { - sess.beginTransaction(); - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("id")); - fooList = criteria.list(); - assertEquals(1, fooList.get(0).getId()); - assertEquals(100, fooList.get(fooList.toArray().length - 1).getId()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - sess.getTransaction().commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + final String hql = "FROM Foo f ORDER BY f.name ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() + + ); } + sess.getTransaction().commit(); + } @Test - public final void whenCriteriaSortingByMultipAttr_thenSortedResults() { - Session sess = null; - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = Lists.newArrayList(); - try { - sess.beginTransaction(); - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name")); - criteria.addOrder(Order.asc("id")); - fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - sess.getTransaction().commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + final String hql = "FROM Foo f ORDER BY f.name, f.id"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() + + ); } + sess.getTransaction().commit(); + } @Test - public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - Session sess = null; - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = Lists.newArrayList(); - try { - sess.beginTransaction(); - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); - fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } + sess.getTransaction().commit(); + } @Test - public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - Session sess = null; - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = Lists.newArrayList(); - try { - sess.beginTransaction(); - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - fooList = criteria.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); } + sess.getTransaction().commit(); + } @Test - public final void whenHQlSortingByStringNullLast_thenLastNull() { - Session sess = null; - List fooList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - - final Query query = sess.createQuery(hql); - fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); } + sess.getTransaction().commit(); } @Test - public final void whenSortingBars_thenBarsWithSortedFoos() { - Session sess = null; - final Set fooList = new TreeSet(); - List barList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Bar b ORDER BY b.id"; - final Query query = sess.createQuery(hql); - barList = query.list(); - - for (final Bar bar : barList) { - System.out.println("Bar Id:" + bar.getId()); - for (final Foo foo : bar.getFooList()) { - System.out.println("FooName:" + foo.getName()); - } - } - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + final List fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); } - // @Test - // public final void whenSortingPrimitiveNulls_thenException() { - // Session sess = null; - // List fooList = new ArrayList(); - // final List barList = new ArrayList(); - // - // try { - // final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - // sess = sf.openSession(); - // final String hql = "FROM Foo f ORDER BY f.idx"; - // final Query query = sess.createQuery(hql); - // boolean thrown = false; - // try { - // fooList = criteria.list(); - // } catch (final org.hibernate.PropertyAccessException e) { - // thrown = true; - // } - // assertTrue(thrown); - // - // final Transaction tr = sess.beginTransaction(); - // tr.commit(); - // } catch (final Exception ex) { - // ex.printStackTrace(); - // } finally { - // if (sess != null) { - // sess.close(); - // } - // } - // } - @Test - public final void whenSortingStringNullsLast_thenReturnNullsLast() { - Session sess = null; - List fooList = Lists.newArrayList(); - final List barList = Lists.newArrayList(); - - try { - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - final Query query = sess.createQuery(hql); - fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("FooIDX:" + foo.getName()); + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - } + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + final List fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - final Transaction tr = sess.beginTransaction(); - tr.commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); - } } + sess.getTransaction().commit(); } @Test - public final void whenNullPrimitiveValueCriteriaSortingByMultipAttr_thenException() { - Session sess = null; - final SessionFactory sf = new Configuration().configure().buildSessionFactory(); - sess = sf.openSession(); - List fooList = Lists.newArrayList(); - try { - sess.beginTransaction(); - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - criteria.addOrder(Order.asc("idx")); - boolean thrown = false; - try { - fooList = criteria.list(); - } catch (final org.hibernate.PropertyAccessException e) { - thrown = true; - } - assertTrue(thrown); - - sess.getTransaction().commit(); - } catch (final Exception ex) { - ex.printStackTrace(); - } finally { - if (sess != null) { - sess.close(); + public final void whenSortingBars_thenBarsWithSortedFoos() { + + final String hql = "FROM Bar b ORDER BY b.id"; + final Query query = sess.createQuery(hql); + final List barList = query.list(); + for (final Bar bar : barList) { + final Set fooSet = bar.getFooList(); + System.out.println("Bar Id:" + bar.getId()); + for (final Foo foo : fooSet) { + System.out.println("FooName:" + foo.getName()); + } } + sess.getTransaction().commit(); + } + } From 80cb34833ca1b4698ea4de4746884fe6ceacfc26 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 9 May 2014 15:48:57 -0500 Subject: [PATCH 479/796] Update Bar.java --- .../org/baeldung/persistence/model/Bar.java | 68 ++++++++++--------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index ddc60bf0c9e2..0489dbc21a90 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,60 +1,63 @@ package org.baeldung.persistence.model; import java.io.Serializable; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import java.util.Set; +import com.google.common.collect.Sets; +import javax.persistence.*; +import org.hibernate.annotations.OrderBy; @Entity +@NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") public class Bar implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(nullable = false) - private String name; - - private List foos; - public Bar() { super(); } public Bar(final String name) { super(); - + this.name = name; } - // API + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; + + @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @OrderBy(clause = "NAME DESC") + Set fooSet = Sets.newHashSet(); + + //API + + public Set getFooSet() { + return fooSet; + } + + public void setFooList(Set fooSet) { + this.fooSet = fooSet; + } - public long getId() { - return id; + public int getId() { + return this.id; } - public void setId(final long id) { + public void setId(int id) { this.id = id; } public String getName() { - return name; + return this.name; } - public void setName(final String name) { + public void setName(String name) { this.name = name; } - - public List getFooList() { - return foos; - } - // - + @Override public int hashCode() { final int prime = 31; @@ -62,7 +65,7 @@ public int hashCode() { result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) @@ -79,12 +82,13 @@ public boolean equals(final Object obj) { return false; return true; } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("Foo [name=").append(name).append("]"); + builder.append("Bar [name=").append(name).append("]"); return builder.toString(); } + } From 82ccad7146e0d734edc33273df9cd1b56546f718 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 9 May 2014 15:51:04 -0500 Subject: [PATCH 480/796] Update Bar.java --- .../org/baeldung/persistence/model/Bar.java | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java index ddc60bf0c9e2..b3e789b9ce67 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,60 +1,66 @@ package org.baeldung.persistence.model; import java.io.Serializable; -import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.CascadeType; @Entity public class Bar implements Serializable { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - + @Column(nullable = false) private String name; - - private List foos; - + + @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @OrderBy("name ASC") + List fooList; + public Bar() { super(); } - + public Bar(final String name) { super(); - + this.name = name; } - + // API - + public long getId() { return id; } - + public void setId(final long id) { this.id = id; } - + public String getName() { return name; } - + public void setName(final String name) { this.name = name; } - + public List getFooList() { - return foos; + return fooList; } - + + public void setFooList(final List fooList) { + this.fooList = fooList; + } + // - + @Override public int hashCode() { final int prime = 31; @@ -62,7 +68,7 @@ public int hashCode() { result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) @@ -79,12 +85,12 @@ public boolean equals(final Object obj) { return false; return true; } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("Foo [name=").append(name).append("]"); + builder.append("Bar [name=").append(name).append("]"); return builder.toString(); } - + } From 554df1148d0ca5132195078ffe3e2735ee9af58e Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 9 May 2014 15:52:41 -0500 Subject: [PATCH 481/796] Update FooServiceSortingTests.java --- .../service/FooServiceSortingTests.java | 126 ++++++++---------- 1 file changed, 53 insertions(+), 73 deletions(-) diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index 0cc8645af8bb..e1ecbd2015f7 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -1,11 +1,7 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import static org.junit.Assert.*; import java.util.List; - import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; @@ -15,82 +11,79 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; - -import org.baeldung.persistence.model.Bar; -import org.baeldung.persistence.model.Foo; -import org.junit.After; +import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; +import com.cc.jpa.example.Foo; +import com.cc.jpa.example.Bar; public class FooServiceSortingTests { - private EntityManager entityManager; + private static EntityManager entityManager; + private static EntityManagerFactory emf; + private static EntityTransaction entityTransaction; + private static CriteriaBuilder criteriaBuilder; @BeforeClass public static void before() { - // - } - @After - public final void after() { - // + emf = Persistence.createEntityManagerFactory("punit"); + entityManager = emf.createEntityManager(); + entityTransaction = entityManager.getTransaction(); + entityTransaction.begin(); + criteriaBuilder = entityManager.getCriteriaBuilder(); } @Test public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); final String jql = "Select f from Foo as f order by f.id"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); - assertEquals(1, fooList.get(0).getId()); - assertEquals(100, fooList.get(fooList.toArray().length - 1).getId()); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } + } @Test public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); final String jql = "Select f from Foo as f order by f.id desc"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); - assertEquals(100, fooList.get(0).getId()); - assertEquals(1, fooList.get(fooList.toArray().length - 1).getId()); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } + } @Test public final void whenSortingByTwoAttributes_thenPrintSortedResult() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); + final String jql = "Select f from Foo as f order by f.name asc, f.id desc"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } + + } + + @Test + public final void whenSortingFooByBar_thenBarsSorted() { + + final String jql = "Select f from Foo as f order by f.name, f.bar.id"; + final Query barJoinQuery = entityManager.createQuery(jql); + final List fooList = barJoinQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------BarId:" + foo.getBar().getId()); + } } @Test public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); - final String jql = "Select b from Bar as b order by b.id"; + final String jql = "Select b from Bar as b order by b.id"; final Query barQuery = entityManager.createQuery(jql); final List barList = barQuery.getResultList(); for (final Bar bar : barList) { @@ -99,15 +92,12 @@ public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { System.out.println("FooName:" + foo.getName()); } } + } @Test public final void whenSortingByStringNullLast_thenLastNull() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); @@ -117,43 +107,34 @@ public final void whenSortingByStringNullLast_thenLastNull() { } } - // @Test - // public final void whenSortingByStringNullFirst_thenFirstNull() { - // final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - // final EntityManager entityManager = emf.createEntityManager(); - // final EntityTransaction entityTransaction = entityManager.getTransaction(); - // entityTransaction.begin(); - // final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; - // final Query sortQuery = entityManager.createQuery(jql); - // final List fooList = sortQuery.getResultList(); - // assertNull(fooList.get(0).getName()); - // for (final Foo foo : fooList) { - // System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getTest_Null()); - // } - // } - @Test - public final void whenSortingByIntNull_thenException() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final EntityTransaction entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); - final String jql = "Select f from Foo as f order by f.test_Null desc NULLS FIRST"; + public final void whenSortingByStringNullFirst_thenFirstNull() { + + final Foo nullNameFoo = new Foo(); + nullNameFoo.setName(null); + + final Bar bar = new Bar(); + final List fooList1 = Lists.newArrayList(); + bar.setName("Bar_Me"); + nullNameFoo.setBar(bar); + fooList1.add(nullNameFoo); + bar.setFooList(fooList1); + entityManager.persist(bar); + entityManager.persist(nullNameFoo); + entityTransaction.commit(); + final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; final Query sortQuery = entityManager.createQuery(jql); - boolean thrown = false; - try { - final List fooList = sortQuery.getResultList(); - } catch (final javax.persistence.PersistenceException e) { - thrown = true; + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); } - assertTrue(thrown); } @Test public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + + criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); final CriteriaQuery select = criteriaQuery.select(from); @@ -168,9 +149,8 @@ public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { @Test public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { - final EntityManagerFactory emf = Persistence.createEntityManagerFactory("punit"); - final EntityManager entityManager = emf.createEntityManager(); - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + + criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); final CriteriaQuery select = criteriaQuery.select(from); From 08aa91739eef1e3f620ad479f75a8223d100a8eb Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 9 May 2014 18:05:11 -0500 Subject: [PATCH 482/796] Synched with Local --- .../org/baeldung/persistence/model/Bar.java | 43 +++++++++---------- .../org/baeldung/persistence/model/Foo.java | 1 - 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java index b3e789b9ce67..c2da09957f86 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,7 +1,6 @@ package org.baeldung.persistence.model; import java.io.Serializable; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -12,51 +11,51 @@ @Entity public class Bar implements Serializable { + private static final long serialVersionUID = 1L; + @Id @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(nullable = false) - private String name; + private int id; @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) @OrderBy("name ASC") List fooList; - public Bar() { + private String name; + + public Bar(){ super(); } - public Bar(final String name) { + public Bar(final String name){ super(); - this.name = name; } + + //API - // API - - public long getId() { - return id; + public List getFooList() { + return fooList; } - public void setId(final long id) { - this.id = id; + public void setFooList(List fooList) { + this.fooList = fooList; } - public String getName() { - return name; + public int getId() { + return this.id; } - public void setName(final String name) { - this.name = name; + public void setId(int id) { + this.id = id; } - public List getFooList() { - return fooList; + public String getName() { + return this.name; } - public void setFooList(final List fooList) { - this.fooList = fooList; + public void setName(String name) { + this.name = name; } // diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java index 8e1dee33e845..aed28cc07f01 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,7 +1,6 @@ package org.baeldung.persistence.model; import java.io.Serializable; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; From a5c1d774ec7246e59789286604342035f9bf417f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 10 May 2014 15:33:07 +0300 Subject: [PATCH 483/796] initial compilation fixes --- .../service/FooSortingServiceTest.java | 32 ++++++-------- .../org/baeldung/persistence/model/Bar.java | 42 ++++++++++--------- .../service/FooServiceSortingTests.java | 27 ++++-------- 3 files changed, 43 insertions(+), 58 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 9d6f3c355a17..1532c3ef3f80 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -1,26 +1,13 @@ package org.baeldung.persistence.service; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertNull; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; -import org.baeldung.spring.PersistenceConfig; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import static org.junit.Assert.*; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.After; import java.util.List; import java.util.Set; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; import org.hibernate.Criteria; import org.hibernate.NullPrecedence; import org.hibernate.Query; @@ -29,8 +16,13 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; -import com.cc.example.hibernate.Foo; -import com.cc.example.hibernate.Bar; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java index b3e789b9ce67..3f76680d3b90 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,66 +1,70 @@ package org.baeldung.persistence.model; import java.io.Serializable; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.CascadeType; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; @Entity public class Bar implements Serializable { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - + @Column(nullable = false) private String name; - + @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) @OrderBy("name ASC") List fooList; - + public Bar() { super(); } - + public Bar(final String name) { super(); - + this.name = name; } - + // API - + public long getId() { return id; } - + public void setId(final long id) { this.id = id; } - + public String getName() { return name; } - + public void setName(final String name) { this.name = name; } - + public List getFooList() { return fooList; } - + public void setFooList(final List fooList) { this.fooList = fooList; } - + // - + @Override public int hashCode() { final int prime = 31; @@ -68,7 +72,7 @@ public int hashCode() { result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) @@ -85,12 +89,12 @@ public boolean equals(final Object obj) { return false; return true; } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("Bar [name=").append(name).append("]"); return builder.toString(); } - + } diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index e1ecbd2015f7..37ed1dc2f0f4 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -1,7 +1,9 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNull; + import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; @@ -11,11 +13,13 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; -import com.google.common.collect.Lists; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; import org.junit.BeforeClass; import org.junit.Test; -import com.cc.jpa.example.Foo; -import com.cc.jpa.example.Bar; + +import com.google.common.collect.Lists; public class FooServiceSortingTests { private static EntityManager entityManager; @@ -25,7 +29,6 @@ public class FooServiceSortingTests { @BeforeClass public static void before() { - emf = Persistence.createEntityManagerFactory("punit"); entityManager = emf.createEntityManager(); entityTransaction = entityManager.getTransaction(); @@ -35,43 +38,36 @@ public static void before() { @Test public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { - final String jql = "Select f from Foo as f order by f.id"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } - } @Test public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { - final String jql = "Select f from Foo as f order by f.id desc"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } - } @Test public final void whenSortingByTwoAttributes_thenPrintSortedResult() { - final String jql = "Select f from Foo as f order by f.name asc, f.id desc"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); } - } @Test public final void whenSortingFooByBar_thenBarsSorted() { - final String jql = "Select f from Foo as f order by f.name, f.bar.id"; final Query barJoinQuery = entityManager.createQuery(jql); final List fooList = barJoinQuery.getResultList(); @@ -82,7 +78,6 @@ public final void whenSortingFooByBar_thenBarsSorted() { @Test public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { - final String jql = "Select b from Bar as b order by b.id"; final Query barQuery = entityManager.createQuery(jql); final List barList = barQuery.getResultList(); @@ -92,12 +87,10 @@ public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { System.out.println("FooName:" + foo.getName()); } } - } @Test public final void whenSortingByStringNullLast_thenLastNull() { - final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); @@ -109,7 +102,6 @@ public final void whenSortingByStringNullLast_thenLastNull() { @Test public final void whenSortingByStringNullFirst_thenFirstNull() { - final Foo nullNameFoo = new Foo(); nullNameFoo.setName(null); @@ -133,7 +125,6 @@ public final void whenSortingByStringNullFirst_thenFirstNull() { @Test public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { - criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); @@ -144,12 +135,10 @@ public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { for (final Foo foo : fooList) { System.out.println("Name:" + foo.getName() + "--------Id:" + foo.getId()); } - } @Test public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { - criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); From 942b186e60ac6a7b4cef12b1aad1b8a882ace36c Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sat, 10 May 2014 15:13:30 -0500 Subject: [PATCH 484/796] Hibernate/JPA Sorting Repo Compiled in Eclipse --- spring-hibernate4/.project | 6 +++ .../org.hibernate.eclipse.console.prefs | 3 ++ .../baeldung/persistence/model/Bar.hbm.xml | 21 ++++++++ .../org/baeldung/persistence/model/Bar.java | 8 +-- .../baeldung/persistence/model/Foo.hbm.xml | 21 ++++++++ .../org/baeldung/persistence/model/Foo.java | 39 +++++++++----- .../src/test/java/hibernate.cfg.xml | 37 +++++++++++++ .../service/FooSortingServiceTest.java | 48 ++++++----------- spring-jpa/.classpath | 6 +-- spring-jpa/.project | 6 +++ .../org.hibernate.eclipse.console.prefs | 3 ++ .../org/baeldung/persistence/model/Bar.java | 52 ++++++++++--------- .../org/baeldung/persistence/model/Foo.java | 34 ++++++++---- .../src/test/java/META-INF/persistence.xml | 16 ++++++ .../service/FooServiceSortingTests.java | 13 +++-- 15 files changed, 222 insertions(+), 91 deletions(-) create mode 100644 spring-hibernate4/.settings/org.hibernate.eclipse.console.prefs create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml create mode 100644 spring-hibernate4/src/test/java/hibernate.cfg.xml create mode 100644 spring-jpa/.settings/org.hibernate.eclipse.console.prefs create mode 100644 spring-jpa/src/test/java/META-INF/persistence.xml diff --git a/spring-hibernate4/.project b/spring-hibernate4/.project index b68719164667..10df76aa23b9 100644 --- a/spring-hibernate4/.project +++ b/spring-hibernate4/.project @@ -30,6 +30,11 @@ + + org.hibernate.eclipse.console.hibernateBuilder + + + org.springframework.ide.eclipse.core.springnature @@ -39,5 +44,6 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature + org.hibernate.eclipse.console.hibernateNature diff --git a/spring-hibernate4/.settings/org.hibernate.eclipse.console.prefs b/spring-hibernate4/.settings/org.hibernate.eclipse.console.prefs new file mode 100644 index 000000000000..7505c63770a0 --- /dev/null +++ b/spring-hibernate4/.settings/org.hibernate.eclipse.console.prefs @@ -0,0 +1,3 @@ +default.configuration= +eclipse.preferences.version=1 +hibernate3.enabled=true diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml new file mode 100644 index 000000000000..bbfbb7332960 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index 0489dbc21a90..cba3173f2fc0 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -36,8 +36,8 @@ public Bar(final String name) { public Set getFooSet() { return fooSet; } - - public void setFooList(Set fooSet) { + + public void setFooSet(final Set fooSet) { this.fooSet = fooSet; } @@ -45,7 +45,7 @@ public int getId() { return this.id; } - public void setId(int id) { + public void setId(final int id) { this.id = id; } @@ -53,7 +53,7 @@ public String getName() { return this.name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } // diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml new file mode 100644 index 000000000000..09922c87832a --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 8e1dee33e845..29e9b332ec8b 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -2,46 +2,61 @@ import java.io.Serializable; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; @Entity public class Foo implements Serializable { + private static final long serialVersionUID = 1L; + + public Foo() { + super(); + + } @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - - @Column(nullable = false) private String name; + @ManyToOne(targetEntity = Bar.class) + @JoinColumn(name = "BAR_ID") + @Fetch(FetchMode.JOIN) + private Bar bar = new Bar(); - public Foo() { - super(); + public Bar getBar() { + return bar; } - public Foo(final String name) { - super(); + public void setBar(final Bar bar) { + this.bar = bar; + } - this.name = name; + public int getBar_Id() { + return bar_Id; + } + + public void setBar_Id(final int bar_Id) { + this.bar_Id = bar_Id; } - // API + private int bar_Id; public long getId() { return id; } - public void setId(final long id) { this.id = id; } - public String getName() { return name; } - public void setName(final String name) { this.name = name; } diff --git a/spring-hibernate4/src/test/java/hibernate.cfg.xml b/spring-hibernate4/src/test/java/hibernate.cfg.xml new file mode 100644 index 000000000000..915295111ea0 --- /dev/null +++ b/spring-hibernate4/src/test/java/hibernate.cfg.xml @@ -0,0 +1,37 @@ + + + + + + + + +com.mysql.jdbc.Driver +jdbc:mysql://localhost:3306/HIBERTEST2_TEST +root + + + +1 + + +org.hibernate.dialect.MySQLDialect + + +thread + + +org.hibernate.cache.internal.NoCacheProvider + + +true + + + + + + + + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 9d6f3c355a17..b808a5e36b1e 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -1,26 +1,13 @@ package org.baeldung.persistence.service; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertNull; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; -import org.baeldung.spring.PersistenceConfig; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import static org.junit.Assert.*; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.After; import java.util.List; import java.util.Set; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; import org.hibernate.Criteria; import org.hibernate.NullPrecedence; import org.hibernate.Query; @@ -29,8 +16,14 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; -import com.cc.example.hibernate.Foo; -import com.cc.example.hibernate.Bar; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) @@ -81,7 +74,6 @@ public final void whenHQlSortingByStringNullLast_thenLastNull() { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } sess.getTransaction().commit(); - } @Test @@ -96,7 +88,6 @@ public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { } sess.getTransaction().commit(); - } @Test @@ -108,10 +99,9 @@ public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSorted for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - ); + ); } sess.getTransaction().commit(); - } @Test @@ -123,10 +113,9 @@ public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - ); + ); } sess.getTransaction().commit(); - } @Test @@ -139,7 +128,6 @@ public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrint System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } sess.getTransaction().commit(); - } @Test @@ -152,7 +140,6 @@ public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); } sess.getTransaction().commit(); - } @Test @@ -166,7 +153,6 @@ public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); } sess.getTransaction().commit(); - } @Test @@ -178,10 +164,8 @@ public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { assertNull(fooList.get(fooList.toArray().length - 1).getName()); for (final Foo foo : fooList) { System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } sess.getTransaction().commit(); - } @Test @@ -206,7 +190,7 @@ public final void whenSortingBars_thenBarsWithSortedFoos() { final Query query = sess.createQuery(hql); final List barList = query.list(); for (final Bar bar : barList) { - final Set fooSet = bar.getFooList(); + final Set fooSet = bar.getFooSet(); System.out.println("Bar Id:" + bar.getId()); for (final Foo foo : fooSet) { System.out.println("FooName:" + foo.getName()); diff --git a/spring-jpa/.classpath b/spring-jpa/.classpath index ca257cf1f962..d1d54e092ae5 100644 --- a/spring-jpa/.classpath +++ b/spring-jpa/.classpath @@ -22,11 +22,7 @@ - - - - - + diff --git a/spring-jpa/.project b/spring-jpa/.project index 235ae29ecfc3..5bb2baa2b950 100644 --- a/spring-jpa/.project +++ b/spring-jpa/.project @@ -30,6 +30,11 @@ + + org.hibernate.eclipse.console.hibernateBuilder + + + org.springframework.ide.eclipse.core.springnature @@ -39,5 +44,6 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature + org.hibernate.eclipse.console.hibernateNature diff --git a/spring-jpa/.settings/org.hibernate.eclipse.console.prefs b/spring-jpa/.settings/org.hibernate.eclipse.console.prefs new file mode 100644 index 000000000000..7505c63770a0 --- /dev/null +++ b/spring-jpa/.settings/org.hibernate.eclipse.console.prefs @@ -0,0 +1,3 @@ +default.configuration= +eclipse.preferences.version=1 +hibernate3.enabled=true diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java index c2da09957f86..03162b84474c 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,65 +1,69 @@ package org.baeldung.persistence.model; import java.io.Serializable; -import javax.persistence.Column; +import java.util.List; + +import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.CascadeType; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; @Entity public class Bar implements Serializable { - + private static final long serialVersionUID = 1L; - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - + @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) @OrderBy("name ASC") List fooList; - + private String name; - + public Bar(){ super(); } - + public Bar(final String name){ super(); this.name = name; } //API - + public List getFooList() { return fooList; } - - public void setFooList(List fooList) { + + public void setFooList(final List fooList) { this.fooList = fooList; } - + public int getId() { - return this.id; + return id; } - - public void setId(int id) { + + public void setId(final int id) { this.id = id; } - + public String getName() { - return this.name; + return name; } - - public void setName(String name) { + + public void setName(final String name) { this.name = name; } - + // - + @Override public int hashCode() { final int prime = 31; @@ -67,7 +71,7 @@ public int hashCode() { result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) @@ -84,12 +88,12 @@ public boolean equals(final Object obj) { return false; return true; } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("Bar [name=").append(name).append("]"); return builder.toString(); } - + } diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java index aed28cc07f01..585cefb159e4 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java @@ -1,21 +1,20 @@ package org.baeldung.persistence.model; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; @Entity public class Foo implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(nullable = false) - private String name; + private static final long serialVersionUID = 1L; public Foo() { super(); @@ -27,13 +26,30 @@ public Foo(final String name) { this.name = name; } - // API + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "ID") + private long id; + @Column(name = "NAME") + private String name; + + @ManyToOne(targetEntity = Bar.class, fetch = FetchType.EAGER) + @JoinColumn(name = "BAR_ID") + private Bar bar; + + public Bar getBar() { + return bar; + } + + public void setBar(final Bar bar) { + this.bar = bar; + } public long getId() { return id; } - public void setId(final long id) { + public void setId(final int id) { this.id = id; } @@ -45,8 +61,6 @@ public void setName(final String name) { this.name = name; } - // - @Override public int hashCode() { final int prime = 31; diff --git a/spring-jpa/src/test/java/META-INF/persistence.xml b/spring-jpa/src/test/java/META-INF/persistence.xml new file mode 100644 index 000000000000..e52849179500 --- /dev/null +++ b/spring-jpa/src/test/java/META-INF/persistence.xml @@ -0,0 +1,16 @@ + + + + org.baeldung.persistence.model.Foo + org.baeldung.persistence.model.Bar + + + + + + + + + + + diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index e1ecbd2015f7..1a15faf2c1cb 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -1,7 +1,9 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNull; + import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; @@ -11,11 +13,13 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; -import com.google.common.collect.Lists; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; import org.junit.BeforeClass; import org.junit.Test; -import com.cc.jpa.example.Foo; -import com.cc.jpa.example.Bar; + +import com.google.common.collect.Lists; public class FooServiceSortingTests { private static EntityManager entityManager; @@ -162,4 +166,5 @@ public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSorte } } + } From ade8cb51db7eb2aa8051b353384b2664e57a0c73 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sat, 10 May 2014 18:33:51 -0500 Subject: [PATCH 485/796] Corrections After the Merge Today --- .../org/baeldung/persistence/model/Bar.java | 34 ++- .../org/baeldung/persistence/model/Foo.java | 19 +- .../service/FooSortingServiceTest.java | 269 +++++++++--------- 3 files changed, 163 insertions(+), 159 deletions(-) diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index cba3173f2fc0..b6cedbd772a8 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -2,10 +2,20 @@ import java.io.Serializable; import java.util.Set; -import com.google.common.collect.Sets; -import javax.persistence.*; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; + import org.hibernate.annotations.OrderBy; +import com.google.common.collect.Sets; + @Entity @NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") public class Bar implements Serializable { @@ -16,7 +26,7 @@ public Bar() { public Bar(final String name) { super(); - + this.name = name; } @@ -31,18 +41,18 @@ public Bar(final String name) { @OrderBy(clause = "NAME DESC") Set fooSet = Sets.newHashSet(); - //API - + // API + public Set getFooSet() { return fooSet; } - + public void setFooSet(final Set fooSet) { this.fooSet = fooSet; } public int getId() { - return this.id; + return id; } public void setId(final int id) { @@ -50,14 +60,15 @@ public void setId(final int id) { } public String getName() { - return this.name; + return name; } public void setName(final String name) { this.name = name; } + // - + @Override public int hashCode() { final int prime = 31; @@ -65,7 +76,7 @@ public int hashCode() { result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) @@ -82,7 +93,7 @@ public boolean equals(final Object obj) { return false; return true; } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); @@ -90,5 +101,4 @@ public String toString() { return builder.toString(); } - } diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 29e9b332ec8b..1f4ec7a544ef 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -21,6 +21,12 @@ public Foo() { super(); } + + public Foo(final String name) { + super(); + this.name = name; + } + @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @@ -38,25 +44,18 @@ public void setBar(final Bar bar) { this.bar = bar; } - public int getBar_Id() { - return bar_Id; - } - - public void setBar_Id(final int bar_Id) { - this.bar_Id = bar_Id; - } - - private int bar_Id; - public long getId() { return id; } + public void setId(final long id) { this.id = id; } + public String getName() { return name; } + public void setName(final String name) { this.name = name; } diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index a6dc8bd1b8b5..103d87b1f31f 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -1,21 +1,16 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.assertNull; - import java.util.List; import java.util.Set; import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceConfig; -import org.hibernate.Criteria; -import org.hibernate.NullPrecedence; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; -import org.hibernate.criterion.Order; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; @@ -49,138 +44,138 @@ public void after() { } - @Test - public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - - final String hql = "FROM Foo f ORDER BY f.name"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - - } - - @Test - public final void whenHQlSortingByStringNullLast_thenLastNull() { - - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { - - final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - - final String hql = "FROM Foo f ORDER BY f.name ASC"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - - ); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - - final String hql = "FROM Foo f ORDER BY f.name, f.id"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - - ); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { - - final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { - - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { - - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name")); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); - final List fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - final List fooList = criteria.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - - } - sess.getTransaction().commit(); - - } + /* @Test + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + sess.getTransaction().commit(); + + } + + @Test + public final void whenHQlSortingByStringNullLast_thenLastNull() { + + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { + + final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + + } + sess.getTransaction().commit(); + } + + @Test + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() + + ); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name, f.id"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() + + ); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { + + final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + final List fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + sess.getTransaction().commit(); + } + + @Test + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { + + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + final List fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + + } + sess.getTransaction().commit(); + + }*/ @Test public final void whenSortingBars_thenBarsWithSortedFoos() { From a2c98ab37f314e609d1cb6159fd0a1ac24e5b78d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 May 2014 10:35:35 +0300 Subject: [PATCH 486/796] minor cleanup --- .../org/baeldung/persistence/model/Bar.java | 21 ++++---- .../baeldung/persistence/model/Foo.hbm.xml | 2 - .../org/baeldung/persistence/model/Foo.java | 22 ++++---- .../src/test/java/hibernate.cfg.xml | 8 +-- ...erviceBasicPersistenceIntegrationTest.java | 54 +++++++++++++++++++ .../service/FooSortingServiceTest.java | 37 ++++--------- 6 files changed, 90 insertions(+), 54 deletions(-) create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index b6cedbd772a8..beca727200ca 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -20,6 +20,16 @@ @NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") public class Bar implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; + + @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @OrderBy(clause = "NAME DESC") + private Set fooSet = Sets.newHashSet(); + public Bar() { super(); } @@ -30,17 +40,6 @@ public Bar(final String name) { this.name = name; } - private static final long serialVersionUID = 1L; - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - private String name; - - @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.EAGER) - @OrderBy(clause = "NAME DESC") - Set fooSet = Sets.newHashSet(); - // API public Set getFooSet() { diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml index 09922c87832a..db7ec3010bd5 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml @@ -15,7 +15,5 @@ - - diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 1f4ec7a544ef..f6280c03639c 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -15,7 +16,17 @@ @Entity public class Foo implements Serializable { - private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + @ManyToOne(targetEntity = Bar.class) + @JoinColumn(name = "BAR_ID") + @Fetch(FetchMode.JOIN) + private Bar bar = new Bar(); public Foo() { super(); @@ -27,14 +38,7 @@ public Foo(final String name) { this.name = name; } - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - private String name; - @ManyToOne(targetEntity = Bar.class) - @JoinColumn(name = "BAR_ID") - @Fetch(FetchMode.JOIN) - private Bar bar = new Bar(); + // public Bar getBar() { return bar; diff --git a/spring-hibernate4/src/test/java/hibernate.cfg.xml b/spring-hibernate4/src/test/java/hibernate.cfg.xml index 915295111ea0..3c4e53efb8ad 100644 --- a/spring-hibernate4/src/test/java/hibernate.cfg.xml +++ b/spring-hibernate4/src/test/java/hibernate.cfg.xml @@ -9,9 +9,9 @@ com.mysql.jdbc.Driver -jdbc:mysql://localhost:3306/HIBERTEST2_TEST -root - +jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +tutorialuser +tutorialmy5ql 1 @@ -33,5 +33,5 @@ - + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java new file mode 100644 index 000000000000..457f5cc51993 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java @@ -0,0 +1,54 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServiceBasicPersistenceIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private IFooService fooService; + + private Session session; + + // tests + + @Before + public final void before() { + session = sessionFactory.openSession(); + } + + @After + public final void after() { + session.close(); + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + fooService.create(new Foo(randomAlphabetic(6))); + } + +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java index 103d87b1f31f..b75e2b2f3b97 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java @@ -12,7 +12,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.junit.After; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; @@ -21,32 +21,26 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) - - - public class FooSortingServiceTest { - private static Configuration configuration; - private static StandardServiceRegistryBuilder builder; - private static SessionFactory sf; - private static Session sess; + private SessionFactory sf; + private Session sess; - @BeforeClass - public static void before() { - - configuration = new Configuration().configure(); - builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); + @Before + public void before() { + final Configuration configuration = new Configuration().configure(); + final StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); sf = configuration.buildSessionFactory(builder.build()); sess = sf.openSession(); sess.beginTransaction(); } + @After public void after() { - + // } /* @Test public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -54,12 +48,10 @@ public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); } sess.getTransaction().commit(); - } @Test public final void whenHQlSortingByStringNullLast_thenLastNull() { - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -72,7 +64,6 @@ public final void whenHQlSortingByStringNullLast_thenLastNull() { @Test public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { - final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -86,7 +77,6 @@ public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { @Test public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name ASC"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -100,7 +90,6 @@ public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSorted @Test public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name, f.id"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -114,7 +103,6 @@ public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { @Test public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; final Query query = sess.createQuery(hql); final List fooList = query.list(); @@ -126,7 +114,6 @@ public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrint @Test public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("id")); final List fooList = criteria.list(); @@ -138,7 +125,6 @@ public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { @Test public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("name")); criteria.addOrder(Order.asc("id")); @@ -151,7 +137,6 @@ public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { @Test public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); final List fooList = criteria.list(); @@ -164,7 +149,6 @@ public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { @Test public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); final List fooList = criteria.list(); @@ -174,12 +158,10 @@ public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { } sess.getTransaction().commit(); - }*/ @Test public final void whenSortingBars_thenBarsWithSortedFoos() { - final String hql = "FROM Bar b ORDER BY b.id"; final Query query = sess.createQuery(hql); final List barList = query.list(); @@ -192,7 +174,6 @@ public final void whenSortingBars_thenBarsWithSortedFoos() { } } sess.getTransaction().commit(); - } } From 890d4348cd99f4c6f26095f883e0688ab7083b92 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 May 2014 10:39:34 +0300 Subject: [PATCH 487/796] minor testing work --- .../org/baeldung/persistence/model/Foo.java | 1 - .../persistence/IntegrationTestSuite.java | 21 +++++++++++++++++++ ...erviceBasicPersistenceIntegrationTest.java | 1 + ...ePaginationPersistenceIntegrationTest.java | 1 + .../FooServicePersistenceIntegrationTest.java | 1 + .../FooSortingServiceTest.java | 2 +- 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java rename spring-hibernate4/src/test/java/org/baeldung/persistence/{service => test}/FooSortingServiceTest.java (99%) diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index f6280c03639c..0c2007a945a3 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -30,7 +30,6 @@ public class Foo implements Serializable { public Foo() { super(); - } public Foo(final String name) { diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java new file mode 100644 index 000000000000..61f4dc456a90 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java @@ -0,0 +1,21 @@ +package org.baeldung.persistence; + +import org.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest; +import org.baeldung.persistence.service.FooServicePaginationPersistenceIntegrationTest; +import org.baeldung.persistence.service.FooServicePersistenceIntegrationTest; +import org.baeldung.persistence.service.ParentServicePersistenceIntegrationTest; +import org.baeldung.persistence.test.FooSortingServiceTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({// @formatter:off + FooServiceBasicPersistenceIntegrationTest.class + ,FooServicePaginationPersistenceIntegrationTest.class + ,FooServicePersistenceIntegrationTest.class + ,ParentServicePersistenceIntegrationTest.class + ,FooSortingServiceTest.class +}) // @formatter:on +public class IntegrationTestSuite { + // +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java index 457f5cc51993..2865810c679d 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java @@ -3,6 +3,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; import org.hibernate.Session; import org.hibernate.SessionFactory; diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java index 1204b8ed1302..24f1e241ce18 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java @@ -8,6 +8,7 @@ import java.util.List; import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; import org.hibernate.Criteria; import org.hibernate.Query; diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 84e5d39d1540..5b45d65e579d 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -3,6 +3,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java similarity index 99% rename from spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java index b75e2b2f3b97..a7d317276283 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.persistence.test; import java.util.List; import java.util.Set; From 1e9eefc8339f36102bed1906c29f6f132f5e3bc1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 May 2014 10:45:01 +0300 Subject: [PATCH 488/796] minor testing work --- .../org/baeldung/persistence/IntegrationTestSuite.java | 8 ++++---- .../FooPaginationPersistenceIntegrationTest.java} | 4 ++-- .../FooSortingPersistenceServiceTest.java} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename spring-hibernate4/src/test/java/org/baeldung/persistence/{service/FooServicePaginationPersistenceIntegrationTest.java => hibernate/FooPaginationPersistenceIntegrationTest.java} (98%) rename spring-hibernate4/src/test/java/org/baeldung/persistence/{test/FooSortingServiceTest.java => hibernate/FooSortingPersistenceServiceTest.java} (98%) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java index 61f4dc456a90..938e8f359cfc 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/IntegrationTestSuite.java @@ -1,20 +1,20 @@ package org.baeldung.persistence; +import org.baeldung.persistence.hibernate.FooPaginationPersistenceIntegrationTest; +import org.baeldung.persistence.hibernate.FooSortingPersistenceServiceTest; import org.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest; -import org.baeldung.persistence.service.FooServicePaginationPersistenceIntegrationTest; import org.baeldung.persistence.service.FooServicePersistenceIntegrationTest; import org.baeldung.persistence.service.ParentServicePersistenceIntegrationTest; -import org.baeldung.persistence.test.FooSortingServiceTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({// @formatter:off FooServiceBasicPersistenceIntegrationTest.class - ,FooServicePaginationPersistenceIntegrationTest.class + ,FooPaginationPersistenceIntegrationTest.class ,FooServicePersistenceIntegrationTest.class ,ParentServicePersistenceIntegrationTest.class - ,FooSortingServiceTest.class + ,FooSortingPersistenceServiceTest.class }) // @formatter:on public class IntegrationTestSuite { // diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java similarity index 98% rename from spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java index 24f1e241ce18..ec90c3779c8e 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePaginationPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.persistence.hibernate; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.hamcrest.Matchers.hasSize; @@ -31,7 +31,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServicePaginationPersistenceIntegrationTest { +public class FooPaginationPersistenceIntegrationTest { @Autowired private SessionFactory sessionFactory; diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java similarity index 98% rename from spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java index a7d317276283..3c01995dc0cd 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/test/FooSortingServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.test; +package org.baeldung.persistence.hibernate; import java.util.List; import java.util.Set; @@ -21,7 +21,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooSortingServiceTest { +public class FooSortingPersistenceServiceTest { private SessionFactory sf; private Session sess; From a9738345e8e1ea5c5539645f4ba4e36fb5eb1a1c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 May 2014 16:17:22 +0300 Subject: [PATCH 489/796] small cleanup work --- .../src/test/java/hibernate.cfg.xml | 52 ++-- .../FooSortingPersistenceServiceTest.java | 238 +++++++++--------- 2 files changed, 140 insertions(+), 150 deletions(-) diff --git a/spring-hibernate4/src/test/java/hibernate.cfg.xml b/spring-hibernate4/src/test/java/hibernate.cfg.xml index 3c4e53efb8ad..b073f6e3e66b 100644 --- a/spring-hibernate4/src/test/java/hibernate.cfg.xml +++ b/spring-hibernate4/src/test/java/hibernate.cfg.xml @@ -7,31 +7,31 @@ - -com.mysql.jdbc.Driver -jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true -tutorialuser -tutorialmy5ql - - -1 - - -org.hibernate.dialect.MySQLDialect - - -thread - - -org.hibernate.cache.internal.NoCacheProvider - - -true - - - - - - + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true + tutorialuser + tutorialmy5ql + + + 1 + + + org.hibernate.dialect.MySQLDialect + + + thread + + + org.hibernate.cache.internal.NoCacheProvider + + + true + + + + + + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java index 3c01995dc0cd..afaa74ea27aa 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java @@ -1,16 +1,21 @@ package org.baeldung.persistence.hibernate; +import static org.junit.Assert.assertNull; + import java.util.List; import java.util.Set; import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceConfig; +import org.hibernate.Criteria; +import org.hibernate.NullPrecedence; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; +import org.hibernate.criterion.Order; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -21,12 +26,13 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +@SuppressWarnings("unchecked") public class FooSortingPersistenceServiceTest { private SessionFactory sf; private Session sess; @Before - public void before() { + public final void before() { final Configuration configuration = new Configuration().configure(); final StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); sf = configuration.buildSessionFactory(builder.build()); @@ -36,129 +42,115 @@ public void before() { @After public void after() { - // + sess.getTransaction().commit(); + } + + @Test + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByStringNullLast_thenLastNull() { + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } } - /* @Test - public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByStringNullLast_thenLastNull() { - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { - final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name ASC"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - - ); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name, f.id"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId() - - ); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - final Query query = sess.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name")); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); - final List fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - sess.getTransaction().commit(); - } - - @Test - public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - final List fooList = criteria.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - - } - sess.getTransaction().commit(); - }*/ + @Test + public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { + final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + + } + } + + @Test + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name, f.id"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + final Query query = sess.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + final List fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { + final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + final List fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } @Test public final void whenSortingBars_thenBarsWithSortedFoos() { @@ -170,10 +162,8 @@ public final void whenSortingBars_thenBarsWithSortedFoos() { System.out.println("Bar Id:" + bar.getId()); for (final Foo foo : fooSet) { System.out.println("FooName:" + foo.getName()); - } } - sess.getTransaction().commit(); } } From 07419451d73213bde7d5ae94a26afe3acc7e31d7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 12 May 2014 17:57:33 +0300 Subject: [PATCH 490/796] simple jackson test for enums --- .../jackson/dtos/withEnum/TypeEnumSimple.java | 33 +++++++++++++++++++ .../JacksonSerializationEnumsUnitTest.java | 14 ++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java new file mode 100644 index 000000000000..4cf71f722129 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java @@ -0,0 +1,33 @@ +package org.baeldung.jackson.dtos.withEnum; + + +public enum TypeEnumSimple { + TYPE1(1, "Type A"), TYPE2(2, "Type 2"); + + private Integer id; + private String name; + + private TypeEnumSimple(final Integer id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java index a19b6831bd5f..bdf8c888fbae 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java @@ -8,6 +8,7 @@ import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnum; import org.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom; import org.baeldung.jackson.dtos.withEnum.TypeEnum; +import org.baeldung.jackson.dtos.withEnum.TypeEnumSimple; import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; import org.junit.Test; @@ -19,9 +20,18 @@ public class JacksonSerializationEnumsUnitTest { // tests - enums @Test - public final void whenSerializingSimpleEnum_thenCorrect() throws JsonParseException, IOException { + public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); + final String dtoAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1.name()); + System.out.println(dtoAsString); + + assertThat(dtoAsString, containsString("TYPE1")); + } + + @Test + public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1.name()); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); From 27ab504a9012f30087b1bf0ac7b2fa9444c0609c Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 13 May 2014 09:42:24 -0500 Subject: [PATCH 491/796] Latest Changes as of May 13th MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added utility class for data creation (populating tables). Eliminated hbm.xml files Fixed the strange “id bug†with Foo Eliminated the bar_id field from the Foo class --- .../baeldung/persistence/model/Bar.hbm.xml | 21 ---- .../org/baeldung/persistence/model/Bar.java | 5 +- .../baeldung/persistence/model/Foo.hbm.xml | 19 --- .../org/baeldung/persistence/model/Foo.java | 11 +- .../src/test/java/hibernate.cfg.xml | 53 ++++---- .../FooSortingPersistenceServiceData.java | 119 ++++++++++++++++++ .../FooSortingPersistenceServiceTest.java | 24 +++- 7 files changed, 174 insertions(+), 78 deletions(-) delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml delete mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml deleted file mode 100644 index bbfbb7332960..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.hbm.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index beca727200ca..410ad79b025a 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -4,6 +4,7 @@ import java.util.Set; import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -22,11 +23,13 @@ public class Bar implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") private int id; + @Column(name = "name") private String name; - @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OrderBy(clause = "NAME DESC") private Set fooSet = Sets.newHashSet(); diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml deleted file mode 100644 index db7ec3010bd5..000000000000 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.hbm.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 0c2007a945a3..974535e05801 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -2,30 +2,29 @@ import java.io.Serializable; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; - @Entity public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") private long id; - @Column(nullable = false) + @Column(name = "name") private String name; - @ManyToOne(targetEntity = Bar.class) + @ManyToOne(targetEntity = Bar.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "BAR_ID") - @Fetch(FetchMode.JOIN) private Bar bar = new Bar(); public Foo() { diff --git a/spring-hibernate4/src/test/java/hibernate.cfg.xml b/spring-hibernate4/src/test/java/hibernate.cfg.xml index b073f6e3e66b..2167eada167e 100644 --- a/spring-hibernate4/src/test/java/hibernate.cfg.xml +++ b/spring-hibernate4/src/test/java/hibernate.cfg.xml @@ -7,31 +7,30 @@ - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true - tutorialuser - tutorialmy5ql - - - 1 - - - org.hibernate.dialect.MySQLDialect - - - thread - - - org.hibernate.cache.internal.NoCacheProvider - - - true - - - - - - - + +com.mysql.jdbc.Driver +jdbc:mysql://localhost:3306/HIBERTEST2_TEST +root + + + +1 + + +org.hibernate.dialect.MySQLDialect + + +thread + + +org.hibernate.cache.internal.NoCacheProvider + + +true + + + + + + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java new file mode 100644 index 000000000000..5b8696821dca --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java @@ -0,0 +1,119 @@ +package org.baeldung.persistence.hibernate; + +import java.util.List; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; + +import com.google.common.collect.Lists; + +public class FooSortingPersistenceServiceData { + private static ServiceRegistry serviceRegistry; + private static SessionFactory sessionFactory; + private static Configuration configuration; + private static StandardServiceRegistryBuilder builder; + + public FooSortingPersistenceServiceData() { + super(); + } + + public void createBars() { + + configWork(); + Session session = null; + Transaction tx = null; + session = sessionFactory.openSession(); + tx = session.getTransaction(); + try { + tx.begin(); + for (int i = 156; i < 160; i++) { + final Bar bar = new Bar(); + bar.setName("Bar_" + i); + final Foo foo = new Foo("Foo_" + (i + 120)); + foo.setBar(bar); + session.save(foo); + final Foo foo2 = new Foo(null); + if (i % 2 == 0) + foo2.setName("LuckyFoo" + (i + 120)); + foo2.setBar(bar); + session.save(foo2); + bar.getFooSet().add(foo); + bar.getFooSet().add(foo2); + session.merge(bar); + } + tx.commit(); + session.flush(); + } catch (final HibernateException he) { + if (tx != null) + tx.rollback(); + System.out.println("Not able to open session"); + he.printStackTrace(); + } catch (final Exception e) { + e.printStackTrace(); + } finally { + if (session != null) + session.close(); + } + + } + + public void createFoos() { + + configWork(); + Session session = null; + Transaction tx = null; + session = sessionFactory.openSession(); + tx = session.getTransaction(); + final List fooList = Lists.newArrayList(); + for (int i = 35; i < 46; i++) { + + final Foo foo = new Foo(); + foo.setName("Foo_" + (i + 120)); + final Bar bar = new Bar("bar_" + i); + bar.getFooSet().add(foo); + foo.setBar(bar); + fooList.add(foo); + + } + try { + tx.begin(); + for (final Foo foo : fooList) { + + session.save(foo.getBar()); + session.save(foo); + } + tx.commit(); + session.flush(); + } catch (final HibernateException he) { + if (tx != null) + tx.rollback(); + System.out.println("Not able to open session"); + he.printStackTrace(); + } catch (final Exception e) { + e.printStackTrace(); + } finally { + if (session != null) + session.close(); + } + } + + public void configWork() { + configuration = new Configuration(); + configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); + configuration.setProperty("dialect", "org.hibernate.dialect.MySQLDialect"); + configuration.setProperty(AvailableSettings.DRIVER, "com.mysql.jdbc.Driver"); + configuration.setProperty(AvailableSettings.URL, "jdbc:mysql://localhost:3306/HIBERTEST2_TEST"); + configuration.setProperty(AvailableSettings.USER, "root"); + configuration.setProperty(AvailableSettings.PASS, ""); + builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); + sessionFactory = configuration.addPackage("com.cc.example.hibernate").addAnnotatedClass(Foo.class).addAnnotatedClass(Bar.class).configure().buildSessionFactory(builder.build()); + } +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java index afaa74ea27aa..fbc041ec02f6 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Set; +import javax.imageio.spi.ServiceRegistry; + import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceConfig; @@ -14,6 +16,7 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; import org.junit.After; @@ -30,12 +33,25 @@ public class FooSortingPersistenceServiceTest { private SessionFactory sf; private Session sess; + private static ServiceRegistry serviceRegistry; + private static Configuration configuration; + private static StandardServiceRegistryBuilder builder; @Before - public final void before() { - final Configuration configuration = new Configuration().configure(); - final StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); - sf = configuration.buildSessionFactory(builder.build()); + public void before() { + + // final FooSortingPersistenceServiceData fooData = new FooSortingPersistenceServiceData(); + // fooData.createBars(); + configuration = new Configuration(); + configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); + configuration.setProperty("dialect", "org.hibernate.dialect.MySQLDialect"); + configuration.setProperty(AvailableSettings.DRIVER, "com.mysql.jdbc.Driver"); + configuration.setProperty(AvailableSettings.URL, "jdbc:mysql://localhost:3306/HIBERTEST2_TEST"); + configuration.setProperty(AvailableSettings.USER, "root"); + configuration.setProperty(AvailableSettings.PASS, ""); + configuration.setProperty("hibernate.show_sql", "true"); + builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); + sf = configuration.addPackage("org.baeldung.persistence.model").addAnnotatedClass(Foo.class).addAnnotatedClass(Bar.class).configure().buildSessionFactory(builder.build()); sess = sf.openSession(); sess.beginTransaction(); } From 00fe1b2a6f7485adb181b8b778a2a3a3aad2f48f Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 13 May 2014 09:48:28 -0500 Subject: [PATCH 492/796] Same code just un-commented lines Uncommented lines to populate database in the tes --- .../hibernate/FooSortingPersistenceServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java index fbc041ec02f6..6b1f4318dead 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java @@ -40,8 +40,8 @@ public class FooSortingPersistenceServiceTest { @Before public void before() { - // final FooSortingPersistenceServiceData fooData = new FooSortingPersistenceServiceData(); - // fooData.createBars(); + final FooSortingPersistenceServiceData fooData = new FooSortingPersistenceServiceData(); + fooData.createBars(); configuration = new Configuration(); configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); configuration.setProperty("dialect", "org.hibernate.dialect.MySQLDialect"); From 393ca4303338b281236db13761a8d2f273f3107b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 13 May 2014 20:41:39 +0300 Subject: [PATCH 493/796] minor eclipse cleanup --- spring-hibernate4/.project | 6 ------ spring-jpa/.classpath | 6 +++++- spring-jpa/.project | 6 ------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/spring-hibernate4/.project b/spring-hibernate4/.project index 10df76aa23b9..b68719164667 100644 --- a/spring-hibernate4/.project +++ b/spring-hibernate4/.project @@ -30,11 +30,6 @@ - - org.hibernate.eclipse.console.hibernateBuilder - - - org.springframework.ide.eclipse.core.springnature @@ -44,6 +39,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.hibernate.eclipse.console.hibernateNature diff --git a/spring-jpa/.classpath b/spring-jpa/.classpath index d1d54e092ae5..6cb510b80c3f 100644 --- a/spring-jpa/.classpath +++ b/spring-jpa/.classpath @@ -22,12 +22,16 @@ - + + + + + diff --git a/spring-jpa/.project b/spring-jpa/.project index 5bb2baa2b950..235ae29ecfc3 100644 --- a/spring-jpa/.project +++ b/spring-jpa/.project @@ -30,11 +30,6 @@ - - org.hibernate.eclipse.console.hibernateBuilder - - - org.springframework.ide.eclipse.core.springnature @@ -44,6 +39,5 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature - org.hibernate.eclipse.console.hibernateNature From c970f3261ecf5eef7cca72543bc98711611119a8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 16 May 2014 22:40:53 +0300 Subject: [PATCH 494/796] formatting work --- .../org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java | 1 - .../jackson/test/JacksonCollectionDeserializationUnitTest.java | 1 - .../jackson/test/JacksonSerializationIgnoreUnitTest.java | 1 - jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java | 1 + .../org/baeldung/persistence/service/impl/ChildService.java | 1 - .../src/main/java/org/baeldung/persistence/model/Bar.java | 3 --- .../baeldung/persistence/service/FooServiceSortingTests.java | 1 - .../src/main/java/org/baeldung/servlet/WebAppOld.java | 1 - 8 files changed, 1 insertion(+), 9 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java index 4cf71f722129..b76a5740ecfb 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumSimple.java @@ -1,6 +1,5 @@ package org.baeldung.jackson.dtos.withEnum; - public enum TypeEnumSimple { TYPE1(1, "Type A"), TYPE2(2, "Type 2"); diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java index e2b3b35d72db..c3d8153546c1 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonCollectionDeserializationUnitTest.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.type.CollectionType; import com.google.common.collect.Lists; - public class JacksonCollectionDeserializationUnitTest { // tests - json to multiple entity diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java index e9608ad7f026..062bcc99dffa 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -28,7 +28,6 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; - public class JacksonSerializationIgnoreUnitTest { // tests - single entity to json diff --git a/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java b/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java index e7dfb560e242..ce4c83729abc 100644 --- a/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java +++ b/jackson/src/test/java/org/baeldung/jackson/try1/IEntity.java @@ -1,4 +1,5 @@ package org.baeldung.jackson.try1; + public interface IEntity { public int getId(); } \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java index 4b66f3d2bd6b..89597313eaf2 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java +++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java @@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - @Service public class ChildService extends AbstractService implements IChildService { diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java index 154d52988191..b602e5756243 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java @@ -17,7 +17,6 @@ public class Bar implements Serializable { private static final long serialVersionUID = 1L; - @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @@ -25,12 +24,10 @@ public class Bar implements Serializable { @Column(nullable = false) private String name; - @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) @OrderBy("name ASC") List fooList; - public Bar() { super(); } diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index baba4037f140..37ed1dc2f0f4 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -151,5 +151,4 @@ public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSorte } } - } diff --git a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java index 155597e888ba..a2589e465fdf 100644 --- a/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java +++ b/spring-mvc-no-xml/src/main/java/org/baeldung/servlet/WebAppOld.java @@ -1,6 +1,5 @@ package org.baeldung.servlet; - //public class WebApp implements WebApplicationInitializer { // // public WebApp() { From 158a138adb033f6680d3576fd36dbf9bfbf2acc6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 16 May 2014 22:44:26 +0300 Subject: [PATCH 495/796] minor maven upgrades --- core-java/pom.xml | 6 +++--- experiments/pom.xml | 4 ++-- guava/pom.xml | 4 ++-- httpclient/pom.xml | 4 ++-- jackson/pom.xml | 6 +++--- mockito/pom.xml | 4 ++-- rest-testing/pom.xml | 4 ++-- sandbox/pom.xml | 6 +++--- spring-all/pom.xml | 4 ++-- spring-exceptions/pom.xml | 4 ++-- spring-hibernate3/pom.xml | 4 ++-- spring-hibernate4/pom.xml | 4 ++-- spring-jpa/pom.xml | 4 ++-- spring-mvc-java/pom.xml | 4 ++-- spring-rest/pom.xml | 6 +++--- spring-security-basic-auth/pom.xml | 4 ++-- spring-security-mvc-custom/pom.xml | 4 ++-- spring-security-mvc-digest-auth/pom.xml | 4 ++-- spring-security-mvc-login/pom.xml | 4 ++-- spring-security-mvc-session/pom.xml | 4 ++-- spring-security-rest-basic-auth/pom.xml | 4 ++-- spring-security-rest-custom/pom.xml | 4 ++-- spring-security-rest-digest-auth/pom.xml | 4 ++-- spring-security-rest-full/pom.xml | 6 +++--- spring-security-rest/pom.xml | 4 ++-- 25 files changed, 55 insertions(+), 55 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index ab40590cb3d9..b80fe2e5796e 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -141,18 +141,18 @@ 5.1.30 - 2.3.2 + 2.3.3 1.7.6 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/experiments/pom.xml b/experiments/pom.xml index 606b1bfc49cc..1bfbff341ac1 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -267,11 +267,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/guava/pom.xml b/guava/pom.xml index b4abd03dc607..d11727afc813 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -106,11 +106,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index c5cce96fafcb..e4eb326560a7 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -142,11 +142,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/jackson/pom.xml b/jackson/pom.xml index 86ea96dceb48..365b2ca536b9 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -115,18 +115,18 @@ 5.1.30 - 2.3.2 + 2.3.3 1.7.6 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/mockito/pom.xml b/mockito/pom.xml index 5f20d113fec6..f247352eafc7 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -101,11 +101,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 4a866cea02a8..73e71c2912eb 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -141,14 +141,14 @@ 4.0.3.RELEASE - 2.3.2 + 2.3.3 1.7.6 1.1.1 - 5.0.3.Final + 5.1.1.Final 16.0.1 diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 2028a4b44295..a3c457101cd8 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -141,18 +141,18 @@ 5.1.29 - 2.3.2 + 2.3.3 1.7.6 1.1.1 - 5.0.3.Final + 5.1.1.Final 16.0.1 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index d7360668613d..5d0e8f4e3904 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -206,11 +206,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 9fa76afdf496..075c22815c04 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -219,11 +219,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 4b506d95e715..c2b7a9fa7eb9 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -188,11 +188,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index c6438f00761b..099f698c59bb 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -196,11 +196,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 8ec998095e77..c7bad22c976a 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -189,11 +189,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 456b4e095e6c..d8e4f77b209c 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -153,11 +153,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index f1d105d0490b..621f099efb10 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -211,14 +211,14 @@ - 2.3.2 + 2.3.3 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 4b4cec8f15a0..74f463c061e1 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -238,11 +238,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 48b9b8e4c1c8..182e5fda3aaf 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -243,11 +243,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 91aab8b220d5..e81fd4da9c89 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -238,11 +238,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 556e6eb086c6..9da13cde70b1 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -235,11 +235,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index c0a91edc7bd4..d4ee346179ac 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -243,11 +243,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 79965a553c43..e9b29a610363 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -303,11 +303,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index d5631e41212d..0e83c0bb73e0 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -263,11 +263,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index e97df2100ce9..9a812d773de6 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -291,11 +291,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 9c0e590ce462..8abfc26923b9 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -311,18 +311,18 @@ - 2.3.2 + 2.3.3 1.7.6 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index b6a9ebbbb41a..e775b1125cdc 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -226,11 +226,11 @@ 1.1.1 - 5.0.3.Final + 5.1.1.Final 17.0 - 3.3.1 + 3.3.2 1.3 From 7ac01d2ac1f0a383b0a7675fe492fb7820670506 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 16 May 2014 22:49:47 +0300 Subject: [PATCH 496/796] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 06656d650cb6..63ca8c79268a 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -10,6 +10,7 @@ - [REST API Discoverability and HATEOAS](http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/) - [ETags for REST with Spring](http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/) - [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) +- [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/2011/10/16/how-to-set-up-integration-testing-with-the-maven-cargo-plugin/) ### Build the Project From f61c34195c4fdb6cf8399e850c0a0b579b336fa6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 16 May 2014 22:52:40 +0300 Subject: [PATCH 497/796] new cargo based testign for this project --- spring-security-rest-full/pom.xml | 744 ++++++++++++++++-------------- 1 file changed, 401 insertions(+), 343 deletions(-) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 8abfc26923b9..7d1d345faf7d 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -1,345 +1,403 @@ - - 4.0.0 - org.baeldung - spring-security-rest-full - 0.1-SNAPSHOT - - spring-security-rest-full - war - - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework.data - spring-data-jpa - ${spring-data-jpa.version} - - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - org.javassist - javassist - 3.18.1-GA - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - com.jayway.restassured - rest-assured - 2.3.0 - test - - - commons-logging - commons-logging - - - - - - - - spring-security-rest-full - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 4.0.4.RELEASE - 3.2.3.RELEASE - - - 4.3.5.Final - 5.1.30 - 1.5.2.RELEASE - - - - 2.3.3 - - - 1.7.6 - 1.1.1 - - - 5.1.1.Final - - - 17.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.3 - - 2.3.1 - - - 3.1 - 2.4 - 2.17 - 1.4.8 - - + + 4.0.0 + org.baeldung + spring-security-rest-full + 0.1-SNAPSHOT + + spring-security-rest-full + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework.data + spring-data-jpa + ${spring-data-jpa.version} + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.javassist + javassist + 3.18.1-GA + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + com.jayway.restassured + rest-assured + 2.3.0 + test + + + commons-logging + commons-logging + + + + + + + + spring-security-rest-full + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + integration + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + none + + + **/*IntegrationTest.java + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + false + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + + + + + + + + 4.0.4.RELEASE + 3.2.3.RELEASE + + + 4.3.5.Final + 5.1.30 + 1.5.2.RELEASE + + + + 2.3.3 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 1.4.8 + + \ No newline at end of file From 5f3ca56a525abc1999e8c2e7e521e73f7e18ed8f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 17 May 2014 00:29:05 +0300 Subject: [PATCH 498/796] cargo and testing work --- spring-security-rest-full/pom.xml | 14 ++++- .../web/AbstractDiscoverabilityLiveTest.java | 2 +- .../FooServicePersistenceIntegrationTest.java | 54 +++++++++++++++++++ .../org/baeldung/test/JacksonMarshaller.java | 2 - .../baeldung/test/TestMarshallerFactory.java | 48 +++++++++++++++++ .../org/baeldung/test/XStreamMarshaller.java | 49 +++++++++++++++++ .../web/FooDiscoverabilityLiveTest.java | 2 + .../java/org/baeldung/web/FooLiveTest.java | 2 + .../resources/persistence-mysql.properties | 10 ++++ 9 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/test/TestMarshallerFactory.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/test/XStreamMarshaller.java create mode 100644 spring-security-rest-full/src/test/resources/persistence-mysql.properties diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 7d1d345faf7d..5dca63280734 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -150,6 +150,12 @@ ${jackson.version} + + com.thoughtworks.xstream + xstream + 1.4.7 + + @@ -291,7 +297,7 @@ - 8082 + 8080 @@ -323,10 +329,16 @@ **/*IntegrationTest.java + **/*LiveTest.java
+ + + json + +
org.codehaus.cargo diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java index 4a7c19b6ce59..ca3f56416d45 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java @@ -66,7 +66,7 @@ public void whenResourceIsRetrieved_thenUriToGetAllResourcesIsDiscoverable() { final String uriToAllResources = HTTPLinkHeaderUtil.extractURIByRel(getResponse.getHeader("Link"), "collection"); final Response getAllResponse = givenAuth().get(uriToAllResources); - assertThat(getAllResponse.getStatusCode(), is(200)); + assertThat(getAllResponse.getStatusCode(), is(403)); } // template method diff --git a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..fd035e5615cc --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,54 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.persistence.model.Foo; +import org.baeldung.spring.PersistenceConfig; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + + @Autowired + private IFooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java index 99deafaee499..392e1011939f 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java @@ -7,7 +7,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -15,7 +14,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; -@Component public final class JacksonMarshaller implements IMarshaller { private final Logger logger = LoggerFactory.getLogger(JacksonMarshaller.class); diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/TestMarshallerFactory.java b/spring-security-rest-full/src/test/java/org/baeldung/test/TestMarshallerFactory.java new file mode 100644 index 000000000000..11273276cdf2 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/TestMarshallerFactory.java @@ -0,0 +1,48 @@ +package org.baeldung.test; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +@Profile("test") +public class TestMarshallerFactory implements FactoryBean { + + @Autowired + private Environment env; + + public TestMarshallerFactory() { + super(); + } + + // API + + @Override + public IMarshaller getObject() { + final String testMime = env.getProperty("test.mime"); + if (testMime != null) { + switch (testMime) { + case "json": + return new JacksonMarshaller(); + case "xml": + return new XStreamMarshaller(); + default: + throw new IllegalStateException(); + } + } + + return new JacksonMarshaller(); + } + + @Override + public Class getObjectType() { + return IMarshaller.class; + } + + @Override + public boolean isSingleton() { + return true; + } +} \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/XStreamMarshaller.java b/spring-security-rest-full/src/test/java/org/baeldung/test/XStreamMarshaller.java new file mode 100644 index 000000000000..d7cf084e34dd --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/XStreamMarshaller.java @@ -0,0 +1,49 @@ +package org.baeldung.test; + +import java.util.List; + +import org.baeldung.persistence.model.Foo; +import org.springframework.http.MediaType; + +import com.google.common.base.Preconditions; +import com.thoughtworks.xstream.XStream; + +public final class XStreamMarshaller implements IMarshaller { + + private XStream xstream; + + public XStreamMarshaller() { + super(); + + xstream = new XStream(); + xstream.autodetectAnnotations(true); + xstream.processAnnotations(Foo.class); + } + + // API + + @Override + public final String encode(final T resource) { + Preconditions.checkNotNull(resource); + return xstream.toXML(resource); + } + + @SuppressWarnings("unchecked") + @Override + public final T decode(final String resourceAsString, final Class clazz) { + Preconditions.checkNotNull(resourceAsString); + return (T) xstream.fromXML(resourceAsString); + } + + @SuppressWarnings("unchecked") + @Override + public List decodeList(final String resourcesAsString, final Class clazz) { + return this.decode(resourcesAsString, List.class); + } + + @Override + public final String getMime() { + return MediaType.APPLICATION_XML.toString(); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java index 28dfcd372ce3..c0e1f9d04da4 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooDiscoverabilityLiveTest.java @@ -6,12 +6,14 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.spring.ConfigTest; import org.junit.runner.RunWith; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class) +@ActiveProfiles("test") public class FooDiscoverabilityLiveTest extends AbstractDiscoverabilityLiveTest { public FooDiscoverabilityLiveTest() { diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java index 9024ca4f963c..5a4f472fe33b 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/FooLiveTest.java @@ -6,12 +6,14 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.spring.ConfigTest; import org.junit.runner.RunWith; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class) +@ActiveProfiles("test") public class FooLiveTest extends AbstractBasicLiveTest { public FooLiveTest() { diff --git a/spring-security-rest-full/src/test/resources/persistence-mysql.properties b/spring-security-rest-full/src/test/resources/persistence-mysql.properties new file mode 100644 index 000000000000..8263b0d9accd --- /dev/null +++ b/spring-security-rest-full/src/test/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop From b717b7cc4edd9cdabbc84f1329223926fd06a17b Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 20 May 2014 12:40:31 -0500 Subject: [PATCH 499/796] HttpMultipartTest Only try uncommented test --- httpclient/.classpath | 6 + .../httpclient/HttpClientMultipartTest.java | 169 ++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java diff --git a/httpclient/.classpath b/httpclient/.classpath index 0720e4851bd7..5e95764558fb 100644 --- a/httpclient/.classpath +++ b/httpclient/.classpath @@ -32,5 +32,11 @@ + + + + + + diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java new file mode 100644 index 000000000000..4248a6818b39 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -0,0 +1,169 @@ +package org.baeldung.httpclient; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.fluent.Request; +import org.apache.http.client.fluent.Response; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.HttpClientBuilder; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class HttpClientMultipartTest { + + private static final String SERVER = "http://cgi-lib.berkeley.edu/ex/fup.cgi"; + private static final String SERVER2 = "http://posttestserver.com/post.php"; + private static final String SERVER3 = "http://postcatcher.in/catchers/53765b0349c306020000077b"; + private static final String SERVER4 = "http://echo.200please.com"; + private static final String SERVER5 = "http://greensuisse.zzl.org/product/dump/dump.php"; + private static final String SERVER6 = "http://www.newburghschools.org/testfolder/dump.php"; + private static HttpClient client; + private static HttpPost post; + private static String textFileName; + private static String imageFileName; + private static String zipFileName; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + client = HttpClientBuilder.create().build(); + post = new HttpPost(SERVER2 /*"fup.cgi"*/); + textFileName = ".\temp.txt"; + imageFileName = "image.jpg"; + zipFileName = "zipFile.zip"; + + } + + @Before + public void setUp() throws Exception { + + } + + /* @Test + public final void whenUploadWithAddPart_thenNoExceptions() throws IOException { + + + final File file = new File(textFileName); + final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); + final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); + final StringBody stringBody2 = new StringBody("This is message 2", ContentType.MULTIPART_FORM_DATA); + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("submitted", fileBody); + builder.addPart("note", stringBody1); + builder.addPart("note2", stringBody2); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + Header[] headers = response.getAllHeaders(); + + for (Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + } */ + /*@Test + public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + + final File file = new File(textFileName); + String message = "This is a multipart post"; + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + Header[] headers = response.getAllHeaders(); + + for (Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + + }*/ + + /* @Test + public final void whenUploadWithAddBinaryBody_NoType_andAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + + final File file = new File(imageFileName); + final String message = "This is a multipart post"; + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); + //builder.addBinaryBody("upfile", fileBin); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + Header[] headers = response.getAllHeaders(); + + for (Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + + }*/ + + /* @Test + public final void whenUploadWithAddBinaryBody_InputStream_andTextBody_ThenNoException() throws ClientProtocolException, IOException{ + final InputStream inputStream = new FileInputStream(zipFileName); + final String message = "This is a multipart post"; + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + // builder.addBinaryBody("submitted", inputStream, ContentType.create("application/zip"), "zipFileName"); + builder.addBinaryBody("upfile", inputStream, ContentType.create("application/zip"), "zipFileName"); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + + System.out.println(getContent(response)); + Header[] headers = response.getAllHeaders(); + + for (Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + + + }*/ + + // BUG + @Test + public final void whenFluentRequestWithBody_ThenNoException() throws IOException{ + + final String fileName = ".\temp.txt"; + final File fileBin = new File(fileName); + final String message = "This is a multipart post"; + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addBinaryBody("upfile", fileBin, ContentType.DEFAULT_BINARY, fileName); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + final Response response = Request.Post(SERVER) + .body(entity).execute(); + } + + public static String getContent(final HttpResponse response) throws IOException { + + final BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); + String body = ""; + String content = ""; + + while ((body = rd.readLine()) != null) { + content += body + "\n"; + } + return content.trim(); + } + + +} From f4104354b4c1493eb52e723452a75c66b9adf036 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 22 May 2014 20:57:29 +0300 Subject: [PATCH 500/796] cleanup work for httpclient --- httpclient/.classpath | 6 - httpclient/pom.xml | 355 +++++++++--------- httpclient/src/main/resources/temp.txt | 1 + .../httpclient/HttpClientMultipartTest.java | 192 +++++----- 4 files changed, 281 insertions(+), 273 deletions(-) create mode 100644 httpclient/src/main/resources/temp.txt diff --git a/httpclient/.classpath b/httpclient/.classpath index 5e95764558fb..0720e4851bd7 100644 --- a/httpclient/.classpath +++ b/httpclient/.classpath @@ -32,11 +32,5 @@ - - - - - - diff --git a/httpclient/pom.xml b/httpclient/pom.xml index e4eb326560a7..58d052af33d0 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -1,170 +1,189 @@ - - 4.0.0 - org.baeldung - httpclient - 0.1-SNAPSHOT - - httpclient - - - - - - - com.google.guava - guava - ${guava.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - httpclient - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - 4.0.4.RELEASE - 3.2.3.RELEASE - - - 4.3.5.Final - 5.1.30 - - - 1.7.6 - 1.1.1 - - - 5.1.1.Final - - - 17.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.3 - - 2.3.1 - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.8 - - + + 4.0.0 + org.baeldung + httpclient + 0.1-SNAPSHOT + + httpclient + + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + + org.apache.httpcomponents + fluent-hc + 4.3.3 + + + + org.apache.httpcomponents + httpmime + 4.3.3 + + + + commons-codec + commons-codec + 1.9 + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + httpclient + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.4.RELEASE + 3.2.3.RELEASE + + + 4.3.5.Final + 5.1.30 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.8 + + \ No newline at end of file diff --git a/httpclient/src/main/resources/temp.txt b/httpclient/src/main/resources/temp.txt new file mode 100644 index 000000000000..f0eec86f6149 --- /dev/null +++ b/httpclient/src/main/resources/temp.txt @@ -0,0 +1 @@ +some content \ No newline at end of file diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 4248a6818b39..ef11c76187b3 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -2,11 +2,15 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; @@ -14,9 +18,11 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; public class HttpClientMultipartTest { @@ -40,107 +46,98 @@ public static void setUpBeforeClass() throws Exception { textFileName = ".\temp.txt"; imageFileName = "image.jpg"; zipFileName = "zipFile.zip"; + } + + @Test + @Ignore + public final void whenUploadWithAddPart_thenNoExceptions() throws IOException { + final File file = new File(textFileName); + final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); + final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); + final StringBody stringBody2 = new StringBody("This is message 2", ContentType.MULTIPART_FORM_DATA); + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("submitted", fileBody); + builder.addPart("note", stringBody1); + builder.addPart("note2", stringBody2); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + final Header[] headers = response.getAllHeaders(); + + for (final Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + } + @Test + @Ignore + public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + final File file = new File(textFileName); + final String message = "This is a multipart post"; + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + final Header[] headers = response.getAllHeaders(); + + for (final Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } } - @Before - public void setUp() throws Exception { + @Test + @Ignore + public final void whenUploadWithAddBinaryBody_NoType_andAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + final File file = new File(imageFileName); + final String message = "This is a multipart post"; + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); + // builder.addBinaryBody("upfile", fileBin); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + System.out.println(getContent(response)); + final Header[] headers = response.getAllHeaders(); + for (final Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } } - /* @Test - public final void whenUploadWithAddPart_thenNoExceptions() throws IOException { - - - final File file = new File(textFileName); - final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); - final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); - final StringBody stringBody2 = new StringBody("This is message 2", ContentType.MULTIPART_FORM_DATA); - final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addPart("submitted", fileBody); - builder.addPart("note", stringBody1); - builder.addPart("note2", stringBody2); - final HttpEntity entity = builder.build(); - post.setEntity(entity); - final HttpResponse response = client.execute(post); - System.out.println(getContent(response)); - Header[] headers = response.getAllHeaders(); - - for (Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - } */ - /*@Test - public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { - - final File file = new File(textFileName); - String message = "This is a multipart post"; - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); - builder.addTextBody("note", message, ContentType.TEXT_PLAIN); - final HttpEntity entity = builder.build(); - post.setEntity(entity); - HttpResponse response = client.execute(post); - System.out.println(getContent(response)); - Header[] headers = response.getAllHeaders(); - - for (Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - - }*/ - - /* @Test - public final void whenUploadWithAddBinaryBody_NoType_andAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { - - final File file = new File(imageFileName); - final String message = "This is a multipart post"; - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addBinaryBody("submitted", file, ContentType.DEFAULT_BINARY, textFileName); - //builder.addBinaryBody("upfile", fileBin); - builder.addTextBody("note", message, ContentType.TEXT_PLAIN); - final HttpEntity entity = builder.build(); - post.setEntity(entity); - final HttpResponse response = client.execute(post); - System.out.println(getContent(response)); - Header[] headers = response.getAllHeaders(); - - for (Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - - }*/ - - /* @Test - public final void whenUploadWithAddBinaryBody_InputStream_andTextBody_ThenNoException() throws ClientProtocolException, IOException{ - final InputStream inputStream = new FileInputStream(zipFileName); - final String message = "This is a multipart post"; - final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - // builder.addBinaryBody("submitted", inputStream, ContentType.create("application/zip"), "zipFileName"); - builder.addBinaryBody("upfile", inputStream, ContentType.create("application/zip"), "zipFileName"); - builder.addTextBody("note", message, ContentType.TEXT_PLAIN); - final HttpEntity entity = builder.build(); - post.setEntity(entity); - final HttpResponse response = client.execute(post); - - System.out.println(getContent(response)); - Header[] headers = response.getAllHeaders(); - - for (Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - - - }*/ + @Test + @Ignore + public final void whenUploadWithAddBinaryBody_InputStream_andTextBody_ThenNoException() throws ClientProtocolException, IOException { + final InputStream inputStream = new FileInputStream(zipFileName); + final String message = "This is a multipart post"; + final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + // builder.addBinaryBody("submitted", inputStream, ContentType.create("application/zip"), "zipFileName"); + builder.addBinaryBody("upfile", inputStream, ContentType.create("application/zip"), "zipFileName"); + builder.addTextBody("note", message, ContentType.TEXT_PLAIN); + final HttpEntity entity = builder.build(); + post.setEntity(entity); + final HttpResponse response = client.execute(post); + + System.out.println(getContent(response)); + final Header[] headers = response.getAllHeaders(); + + for (final Header thisHeader : headers) { + System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); + } + } // BUG - @Test - public final void whenFluentRequestWithBody_ThenNoException() throws IOException{ - + + @Test + public final void whenFluentRequestWithBody_ThenNoException() throws IOException { final String fileName = ".\temp.txt"; final File fileBin = new File(fileName); final String message = "This is a multipart post"; @@ -149,12 +146,10 @@ public final void whenFluentRequestWithBody_ThenNoException() throws IOException builder.addBinaryBody("upfile", fileBin, ContentType.DEFAULT_BINARY, fileName); builder.addTextBody("note", message, ContentType.TEXT_PLAIN); final HttpEntity entity = builder.build(); - final Response response = Request.Post(SERVER) - .body(entity).execute(); + final Response response = Request.Post(SERVER).body(entity).execute(); } public static String getContent(final HttpResponse response) throws IOException { - final BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String body = ""; String content = ""; @@ -164,6 +159,5 @@ public static String getContent(final HttpResponse response) throws IOException } return content.trim(); } - - + } From d1d71b62ffe439c5274705548b57b21f5fadf181 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Thu, 22 May 2014 18:59:09 -0500 Subject: [PATCH 501/796] HttpClient Multi Part Form Upload Tests --- httpclient/image.jpg | Bin 0 -> 4329 bytes .../httpclient/HttpClientMultipartTest.java | 165 +++++++++++------- httpclient/temp.txt | 1 + httpclient/zipFile.zip | Bin 0 -> 282 bytes 4 files changed, 102 insertions(+), 64 deletions(-) create mode 100644 httpclient/image.jpg create mode 100644 httpclient/temp.txt create mode 100644 httpclient/zipFile.zip diff --git a/httpclient/image.jpg b/httpclient/image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..715665678595c9c72fd7eefac1808ca879bd0acf GIT binary patch literal 4329 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 Date: Fri, 23 May 2014 17:09:25 +0300 Subject: [PATCH 502/796] intermediary json work --- .../dtos/withEnum/TypeEnumWithValue.java | 37 +++++++++++++++++++ .../JacksonSerializationEnumsUnitTest.java | 36 +++++++++++++----- .../baeldung/jackson/test/UnitTestSuite.java | 20 ++++++++++ 3 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java new file mode 100644 index 000000000000..2754fe96008d --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java @@ -0,0 +1,37 @@ +package org.baeldung.jackson.dtos.withEnum; + +import com.fasterxml.jackson.annotation.JsonValue; + + +public enum TypeEnumWithValue { + TYPE1(1, "Type A"), TYPE2(2, "Type 2"); + + private Integer id; + + private String name; + + private TypeEnumWithValue(final Integer id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + @JsonValue + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java index bdf8c888fbae..316da46e91d8 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java @@ -10,6 +10,8 @@ import org.baeldung.jackson.dtos.withEnum.TypeEnum; import org.baeldung.jackson.dtos.withEnum.TypeEnumSimple; import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; +import org.baeldung.jackson.dtos.withEnum.TypeEnumWithValue; +import org.junit.Ignore; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; @@ -17,7 +19,7 @@ public class JacksonSerializationEnumsUnitTest { - // tests - enums + // tests - simple enum @Test public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseException, IOException { @@ -28,28 +30,33 @@ public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseExcep assertThat(dtoAsString, containsString("TYPE1")); } + // tests - enum with main value + @Test - public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException { + @Ignore("https://github.com/FasterXML/jackson-databind/issues/47") + public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1.name()); - + final String dtoAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1.name()); System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + + assertThat(dtoAsString, containsString("Type A")); } + // tests - enum + @Test - public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); + final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1.name()); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); } @Test - public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); @@ -64,4 +71,15 @@ public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseExce assertThat(json, containsString("\"name\":\"Type A\"")); } + // tests - enum with custom serializer + + @Test + public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); + + System.out.println(dtoAsString); + assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + } + } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java b/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java new file mode 100644 index 000000000000..2eb24928d6fe --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java @@ -0,0 +1,20 @@ +package org.baeldung.jackson.test; + +import org.baeldung.jackson.sandbox.JacksonPrettyPrintUnitTest; +import org.baeldung.jackson.sandbox.SandboxTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({// @formatter:off + JacksonCollectionDeserializationUnitTest.class + ,JacksonSerializationEnumsUnitTest.class + ,JacksonDeserializationUnitTest.class + ,JacksonDeserializationUnitTest.class + ,JacksonPrettyPrintUnitTest.class + ,JacksonSerializationIgnoreUnitTest.class + ,JacksonSerializationUnitTest.class + ,SandboxTest.class +}) // @formatter:on +public class UnitTestSuite { +} \ No newline at end of file From 4bb514dc0969917f6d9bf496b49d56ed83db6bba Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 23 May 2014 17:12:56 +0300 Subject: [PATCH 503/796] using @JsonValue with enums and jackson --- .../jackson/dtos/withEnum/TypeEnumWithValue.java | 1 - .../jackson/test/JacksonSerializationEnumsUnitTest.java | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java index 2754fe96008d..cf104df473b8 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/withEnum/TypeEnumWithValue.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonValue; - public enum TypeEnumWithValue { TYPE1(1, "Type A"), TYPE2(2, "Type 2"); diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java index 316da46e91d8..3003045063d7 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java @@ -11,7 +11,6 @@ import org.baeldung.jackson.dtos.withEnum.TypeEnumSimple; import org.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer; import org.baeldung.jackson.dtos.withEnum.TypeEnumWithValue; -import org.junit.Ignore; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; @@ -24,7 +23,7 @@ public class JacksonSerializationEnumsUnitTest { @Test public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1.name()); + final String dtoAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("TYPE1")); @@ -33,10 +32,10 @@ public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseExcep // tests - enum with main value @Test - @Ignore("https://github.com/FasterXML/jackson-databind/issues/47") + // @Ignore("https://github.com/FasterXML/jackson-databind/issues/47") public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1.name()); + final String dtoAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("Type A")); @@ -47,7 +46,7 @@ public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseEx @Test public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1.name()); + final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); System.out.println(dtoAsString); assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); From 2030aeb65b98c3ece84baac182114a198671fdc6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 23 May 2014 17:28:44 +0300 Subject: [PATCH 504/796] minor jackson cleanup --- .../JacksonSerializationEnumsUnitTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java index 3003045063d7..d64834078afe 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java @@ -1,6 +1,7 @@ package org.baeldung.jackson.test; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.io.IOException; @@ -23,22 +24,21 @@ public class JacksonSerializationEnumsUnitTest { @Test public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1); - System.out.println(dtoAsString); + final String enumAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1); + System.out.println(enumAsString); - assertThat(dtoAsString, containsString("TYPE1")); + assertThat(enumAsString, containsString("TYPE1")); } // tests - enum with main value @Test - // @Ignore("https://github.com/FasterXML/jackson-databind/issues/47") public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1); - System.out.println(dtoAsString); + final String enumAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1); + System.out.println(enumAsString); - assertThat(dtoAsString, containsString("Type A")); + assertThat(enumAsString, is("\"Type A\"")); } // tests - enum @@ -46,19 +46,19 @@ public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseEx @Test public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(TypeEnum.TYPE1); + final String enumAsString = mapper.writeValueAsString(TypeEnum.TYPE1); - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + System.out.println(enumAsString); + assertThat(enumAsString, containsString("\"name\":\"Type A\"")); } @Test public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); + final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1)); - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + System.out.println(enumAsString); + assertThat(enumAsString, containsString("\"name\":\"Type A\"")); } @Test @@ -75,10 +75,10 @@ public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseExce @Test public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException { final ObjectMapper mapper = new ObjectMapper(); - final String dtoAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); + final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1)); - System.out.println(dtoAsString); - assertThat(dtoAsString, containsString("\"name\":\"Type A\"")); + System.out.println(enumAsString); + assertThat(enumAsString, containsString("\"name\":\"Type A\"")); } } From db6c43e65f71f365fe83b35b6f8b741e83550632 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 13:26:51 -0500 Subject: [PATCH 505/796] Last Changes Added a utility method to get post Headers --- .../httpclient/HttpClientMultipartTest.java | 79 +++++++------------ 1 file changed, 30 insertions(+), 49 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 106051d729df..dfd108fc0312 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.io.BufferedReader; import java.io.File; @@ -10,7 +11,6 @@ import java.io.InputStream; import java.io.InputStreamReader; -import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; @@ -74,8 +74,7 @@ public final void after() throws IllegalStateException, IOException { } @Test - public final void whenUploadWithAddPart_thenNoExceptions() throws IOException { - + public final void givenFileandMultipleTextParts_whenUploadWithAddPart_thenNoExceptions() throws IOException { final File file = new File(textFileName); final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); @@ -89,21 +88,17 @@ public final void whenUploadWithAddPart_thenNoExceptions() throws IOException { post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine().getStatusCode(); + final String responseString = getContent(); + final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); - - System.out.println(getContent()); - - final Header[] headers = response.getAllHeaders(); - assertThat(headers.length, equalTo(5)); - - for (final Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } + assertTrue(responseString.contains("Content-Type: multipart/form-data;")); + assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;")); + System.out.println(responseString); + System.out.println("POST Content Type: " + contentTypeInHeader); } @Test public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { - final File file = new File(textFileName); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -114,22 +109,17 @@ public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() thr post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine().getStatusCode(); + final String responseString = getContent(); + final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); - - System.out.println(getContent()); - - final Header[] headers = response.getAllHeaders(); - assertThat(headers.length, equalTo(5)); - - for (final Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - + assertTrue(responseString.contains("Content-Type: multipart/form-data;")); + assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;")); + System.out.println(responseString); + System.out.println("POST Content Type: " + contentTypeInHeader); } @Test public final void whenUploadWithAddBinaryBody_withInputStreamAndFile_andTextBody_ThenNoException() throws ClientProtocolException, IOException { - final InputStream inputStream = new FileInputStream(zipFileName); final File file = new File(imageFileName); final String message = "This is a multipart post"; @@ -142,24 +132,18 @@ public final void whenUploadWithAddBinaryBody_withInputStreamAndFile_andTextBody post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine().getStatusCode(); + final String responseString = getContent(); + final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); - - System.out.println(getContent()); - - final Header[] headers = response.getAllHeaders(); - assertThat(headers.length, equalTo(5)); - - for (final Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - + assertTrue(responseString.contains("Content-Type: multipart/form-data;")); + assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;")); + System.out.println(responseString); + System.out.println("POST Content Type: " + contentTypeInHeader); inputStream.close(); - } @Test public final void whenUploadWithAddBinaryBody_withCharArray_andTextBody_ThenNoException() throws ClientProtocolException, IOException { - final String message = "This is a multipart post"; final byte[] bytes = "binary code".getBytes(); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -170,31 +154,28 @@ public final void whenUploadWithAddBinaryBody_withCharArray_andTextBody_ThenNoEx post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine().getStatusCode(); + final String responseString = getContent(); + final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); - - System.out.println(getContent()); - - final Header[] headers = response.getAllHeaders(); - assertThat(headers.length, equalTo(5)); - - for (final Header thisHeader : headers) { - System.out.println(thisHeader.getName() + ":" + thisHeader.getValue()); - } - + assertTrue(responseString.contains("Content-Type: multipart/form-data;")); + assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;")); + System.out.println(responseString); + System.out.println("POST Content Type: " + contentTypeInHeader); } public String getContent() throws IOException { - rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String body = ""; String content = ""; - while ((body = rd.readLine()) != null) { content += body + "\n"; } - + rd.close(); return content.trim(); + } + public String getContentTypeHeader() throws IOException { + return post.getEntity().getContentType().toString(); } } From 1c56b98059d7b7e3fc825f9655b9a4aa21309254 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 13:32:53 -0500 Subject: [PATCH 506/796] Final Commit --- .../java/org/baeldung/httpclient/HttpClientMultipartTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index dfd108fc0312..f8b7bd2b551c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -170,7 +170,6 @@ public String getContent() throws IOException { while ((body = rd.readLine()) != null) { content += body + "\n"; } - rd.close(); return content.trim(); } From 4f9dcf0a8e15abdea35866ff1d02cfb2fb35a8d6 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 14:15:50 -0500 Subject: [PATCH 507/796] Changed Test Method Names --- .../org/baeldung/httpclient/HttpClientMultipartTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index f8b7bd2b551c..0f40f2236f22 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -74,7 +74,7 @@ public final void after() throws IllegalStateException, IOException { } @Test - public final void givenFileandMultipleTextParts_whenUploadWithAddPart_thenNoExceptions() throws IOException { + public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException { final File file = new File(textFileName); final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); @@ -98,7 +98,7 @@ public final void givenFileandMultipleTextParts_whenUploadWithAddPart_thenNoExce } @Test - public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { final File file = new File(textFileName); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -119,7 +119,7 @@ public final void whenUploadWithAddBinaryBodyandAddTextBody_ThenNoExeption() thr } @Test - public final void whenUploadWithAddBinaryBody_withInputStreamAndFile_andTextBody_ThenNoException() throws ClientProtocolException, IOException { + public final void givenFileandInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { final InputStream inputStream = new FileInputStream(zipFileName); final File file = new File(imageFileName); final String message = "This is a multipart post"; @@ -143,7 +143,7 @@ public final void whenUploadWithAddBinaryBody_withInputStreamAndFile_andTextBody } @Test - public final void whenUploadWithAddBinaryBody_withCharArray_andTextBody_ThenNoException() throws ClientProtocolException, IOException { + public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { final String message = "This is a multipart post"; final byte[] bytes = "binary code".getBytes(); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); From 83ccbf07c034f8944807b8e71e430dd11ee98231 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 23 May 2014 23:38:04 +0300 Subject: [PATCH 508/796] httpclient cleanup work --- .../httpclient/HttpClientMultipartTest.java | 16 ++++++++++------ .../{ => src/test/resources/uploads}/image.jpg | Bin .../test/resources/{ => uploads}/sandbox.txt | 0 .../{ => src/test/resources/uploads}/temp.txt | 0 .../test/resources/uploads}/zipFile.zip | Bin 5 files changed, 10 insertions(+), 6 deletions(-) rename httpclient/{ => src/test/resources/uploads}/image.jpg (100%) rename httpclient/src/test/resources/{ => uploads}/sandbox.txt (100%) rename httpclient/{ => src/test/resources/uploads}/temp.txt (100%) rename httpclient/{ => src/test/resources/uploads}/zipFile.zip (100%) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 0f40f2236f22..4e183c0150a0 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URL; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; @@ -39,7 +40,7 @@ public class HttpClientMultipartTest { private CloseableHttpResponse response; @Before - public final void Before() { + public final void before() { client = HttpClientBuilder.create().build(); post = new HttpPost(SERVER); textFileName = "temp.txt"; @@ -53,13 +54,11 @@ public final void after() throws IllegalStateException, IOException { try { client.close(); } catch (final IOException e1) { - e1.printStackTrace(); } try { rd.close(); } catch (final IOException e) { - e.printStackTrace(); } try { @@ -73,9 +72,12 @@ public final void after() throws IllegalStateException, IOException { } } + // tests + @Test public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException { - final File file = new File(textFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + textFileName); + final File file = new File(url.getPath()); final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); final StringBody stringBody2 = new StringBody("This is message 2", ContentType.MULTIPART_FORM_DATA); @@ -163,7 +165,9 @@ public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBod System.out.println("POST Content Type: " + contentTypeInHeader); } - public String getContent() throws IOException { + // UTIL + + final String getContent() throws IOException { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String body = ""; String content = ""; @@ -173,7 +177,7 @@ public String getContent() throws IOException { return content.trim(); } - public String getContentTypeHeader() throws IOException { + final String getContentTypeHeader() throws IOException { return post.getEntity().getContentType().toString(); } diff --git a/httpclient/image.jpg b/httpclient/src/test/resources/uploads/image.jpg similarity index 100% rename from httpclient/image.jpg rename to httpclient/src/test/resources/uploads/image.jpg diff --git a/httpclient/src/test/resources/sandbox.txt b/httpclient/src/test/resources/uploads/sandbox.txt similarity index 100% rename from httpclient/src/test/resources/sandbox.txt rename to httpclient/src/test/resources/uploads/sandbox.txt diff --git a/httpclient/temp.txt b/httpclient/src/test/resources/uploads/temp.txt similarity index 100% rename from httpclient/temp.txt rename to httpclient/src/test/resources/uploads/temp.txt diff --git a/httpclient/zipFile.zip b/httpclient/src/test/resources/uploads/zipFile.zip similarity index 100% rename from httpclient/zipFile.zip rename to httpclient/src/test/resources/uploads/zipFile.zip From 4bd671cdb7c134cab13785ee6bf4bc5530348a69 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 17:28:26 -0500 Subject: [PATCH 509/796] Last Changes --- .../httpclient/HttpClientMultipartTest.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 4e183c0150a0..27a194881ef0 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -31,21 +31,20 @@ public class HttpClientMultipartTest { private static final String SERVER = "http://echo.200please.com"; + private static final String textFileName = "temp.txt"; + private static final String imageFileName = "image.jpg"; + private static final String zipFileName = "zipFile.zip"; private CloseableHttpClient client; private HttpPost post; - private String textFileName; - private String imageFileName; - private String zipFileName; private BufferedReader rd; private CloseableHttpResponse response; + private java.util.logging.Logger log; @Before public final void before() { client = HttpClientBuilder.create().build(); post = new HttpPost(SERVER); - textFileName = "temp.txt"; - imageFileName = "image.jpg"; - zipFileName = "zipFile.zip"; + log = java.util.logging.Logger.getAnonymousLogger(); } @After @@ -54,12 +53,12 @@ public final void after() throws IllegalStateException, IOException { try { client.close(); } catch (final IOException e1) { - e1.printStackTrace(); + log.throwing("HttpClientMultipartTest", "after()", e1); } try { rd.close(); } catch (final IOException e) { - e.printStackTrace(); + log.throwing("HttpClientMultipartTest", "after()", e); } try { final HttpEntity entity = response.getEntity(); @@ -101,7 +100,8 @@ public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExce @Test public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { - final File file = new File(textFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + textFileName); + final File file = new File(url.getPath()); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); @@ -122,8 +122,10 @@ public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody @Test public final void givenFileandInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { - final InputStream inputStream = new FileInputStream(zipFileName); - final File file = new File(imageFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + zipFileName); + final URL url2 = Thread.currentThread().getContextClassLoader().getResource("uploads/" + imageFileName); + final InputStream inputStream = new FileInputStream(url.getPath()); + final File file = new File(url2.getPath()); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); From 0e09022a00e6d687b124fc47747f8ce71cf724f2 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 17:46:27 -0500 Subject: [PATCH 510/796] With Better Logger --- .../baeldung/httpclient/HttpClientMultipartTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 27a194881ef0..ccad8675db25 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -11,6 +11,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; @@ -34,6 +36,7 @@ public class HttpClientMultipartTest { private static final String textFileName = "temp.txt"; private static final String imageFileName = "image.jpg"; private static final String zipFileName = "zipFile.zip"; + private static final Logger LOGGER = Logger.getLogger("org.baeldung.httpclient.HttpClientMultipartTest"); private CloseableHttpClient client; private HttpPost post; private BufferedReader rd; @@ -44,7 +47,6 @@ public class HttpClientMultipartTest { public final void before() { client = HttpClientBuilder.create().build(); post = new HttpPost(SERVER); - log = java.util.logging.Logger.getAnonymousLogger(); } @After @@ -53,12 +55,14 @@ public final void after() throws IllegalStateException, IOException { try { client.close(); } catch (final IOException e1) { - log.throwing("HttpClientMultipartTest", "after()", e1); + LOGGER.log(Level.SEVERE, e1.getMessage(), e1); + throw e1; } try { rd.close(); } catch (final IOException e) { - log.throwing("HttpClientMultipartTest", "after()", e); + LOGGER.log(Level.SEVERE, e.getMessage(), e); + throw e; } try { final HttpEntity entity = response.getEntity(); From 9c444da4e01b8e19f8a8f3b4794ef8ab79afc676 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 23 May 2014 17:47:41 -0500 Subject: [PATCH 511/796] Refined Logger --- .../java/org/baeldung/httpclient/HttpClientMultipartTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index ccad8675db25..9e5d219b3b03 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -41,7 +41,6 @@ public class HttpClientMultipartTest { private HttpPost post; private BufferedReader rd; private CloseableHttpResponse response; - private java.util.logging.Logger log; @Before public final void before() { From 43cc23d2d0edf23c9ffca4f9a12fe72ac42c1165 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 24 May 2014 11:24:44 +0300 Subject: [PATCH 512/796] maven spring upgrades --- core-java/pom.xml | 4 ++-- experiments/pom.xml | 4 ++-- guava/pom.xml | 4 ++-- httpclient/pom.xml | 4 ++-- jackson/pom.xml | 4 ++-- mockito/pom.xml | 4 ++-- sandbox/pom.xml | 2 +- spring-all/pom.xml | 4 ++-- spring-exceptions/pom.xml | 4 ++-- spring-hibernate3/pom.xml | 4 ++-- spring-hibernate4/pom.xml | 4 ++-- spring-jpa/pom.xml | 4 ++-- spring-mvc-java/pom.xml | 4 ++-- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 4 ++-- spring-security-basic-auth/pom.xml | 4 ++-- spring-security-mvc-custom/pom.xml | 4 ++-- spring-security-mvc-digest-auth/pom.xml | 4 ++-- spring-security-mvc-login/pom.xml | 4 ++-- spring-security-mvc-session/pom.xml | 4 ++-- spring-security-rest-basic-auth/pom.xml | 4 ++-- spring-security-rest-custom/pom.xml | 4 ++-- spring-security-rest-digest-auth/pom.xml | 4 ++-- spring-security-rest-full/pom.xml | 6 +++--- spring-security-rest/pom.xml | 4 ++-- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index b80fe2e5796e..1986f3e981e5 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -133,8 +133,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/experiments/pom.xml b/experiments/pom.xml index 1bfbff341ac1..a65a9280492d 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,8 +255,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/guava/pom.xml b/guava/pom.xml index d11727afc813..32831b15853b 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,8 +94,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 58d052af33d0..17675efcea2f 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -149,8 +149,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/jackson/pom.xml b/jackson/pom.xml index 365b2ca536b9..ba9504bed993 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,8 +107,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/mockito/pom.xml b/mockito/pom.xml index f247352eafc7..e33de774dd48 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,8 +89,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/sandbox/pom.xml b/sandbox/pom.xml index a3c457101cd8..3df2cdf7227f 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -134,7 +134,7 @@ 4.0.3.RELEASE - 3.2.3.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 5d0e8f4e3904..5f2a6904e850 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,8 +192,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 3.18.1-GA 1.2 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 075c22815c04..f2e0ac85e98c 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,8 +204,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 3.18.1-GA 1.2 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index c2b7a9fa7eb9..e426ee48170d 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -174,8 +174,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 3.18.1-GA diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 099f698c59bb..847b0b5b7904 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -182,8 +182,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 3.18.1-GA diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index c7bad22c976a..6eb0155a58af 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -177,8 +177,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index d8e4f77b209c..f6e7b55d48df 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,8 +141,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index f4db08254109..20e9da919648 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.0.4.RELEASE + 4.0.5.RELEASE 1.7.6 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 449bb0ded266..7238c7ec6051 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -141,7 +141,7 @@ - 4.0.4.RELEASE + 4.0.5.RELEASE 1.7.6 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 621f099efb10..1d67e3d77082 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,8 +202,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 74f463c061e1..08d4fd1cd53e 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -226,8 +226,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 182e5fda3aaf..664ee2fb2e2f 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -231,8 +231,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index e81fd4da9c89..7afd2170df0d 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -226,8 +226,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 9da13cde70b1..2f919da09036 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -223,8 +223,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index d4ee346179ac..d30b010f3393 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -231,8 +231,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index e9b29a610363..07146eb02b85 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,8 +287,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 0e83c0bb73e0..c1ff09482681 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -251,8 +251,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 9a812d773de6..9c0728a9f6de 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,8 +275,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 5dca63280734..cb5d3c45610f 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -371,13 +371,13 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final 5.1.30 - 1.5.2.RELEASE + 1.6.0.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index e775b1125cdc..5e1048071b3e 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -214,8 +214,8 @@ - 4.0.4.RELEASE - 3.2.3.RELEASE + 4.0.5.RELEASE + 3.2.4.RELEASE 4.3.5.Final From 6da20ff4dbc672c07a5120012b0f9b20276ff0f0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 24 May 2014 12:12:31 +0300 Subject: [PATCH 513/796] spring data jpa work --- .../org/baeldung/persistence/dao/IFooDao.java | 6 +- .../baeldung/spring/PersistenceConfig.java | 4 +- ...ractServicePersistenceIntegrationTest.java | 255 ++++++++++++++++++ .../FooServicePersistenceIntegrationTest.java | 25 +- .../test/java/org/baeldung/util/IDUtil.java | 33 +++ 5 files changed, 316 insertions(+), 7 deletions(-) create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java create mode 100644 spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java index b643516d06d9..7244f447a6b7 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -3,7 +3,11 @@ import org.baeldung.persistence.model.Foo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; public interface IFooDao extends JpaRepository, JpaSpecificationExecutor { - // + + @Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)") + Foo retrieveByName(String name); + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index bcb61033ca89..de4aadf18264 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -36,7 +36,7 @@ public PersistenceConfig() { } @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); @@ -63,7 +63,7 @@ public DataSource dataSource() { @Bean public PlatformTransactionManager transactionManager() { final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactoryBean().getObject()); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); return transactionManager; } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java new file mode 100644 index 000000000000..79889e0f9e81 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java @@ -0,0 +1,255 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.IOperations; +import org.baeldung.persistence.model.Foo; +import org.baeldung.util.IDUtil; +import org.hamcrest.Matchers; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.dao.DataAccessException; + +public abstract class AbstractServicePersistenceIntegrationTest { + + // tests + + // find - one + + @Test + /**/public final void givenResourceDoesNotExist_whenResourceIsRetrieved_thenNoResourceIsReceived() { + // When + final Foo createdResource = getApi().findOne(IDUtil.randomPositiveLong()); + + // Then + assertNull(createdResource); + } + + @Test + public void givenResourceExists_whenResourceIsRetrieved_thenNoExceptions() { + final Foo existingResource = persistNewEntity(); + getApi().findOne(existingResource.getId()); + } + + @Test + public void givenResourceDoesNotExist_whenResourceIsRetrieved_thenNoExceptions() { + getApi().findOne(IDUtil.randomPositiveLong()); + } + + @Test + public void givenResourceExists_whenResourceIsRetrieved_thenTheResultIsNotNull() { + final Foo existingResource = persistNewEntity(); + final Foo retrievedResource = getApi().findOne(existingResource.getId()); + assertNotNull(retrievedResource); + } + + @Test + public void givenResourceExists_whenResourceIsRetrieved_thenResourceIsRetrievedCorrectly() { + final Foo existingResource = persistNewEntity(); + final Foo retrievedResource = getApi().findOne(existingResource.getId()); + assertEquals(existingResource, retrievedResource); + } + + // find - one - by name + + // find - all + + @Test + /**/public void whenAllResourcesAreRetrieved_thenNoExceptions() { + getApi().findAll(); + } + + @Test + /**/public void whenAllResourcesAreRetrieved_thenTheResultIsNotNull() { + final List resources = getApi().findAll(); + + assertNotNull(resources); + } + + @Test + /**/public void givenAtLeastOneResourceExists_whenAllResourcesAreRetrieved_thenRetrievedResourcesAreNotEmpty() { + persistNewEntity(); + + // When + final List allResources = getApi().findAll(); + + // Then + assertThat(allResources, not(Matchers. empty())); + } + + @Test + /**/public void givenAnResourceExists_whenAllResourcesAreRetrieved_thenTheExistingResourceIsIndeedAmongThem() { + final Foo existingResource = persistNewEntity(); + + final List resources = getApi().findAll(); + + assertThat(resources, hasItem(existingResource)); + } + + @Test + /**/public void whenAllResourcesAreRetrieved_thenResourcesHaveIds() { + persistNewEntity(); + + // When + final List allResources = getApi().findAll(); + + // Then + for (final Foo resource : allResources) { + assertNotNull(resource.getId()); + } + } + + // create + + @Test(expected = RuntimeException.class) + /**/public void whenNullResourceIsCreated_thenException() { + getApi().create(null); + } + + @Test + /**/public void whenResourceIsCreated_thenNoExceptions() { + persistNewEntity(); + } + + @Test + /**/public void whenResourceIsCreated_thenResourceIsRetrievable() { + final Foo existingResource = persistNewEntity(); + + assertNotNull(getApi().findOne(existingResource.getId())); + } + + @Test + /**/public void whenResourceIsCreated_thenSavedResourceIsEqualToOriginalResource() { + final Foo originalResource = createNewEntity(); + final Foo savedResource = getApi().create(originalResource); + + assertEquals(originalResource, savedResource); + } + + @Test(expected = RuntimeException.class) + public void whenResourceWithFailedConstraintsIsCreated_thenException() { + final Foo invalidResource = createNewEntity(); + invalidate(invalidResource); + + getApi().create(invalidResource); + } + + /** + * -- specific to the persistence engine + */ + @Test(expected = DataAccessException.class) + @Ignore("Hibernate simply ignores the id silently and still saved (tracking this)") + public void whenResourceWithIdIsCreated_thenDataAccessException() { + final Foo resourceWithId = createNewEntity(); + resourceWithId.setId(IDUtil.randomPositiveLong()); + + getApi().create(resourceWithId); + } + + // update + + @Test(expected = RuntimeException.class) + /**/public void whenNullResourceIsUpdated_thenException() { + getApi().update(null); + } + + @Test + /**/public void givenResourceExists_whenResourceIsUpdated_thenNoExceptions() { + // Given + final Foo existingResource = persistNewEntity(); + + // When + getApi().update(existingResource); + } + + /** + * - can also be the ConstraintViolationException which now occurs on the update operation will not be translated; as a consequence, it will be a TransactionSystemException + */ + @Test(expected = RuntimeException.class) + public void whenResourceIsUpdatedWithFailedConstraints_thenException() { + final Foo existingResource = persistNewEntity(); + invalidate(existingResource); + + getApi().update(existingResource); + } + + @Test + /**/public void givenResourceExists_whenResourceIsUpdated_thenUpdatesArePersisted() { + // Given + final Foo existingResource = persistNewEntity(); + + // When + change(existingResource); + getApi().update(existingResource); + + final Foo updatedResource = getApi().findOne(existingResource.getId()); + + // Then + assertEquals(existingResource, updatedResource); + } + + // delete + + // @Test(expected = RuntimeException.class) + // public void givenResourceDoesNotExists_whenResourceIsDeleted_thenException() { + // // When + // getApi().delete(IDUtil.randomPositiveLong()); + // } + // + // @Test(expected = RuntimeException.class) + // public void whenResourceIsDeletedByNegativeId_thenException() { + // // When + // getApi().delete(IDUtil.randomNegativeLong()); + // } + // + // @Test + // public void givenResourceExists_whenResourceIsDeleted_thenNoExceptions() { + // // Given + // final Foo existingResource = persistNewEntity(); + // + // // When + // getApi().delete(existingResource.getId()); + // } + // + // @Test + // /**/public final void givenResourceExists_whenResourceIsDeleted_thenResourceNoLongerExists() { + // // Given + // final Foo existingResource = persistNewEntity(); + // + // // When + // getApi().delete(existingResource.getId()); + // + // // Then + // assertNull(getApi().findOne(existingResource.getId())); + // } + + // template method + + protected Foo createNewEntity() { + return new Foo(randomAlphabetic(6)); + } + + protected abstract IOperations getApi(); + + private final void invalidate(final Foo entity) { + entity.setName(null); + } + + private final void change(final Foo entity) { + entity.setName(randomAlphabetic(6)); + } + + protected Foo persistNewEntity() { + return getApi().create(createNewEntity()); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index fd035e5615cc..e6a3385ce2f3 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -2,6 +2,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import org.baeldung.persistence.IOperations; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; @@ -16,7 +17,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServicePersistenceIntegrationTest { +public class FooServicePersistenceIntegrationTest extends AbstractServicePersistenceIntegrationTest { @Autowired private IFooService service; @@ -38,11 +39,20 @@ public final void whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } - @Test(expected = DataIntegrityViolationException.class) - public final void whenEntityWithLongNameIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); + // @Test(expected = DataIntegrityViolationException.class) + // public final void whenEntityWithLongNameIsCreated_thenDataException() { + // service.create(new Foo(randomAlphabetic(2048))); + // } + + // custom Query method + + @Test + public final void givenUsingCustomQuery_whenExecuting_thenNoExceptions() { + // service.create(new Foo(randomAlphabetic(2048))); } + // work in progress + @Test(expected = InvalidDataAccessApiUsageException.class) @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") public final void whenSameEntityIsCreatedTwice_thenDataException() { @@ -51,4 +61,11 @@ public final void whenSameEntityIsCreatedTwice_thenDataException() { service.create(entity); } + // API + + @Override + protected final IOperations getApi() { + return service; + } + } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java b/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java new file mode 100644 index 000000000000..84fb63a32160 --- /dev/null +++ b/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java @@ -0,0 +1,33 @@ +package org.baeldung.util; + +import java.util.Random; + +public final class IDUtil { + + private IDUtil() { + throw new AssertionError(); + } + + // API + + public final static String randomPositiveLongAsString() { + return Long.toString(randomPositiveLong()); + } + + public final static String randomNegativeLongAsString() { + return Long.toString(randomNegativeLong()); + } + + public final static long randomPositiveLong() { + long id = new Random().nextLong() * 10000; + id = (id < 0) ? (-1 * id) : id; + return id; + } + + public final static long randomNegativeLong() { + long id = new Random().nextLong() * 10000; + id = (id > 0) ? (-1 * id) : id; + return id; + } + +} From 39b7570d82fe76a315d0ee7954cbf4cd05c8e93a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 24 May 2014 12:17:05 +0300 Subject: [PATCH 514/796] new custom query operation for spring data and tests --- .../org/baeldung/persistence/dao/IFooDao.java | 3 ++- .../persistence/service/IFooService.java | 4 +++- .../persistence/service/impl/FooService.java | 6 ++++++ .../FooServicePersistenceIntegrationTest.java | 17 +++++++++++------ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java index 7244f447a6b7..824d6ea546fd 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -4,10 +4,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface IFooDao extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)") - Foo retrieveByName(String name); + Foo retrieveByName(@Param("name") String name); } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java index 2bfe395df0b5..60d607b9efaa 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -4,5 +4,7 @@ import org.baeldung.persistence.model.Foo; public interface IFooService extends IOperations { - // + + Foo retrieveByName(String name); + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index f509068d42ff..533c0f5082f2 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -32,6 +32,12 @@ protected PagingAndSortingRepository getDao() { return dao; } + // custom methods + + public Foo retrieveByName(final String name) { + return dao.retrieveByName(name); + } + // overridden to be secured @Override diff --git a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index e6a3385ce2f3..089d2d13a26a 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,6 +1,7 @@ package org.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertNotNull; import org.baeldung.persistence.IOperations; import org.baeldung.persistence.model.Foo; @@ -39,16 +40,20 @@ public final void whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } - // @Test(expected = DataIntegrityViolationException.class) - // public final void whenEntityWithLongNameIsCreated_thenDataException() { - // service.create(new Foo(randomAlphabetic(2048))); - // } + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } // custom Query method @Test - public final void givenUsingCustomQuery_whenExecuting_thenNoExceptions() { - // service.create(new Foo(randomAlphabetic(2048))); + public final void givenUsingCustomQuery_whenRetrievingEntity_thenFound() { + final String name = randomAlphabetic(6); + service.create(new Foo(name)); + + final Foo retrievedByName = service.retrieveByName(name); + assertNotNull(retrievedByName); } // work in progress From 36724980feab162c29e8ab7771995be2516fc4f1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 24 May 2014 12:50:26 +0300 Subject: [PATCH 515/796] java config for spring data jpa --- .../src/main/java/org/baeldung/spring/PersistenceConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index de4aadf18264..160650afaf43 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -8,10 +8,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -25,7 +25,8 @@ @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) -@ImportResource("classpath*:springDataPersistenceConfig.xml") +// @ImportResource("classpath*:springDataPersistenceConfig.xml") +@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") public class PersistenceConfig { @Autowired From b5be074c97c4d2a32d4a5b79ef3a516a89fe54bc Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sat, 24 May 2014 07:59:33 -0500 Subject: [PATCH 516/796] Added Caps to File name constants --- .../httpclient/HttpClientMultipartTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java index 9e5d219b3b03..687a24849004 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartTest.java @@ -33,9 +33,9 @@ public class HttpClientMultipartTest { private static final String SERVER = "http://echo.200please.com"; - private static final String textFileName = "temp.txt"; - private static final String imageFileName = "image.jpg"; - private static final String zipFileName = "zipFile.zip"; + private static final String TEXTFILENAME = "temp.txt"; + private static final String IMAGEFILENAME = "image.jpg"; + private static final String ZIPFILENAME = "zipFile.zip"; private static final Logger LOGGER = Logger.getLogger("org.baeldung.httpclient.HttpClientMultipartTest"); private CloseableHttpClient client; private HttpPost post; @@ -78,7 +78,7 @@ public final void after() throws IllegalStateException, IOException { @Test public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException { - final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + textFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + TEXTFILENAME); final File file = new File(url.getPath()); final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); final StringBody stringBody1 = new StringBody("This is message 1", ContentType.MULTIPART_FORM_DATA); @@ -103,12 +103,12 @@ public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExce @Test public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { - final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + textFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + TEXTFILENAME); final File file = new File(url.getPath()); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addBinaryBody("upfile", file, ContentType.DEFAULT_BINARY, textFileName); + builder.addBinaryBody("upfile", file, ContentType.DEFAULT_BINARY, TEXTFILENAME); builder.addTextBody("text", message, ContentType.DEFAULT_BINARY); final HttpEntity entity = builder.build(); post.setEntity(entity); @@ -125,15 +125,15 @@ public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody @Test public final void givenFileandInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { - final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + zipFileName); - final URL url2 = Thread.currentThread().getContextClassLoader().getResource("uploads/" + imageFileName); + final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + ZIPFILENAME); + final URL url2 = Thread.currentThread().getContextClassLoader().getResource("uploads/" + IMAGEFILENAME); final InputStream inputStream = new FileInputStream(url.getPath()); final File file = new File(url2.getPath()); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addBinaryBody("upfile", file, ContentType.DEFAULT_BINARY, imageFileName); - builder.addBinaryBody("upstream", inputStream, ContentType.create("application/zip"), zipFileName); + builder.addBinaryBody("upfile", file, ContentType.DEFAULT_BINARY, IMAGEFILENAME); + builder.addBinaryBody("upstream", inputStream, ContentType.create("application/zip"), ZIPFILENAME); builder.addTextBody("text", message, ContentType.TEXT_PLAIN); final HttpEntity entity = builder.build(); post.setEntity(entity); @@ -155,7 +155,7 @@ public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBod final byte[] bytes = "binary code".getBytes(); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - builder.addBinaryBody("upfile", bytes, ContentType.DEFAULT_BINARY, textFileName); + builder.addBinaryBody("upfile", bytes, ContentType.DEFAULT_BINARY, TEXTFILENAME); builder.addTextBody("text", message, ContentType.TEXT_PLAIN); final HttpEntity entity = builder.build(); post.setEntity(entity); From da60bb960eca17a2e2469dc62b02bbf7d84faf1a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 31 May 2014 00:30:37 +0300 Subject: [PATCH 517/796] simple java conversion logic --- .../CoreJavaCollectionsUnitTest.java | 2 +- .../JavaCollectionConversionUnitTest.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) rename core-java/src/test/java/org/baeldung/java/{ => collections}/CoreJavaCollectionsUnitTest.java (98%) create mode 100644 core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java similarity index 98% rename from core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java rename to core-java/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java index 7dc6b7aab04b..fb7bfe51a275 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaCollectionsUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package org.baeldung.java.collections; import java.util.ArrayList; import java.util.Arrays; diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java new file mode 100644 index 000000000000..5c8e4adf5886 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java @@ -0,0 +1,47 @@ +package org.baeldung.java.collections; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.collections4.CollectionUtils; +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.common.primitives.Ints; + +@SuppressWarnings("unused") +public class JavaCollectionConversionUnitTest { + + @Test + public final void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final List targetList = Arrays.asList(sourceArray); + } + + @Test + public void givenUsingCoreJava_whenListConvertedToArray_thenCorrect() { + final List sourceList = Lists. newArrayList(0, 1, 2, 3, 4, 5); + final Integer[] targetArray = sourceList.toArray(new Integer[sourceList.size()]); + } + + @Test + public final void givenUsingGuava_whenArrayConvertedToList_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final List targetList = Lists.newArrayList(sourceArray); + } + + @Test + public void givenUsingGuava_whenLIistConvertedToArray_thenCorrect() { + final List sourceList = Lists.newArrayList(0, 1, 2, 3, 4, 5); + final int[] targetArray = Ints.toArray(sourceList); + } + + @Test + public void givenUsingCommonsCollections_whenArrayConvertedToList_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final List targetList = new ArrayList<>(6); + CollectionUtils.addAll(targetList, sourceArray); + } + +} From 7b7b5ae49fa698c81a8986ddc917d69b3ddf4d89 Mon Sep 17 00:00:00 2001 From: corsoft Date: Fri, 30 May 2014 22:55:17 +0100 Subject: [PATCH 518/796] Initial commit of Persisted Remember-Me Example Initial commit - project copied from spring-security-mvc-custom and modified. Added PersistedToken remember me configuration (in xml and annotated classes), and some minor refactoring. This version works with PostgreSQL or H2 (configured in DatabaseConfig.java). --- .../.gitignore | 16 + .../README.md | 15 + .../pom.xml | 300 ++++++++++++++++++ ...SimpleUrlAuthenticationSuccessHandler.java | 97 ++++++ .../SecurityWebApplicationInitializer.java | 11 + .../service/MyUserDetailsService.java | 62 ++++ .../org/baeldung/spring/DatabaseConfig.java | 35 ++ .../java/org/baeldung/spring/MvcConfig.java | 42 +++ .../org/baeldung/spring/SecurityConfig.java | 20 ++ .../src/main/resources/logback.xml | 20 ++ .../main/resources/persistence-h2.properties | 11 + .../resources/persistence-postgres.properties | 11 + .../src/main/resources/webSecurityConfig.xml | 52 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 + .../main/webapp/WEB-INF/view/anonymous.jsp | 10 + .../src/main/webapp/WEB-INF/view/console.jsp | 22 ++ .../src/main/webapp/WEB-INF/view/homepage.jsp | 22 ++ .../src/main/webapp/WEB-INF/view/login.jsp | 30 ++ .../src/main/webapp/WEB-INF/web.xml | 55 ++++ .../src/test/resources/.gitignore | 13 + 20 files changed, 850 insertions(+) create mode 100644 spring-security-mvc-persisted-remember-me/.gitignore create mode 100644 spring-security-mvc-persisted-remember-me/README.md create mode 100644 spring-security-mvc-persisted-remember-me/pom.xml create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/resources/logback.xml create mode 100644 spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties create mode 100644 spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties create mode 100644 spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/anonymous.jsp create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-mvc-persisted-remember-me/src/test/resources/.gitignore diff --git a/spring-security-mvc-persisted-remember-me/.gitignore b/spring-security-mvc-persisted-remember-me/.gitignore new file mode 100644 index 000000000000..108e0ccdf65e --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/.gitignore @@ -0,0 +1,16 @@ +# Eclipse +.classpath +.project +.settings/ + +# Intellij +.idea/ +*.iml +*.iws + +# Mac +.DS_Store + +# Maven +log/ +target/ \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/README.md b/spring-security-mvc-persisted-remember-me/README.md new file mode 100644 index 000000000000..11f541702845 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/README.md @@ -0,0 +1,15 @@ +========= + +## Spring Security Persisted Remember Me Example Project + + +### Relevant Articles: +- [Spring Security Persisted Remember Me] +- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) +- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) + + +### Build the Project +``` +mvn clean install +``` diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml new file mode 100644 index 000000000000..b131e3805abb --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -0,0 +1,300 @@ + + 4.0.0 + org.baeldung + spring-security-mvc-persisted-remember-me + 0.1-SNAPSHOT + + spring-security-mvc-persisted-remember-me + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + org.springframework + spring-orm + ${org.springframework.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.h2database + h2 + 1.4.178 + + + + postgresql + postgresql + 9.1-901.jdbc4 + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + + + + + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-persisted-remember-me + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 4.0.5.RELEASE + 3.2.4.RELEASE + + + 4.3.5.Final + 5.1.30 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.3 + 4.3.2 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.8 + + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..2ce1812c9275 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,97 @@ +package org.baeldung.security; + +import java.io.IOException; +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +@Component(value="mySimpleUrlAuthenticationSuccessHandler") +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + + private final Log logger = LogFactory.getLog(this.getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + protected MySimpleUrlAuthenticationSuccessHandler() { + super(); + } + + // API + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + handle(request, response, authentication); + clearAuthenticationAttributes(request); + } + + // IMPL + + protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { + final String targetUrl = determineTargetUrl(authentication); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + protected String determineTargetUrl(final Authentication authentication) { + boolean isUser = false; + boolean isAdmin = false; + final Collection authorities = authentication.getAuthorities(); + for (final GrantedAuthority grantedAuthority : authorities) { + if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + isUser = true; + break; + } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + isAdmin = true; + break; + } + } + + if (isUser) { + return "/homepage.html"; + } else if (isAdmin) { + return "/console.html"; + } else { + throw new IllegalStateException(); + } + } + + /** + * Removes temporary authentication-related data which may have been stored in the session + * during the authentication process. + */ + protected final void clearAuthenticationAttributes(final HttpServletRequest request) { + final HttpSession session = request.getSession(false); + + if (session == null) { + return; + } + + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + + public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } + +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java new file mode 100644 index 000000000000..c4c4b0bb9805 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java @@ -0,0 +1,11 @@ +package org.baeldung.security; + +import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; + +/** + * Registers the springSecurityFilterChain Filter for every URL in the application. + * + */ +public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer{ + +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java new file mode 100644 index 000000000000..5e9abc2dea16 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java @@ -0,0 +1,62 @@ +package org.baeldung.service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +/** + * User Details Service - hard coded to two users for the example. + */ +@Service +public class MyUserDetailsService implements UserDetailsService { + + private final Log logger = LogFactory.getLog(this.getClass()); + + private Map availableUsers = new HashMap(); + + public MyUserDetailsService() { + + availableUsers.put("user", + createUser("user", "password", Arrays.asList("ROLE_USER"))); + availableUsers.put("admin", + createUser("admin", "password", Arrays.asList("ROLE_ADMIN"))); + } + + @Override + public UserDetails loadUserByUsername(String username) + throws UsernameNotFoundException { + + logger.info("Load user by username " + username); + + UserDetails user = availableUsers.get(username); + if (user == null) { + throw new UsernameNotFoundException("Username not found"); + } else { + return availableUsers.get(username); + } + + } + + private User createUser(String username, String password, List roles) { + + logger.info("Create user " + username); + + List authorities = new ArrayList(); + for (String role : roles) { + authorities.add(new SimpleGrantedAuthority(role)); + } + return new User(username, password, true, true, true, true, authorities); + } +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java new file mode 100644 index 000000000000..4fbcca7886b1 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java @@ -0,0 +1,35 @@ +package org.baeldung.spring; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +/** + * Spring Database Configuration. + */ +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-h2.properties" }) +public class DatabaseConfig { + + @Autowired + private Environment env; + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + return dataSource; + } +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..d4e0c5500420 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,42 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +/** + * Spring Web Configuration. + */ +@EnableWebMvc +@ComponentScan("org.baeldung") +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + registry.addViewController("/anonymous.html"); + registry.addViewController("/login.html"); + registry.addViewController("/homepage.html"); + registry.addViewController("/console.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + return bean; + } +} \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java new file mode 100644 index 000000000000..ec1ad9831aad --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java @@ -0,0 +1,20 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +/** + * Spring Security Configuration. + */ +@Configuration +@EnableWebSecurity +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + public SecurityConfig() { + super(); + } + +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/logback.xml b/spring-security-mvc-persisted-remember-me/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties new file mode 100644 index 000000000000..5d872b89d5a2 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties @@ -0,0 +1,11 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:tcp://localhost/~/test + +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties new file mode 100644 index 000000000000..798661e51eb3 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties @@ -0,0 +1,11 @@ +# jdbc.X +jdbc.driverClassName=org.postgresql.Driver +jdbc.url=jdbc:postgresql://localhost:5432 + +jdbc.user=postgres +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..04f84f2e7794 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..a675fc6d954f --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/anonymous.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/anonymous.jsp new file mode 100644 index 000000000000..d4e9c0289b29 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/anonymous.jsp @@ -0,0 +1,10 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +

Anonymous page

+ + ">To Login + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..d18b59a10caf --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..afd2c6da594f --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,22 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%> + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..0eb857c62aee --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,30 @@ + + + + +

Login

+ +
+ + + + + + + + + + + + + + + + + +
User:
Password:
Remember Me:
+ +
+ + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..aa5220542064 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,55 @@ + + + + Spring MVC Custom Application + + + 1 + + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + + + + + \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/test/resources/.gitignore b/spring-security-mvc-persisted-remember-me/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From d06f8f87b22e2817dfe697bffc2344c027edd22b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 31 May 2014 17:56:15 +0300 Subject: [PATCH 519/796] conversion simple testing work --- .../JavaCollectionConversionUnitTest.java | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java index 5c8e4adf5886..ec3385dfc10c 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java @@ -2,17 +2,24 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.Test; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.common.primitives.Ints; @SuppressWarnings("unused") public class JavaCollectionConversionUnitTest { + // List -> array; array -> List + @Test public final void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; @@ -20,7 +27,7 @@ public final void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { } @Test - public void givenUsingCoreJava_whenListConvertedToArray_thenCorrect() { + public final void givenUsingCoreJava_whenListConvertedToArray_thenCorrect() { final List sourceList = Lists. newArrayList(0, 1, 2, 3, 4, 5); final Integer[] targetArray = sourceList.toArray(new Integer[sourceList.size()]); } @@ -32,16 +39,69 @@ public final void givenUsingGuava_whenArrayConvertedToList_thenCorrect() { } @Test - public void givenUsingGuava_whenLIistConvertedToArray_thenCorrect() { + public final void givenUsingGuava_whenListConvertedToArray_thenCorrect() { final List sourceList = Lists.newArrayList(0, 1, 2, 3, 4, 5); final int[] targetArray = Ints.toArray(sourceList); } @Test - public void givenUsingCommonsCollections_whenArrayConvertedToList_thenCorrect() { + public final void givenUsingCommonsCollections_whenArrayConvertedToList_thenCorrect() { final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; final List targetList = new ArrayList<>(6); CollectionUtils.addAll(targetList, sourceArray); } + // Set -> array; array -> Set + + @Test + public final void givenUsingCoreJavaV1_whenArrayConvertedToSet_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final Set targetSet = new HashSet(Arrays.asList(sourceArray)); + } + + @Test + public final void givenUsingCoreJavaV2_whenArrayConvertedToSet_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final Set targetSet = new HashSet(); + Collections.addAll(targetSet, sourceArray); + } + + @Test + public final void givenUsingCoreJava_whenSetConvertedToArray_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final Integer[] targetArray = sourceSet.toArray(new Integer[sourceSet.size()]); + } + + @Test + public final void givenUsingGuava_whenArrayConvertedToSet_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final Set targetSet = Sets.newHashSet(sourceArray); + } + + @Test + public final void givenUsingGuava_whenSetConvertedToArray_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final int[] targetArray = Ints.toArray(sourceSet); + } + + @Test + public final void givenUsingCommonsCollections_whenArrayConvertedToSet_thenCorrect() { + final Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; + final Set targetSet = new HashSet<>(6); + CollectionUtils.addAll(targetSet, sourceArray); + } + + @Test + public final void givenUsingCommonsCollections_whenSetConvertedToArray_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final Integer[] targetArray = sourceSet.toArray(new Integer[sourceSet.size()]); + } + + @Test + public final void givenUsingCommonsCollections_whenSetConvertedToArrayOfPrimitives_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final Integer[] targetArray = sourceSet.toArray(new Integer[sourceSet.size()]); + final int[] primitiveTargetArray = ArrayUtils.toPrimitive(targetArray); + } + } From dd020af30af9b8fe94d3bb3eda90402f0f254ade Mon Sep 17 00:00:00 2001 From: corsoft Date: Sat, 31 May 2014 16:39:21 +0100 Subject: [PATCH 520/796] Updated spring-security-mvc-persisted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated spring-security-mvc-persisted - added login error message if unknown user, and switched default H2 database to be embedded in-memory. Added explicit sql creation script to automatically create table on deployment (for some reason the createTableOnStartup flag in the jdbcTokenRepository didn’t work with embedded H2) --- .../org/baeldung/controller/MyController.java | 35 +++++++++++++++++ ...SimpleUrlAuthenticationSuccessHandler.java | 4 +- .../org/baeldung/security/SecurityRole.java | 12 ++++++ .../service/MyUserDetailsService.java | 39 +++++++++++++++---- .../org/baeldung/spring/SecurityConfig.java | 9 ++++- .../persisted_logins_create_table.sql | 7 ++++ .../main/resources/persistence-h2.properties | 13 +++---- .../resources/persistence-postgres.properties | 8 +--- .../src/main/resources/webSecurityConfig.xml | 25 ++++++------ .../src/main/webapp/WEB-INF/view/login.jsp | 24 +++++++++++- 10 files changed, 141 insertions(+), 35 deletions(-) create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java create mode 100644 spring-security-mvc-persisted-remember-me/src/main/resources/persisted_logins_create_table.sql diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java new file mode 100644 index 000000000000..bf3da5045d4a --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java @@ -0,0 +1,35 @@ +package org.baeldung.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +/** + * Web Controller. + * + */ +@Controller +public class MyController { + + /** + * Build the view model for the login page (add authentication error + * information in the event of an unsuccessful login attempt). + */ + @RequestMapping(value = "/login", method = RequestMethod.GET) + public ModelAndView login( + @RequestParam(value = "error", required = false) String error) { + + ModelAndView model = new ModelAndView(); + if (error != null) { + model.addObject("message", + "Username or password not recognised - please try again."); + } + + model.setViewName("login"); + return model; + + } + +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index 2ce1812c9275..becc321e251f 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -54,10 +54,10 @@ protected String determineTargetUrl(final Authentication authentication) { boolean isAdmin = false; final Collection authorities = authentication.getAuthorities(); for (final GrantedAuthority grantedAuthority : authorities) { - if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + if (grantedAuthority.getAuthority().equals(SecurityRole.ROLE_USER.toString())) { isUser = true; break; - } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + } else if (grantedAuthority.getAuthority().equals(SecurityRole.ROLE_ADMIN.toString())) { isAdmin = true; break; } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java new file mode 100644 index 000000000000..750f672ba961 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java @@ -0,0 +1,12 @@ +package org.baeldung.security; + +/** + * Simple enum of Security Roles available. + * + */ +public enum SecurityRole { + + ROLE_USER, + ROLE_ADMIN; + +} diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java index 5e9abc2dea16..017f6eeb81ef 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java @@ -8,6 +8,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.baeldung.security.SecurityRole; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; @@ -28,10 +29,8 @@ public class MyUserDetailsService implements UserDetailsService { public MyUserDetailsService() { - availableUsers.put("user", - createUser("user", "password", Arrays.asList("ROLE_USER"))); - availableUsers.put("admin", - createUser("admin", "password", Arrays.asList("ROLE_ADMIN"))); + populateDemoUsers(); + } @Override @@ -49,13 +48,39 @@ public UserDetails loadUserByUsername(String username) } - private User createUser(String username, String password, List roles) { + /** + * Create demo users (note: obviously in a real system these would be persisted + * in database or retrieved from another system). + */ + private void populateDemoUsers(){ + + logger.info("Populate demo users"); + + availableUsers.put("user", + createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER))); + availableUsers.put("admin", + createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN))); + } + + + /** + * Create a demo User. + * + * @param username + * Username + * @param password + * Password + * @param roles + * Role names user is assigned to + * @return User + */ + private User createUser(String username, String password, List roles) { logger.info("Create user " + username); List authorities = new ArrayList(); - for (String role : roles) { - authorities.add(new SimpleGrantedAuthority(role)); + for (SecurityRole role : roles) { + authorities.add(new SimpleGrantedAuthority(role.toString())); } return new User(username, password, true, true, true, true, authorities); } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java index ec1ad9831aad..6d8584ff26bc 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java @@ -1,9 +1,11 @@ package org.baeldung.spring; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; /** * Spring Security Configuration. @@ -13,8 +15,13 @@ @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecurityConfig extends WebSecurityConfigurerAdapter { + @Autowired + private AuthenticationSuccessHandler mySimpleUrlAuthenticationSuccessHandler; + public SecurityConfig() { super(); } - + } + + diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/persisted_logins_create_table.sql b/spring-security-mvc-persisted-remember-me/src/main/resources/persisted_logins_create_table.sql new file mode 100644 index 000000000000..aad74ebbdc24 --- /dev/null +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/persisted_logins_create_table.sql @@ -0,0 +1,7 @@ +-- SQL example for H2 (ran automatically by the spring config for the embedded H2 example) +create table if not exists persistent_logins ( + username varchar_ignorecase(100) not null, + series varchar(64) primary key, + token varchar(64) not null, + last_used timestamp not null +); \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties index 5d872b89d5a2..ae659baedb90 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-h2.properties @@ -1,11 +1,10 @@ -# jdbc.X +# Jdbc H2 configuration +# By default uses the embedded in memory database +# Option provided to use the tcp version if you want to start H2 service and view data +# Chosen database defined in DatabaseConfig.java jdbc.driverClassName=org.h2.Driver -jdbc.url=jdbc:h2:tcp://localhost/~/test - +#jdbc.url=jdbc:h2:tcp://localhost/~/testDb +jdbc.url=jdbc:h2:mem:test;MVCC=TRUE jdbc.user=sa jdbc.pass= -# hibernate.X -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties index 798661e51eb3..f8c65c336700 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/persistence-postgres.properties @@ -1,11 +1,7 @@ -# jdbc.X +# Jdbc PostgreSQL option +# Chosen database defined in DatabaseConfig.java jdbc.driverClassName=org.postgresql.Driver jdbc.url=jdbc:postgresql://localhost:5432 - jdbc.user=postgres jdbc.pass= -# hibernate.X -hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml index 04f84f2e7794..77e907b44e4c 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml @@ -5,11 +5,13 @@ xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd"> @@ -25,28 +27,29 @@ + + + + + - - - + - - + + - - + + - + - - \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp index 0eb857c62aee..5697d1544a69 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp @@ -1,5 +1,18 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - + + +

Login

@@ -23,8 +36,17 @@ + + + + + + +
${message}
+
\ No newline at end of file From 2819b3137ce1af45a12dcd16286e1edae99b5217 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 1 Jun 2014 00:31:40 +0300 Subject: [PATCH 521/796] simple collections conversion work --- .../JavaCollectionConversionUnitTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java index ec3385dfc10c..b7f256fafbe1 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java @@ -104,4 +104,40 @@ public final void givenUsingCommonsCollections_whenSetConvertedToArrayOfPrimitiv final int[] primitiveTargetArray = ArrayUtils.toPrimitive(targetArray); } + // Set -> List; List -> Set + + public final void givenUsingCoreJava_whenSetConvertedToList_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final List targetList = new ArrayList<>(sourceSet); + } + + public final void givenUsingCoreJava_whenListConvertedToSet_thenCorrect() { + final List sourceList = Lists.newArrayList(0, 1, 2, 3, 4, 5); + final Set targetSet = new HashSet<>(sourceList); + } + + public final void givenUsingGuava_whenSetConvertedToList_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + final List targetList = Lists.newArrayList(sourceSet); + } + + public final void givenUsingGuava_whenListConvertedToSet_thenCorrect() { + final List sourceList = Lists.newArrayList(0, 1, 2, 3, 4, 5); + final Set targetSet = Sets.newHashSet(sourceList); + } + + public final void givenUsingCommonsCollections_whenListConvertedToSet_thenCorrect() { + final List sourceList = Lists.newArrayList(0, 1, 2, 3, 4, 5); + + final Set targetSet = new HashSet<>(6); + CollectionUtils.addAll(targetSet, sourceList); + } + + public final void givenUsingCommonsCollections_whenSetConvertedToList_thenCorrect() { + final Set sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5); + + final List targetList = new ArrayList<>(6); + CollectionUtils.addAll(targetList, sourceSet); + } + } From 423d49fcd360d29544c168158221cc327cf79b29 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 2 Jun 2014 20:36:09 +0200 Subject: [PATCH 522/796] new conversions --- .../JavaCollectionConversionUnitTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java index b7f256fafbe1..dc1e91a5bd7b 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java @@ -2,9 +2,12 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.commons.collections4.CollectionUtils; @@ -140,4 +143,45 @@ public final void givenUsingCommonsCollections_whenSetConvertedToList_thenCorrec CollectionUtils.addAll(targetList, sourceSet); } + // Map (values) -> Array, List, Set + + @Test + public final void givenUsingCoreJava_whenMapValuesConvertedToArray_thenCorrect() { + final Map sourceMap = createMap(); + + final Collection values = sourceMap.values(); + final String[] targetArray = values.toArray(new String[values.size()]); + } + + @Test + public final void givenUsingCoreJava_whenMapValuesConvertedToList_thenCorrect() { + final Map sourceMap = createMap(); + + final List targetList = new ArrayList<>(sourceMap.values()); + } + + @Test + public final void givenUsingGuava_whenMapValuesConvertedToList_thenCorrect() { + final Map sourceMap = createMap(); + + final List targetList = Lists.newArrayList(sourceMap.values()); + } + + @Test + public final void givenUsingCoreJava_whenMapValuesConvertedToS_thenCorrect() { + final Map sourceMap = createMap(); + + final Set targetSet = new HashSet<>(sourceMap.values()); + } + + // UTIL + + private final Map createMap() { + final Map sourceMap = new HashMap<>(3); + sourceMap.put(0, "zero"); + sourceMap.put(1, "one"); + sourceMap.put(2, "two"); + return sourceMap; + } + } From 8f7f048ed4f3a97f4204535d65cfdafcc4dd9416 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 2 Jun 2014 20:56:17 +0200 Subject: [PATCH 523/796] collection conversion work --- .../java/collections/JavaCollectionConversionUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java index dc1e91a5bd7b..95b79810cd12 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionConversionUnitTest.java @@ -168,7 +168,7 @@ public final void givenUsingGuava_whenMapValuesConvertedToList_thenCorrect() { } @Test - public final void givenUsingCoreJava_whenMapValuesConvertedToS_thenCorrect() { + public final void givenUsingCoreJava_whenMapValuesConvertedToSet_thenCorrect() { final Map sourceMap = createMap(); final Set targetSet = new HashSet<>(sourceMap.values()); From b4c1acebb2daecbe110c1a1f67a1b90e35019148 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 3 Jun 2014 16:31:37 +0200 Subject: [PATCH 524/796] httpclient - timeout simulation for a domain --- .../httpclient/HttpClientTimeoutLiveTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java index 16c1be1550ee..85d7f3456ec8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -92,4 +92,20 @@ public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } + /** + * This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP) + */ + @Test + public final void givenTimeoutIsConfigured_whenTimingOut_thenCorrect() throws ClientProtocolException, IOException { + final int timeout = 3; + + final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); + final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); + + final HttpGet request = new HttpGet("http://www.google.com:81"); + response = client.execute(request); + + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + } From 65bf9a0a94272f346cba306d711401f48c906943 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 3 Jun 2014 19:54:03 +0200 Subject: [PATCH 525/796] persistence sorting work --- .../service/FooServiceSortingTests.java | 75 +++++-------------- .../FooServiceSortingTestsWithNulls.java | 60 +++++++++++++++ 2 files changed, 79 insertions(+), 56 deletions(-) create mode 100644 spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index 37ed1dc2f0f4..c12dfda50c6a 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -1,40 +1,37 @@ package org.baeldung.persistence.service; -import static org.junit.Assert.assertNull; - import java.util.List; import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; +import javax.persistence.PersistenceContext; import javax.persistence.Query; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; +import org.baeldung.config.PersistenceJPAConfig; import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; -import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +@SuppressWarnings("unchecked") +public class FooServiceSortingTests { -import com.google.common.collect.Lists; + @PersistenceContext + private EntityManager entityManager; -public class FooServiceSortingTests { - private static EntityManager entityManager; - private static EntityManagerFactory emf; - private static EntityTransaction entityTransaction; - private static CriteriaBuilder criteriaBuilder; + @Autowired + private FooService service; - @BeforeClass - public static void before() { - emf = Persistence.createEntityManagerFactory("punit"); - entityManager = emf.createEntityManager(); - entityTransaction = entityManager.getTransaction(); - entityTransaction.begin(); - criteriaBuilder = entityManager.getCriteriaBuilder(); - } + // tests @Test public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { @@ -89,43 +86,9 @@ public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { } } - @Test - public final void whenSortingByStringNullLast_thenLastNull() { - final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - } - } - - @Test - public final void whenSortingByStringNullFirst_thenFirstNull() { - final Foo nullNameFoo = new Foo(); - nullNameFoo.setName(null); - - final Bar bar = new Bar(); - final List fooList1 = Lists.newArrayList(); - bar.setName("Bar_Me"); - nullNameFoo.setBar(bar); - fooList1.add(nullNameFoo); - bar.setFooList(fooList1); - entityManager.persist(bar); - entityManager.persist(nullNameFoo); - entityTransaction.commit(); - final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - } - } - @Test public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { - criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); final CriteriaQuery select = criteriaQuery.select(from); @@ -139,7 +102,7 @@ public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { @Test public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { - criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); final Root from = criteriaQuery.from(Foo.class); final CriteriaQuery select = criteriaQuery.select(from); diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java new file mode 100644 index 000000000000..7af2c1b6924b --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java @@ -0,0 +1,60 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertNull; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Foo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServiceSortingTestsWithNulls { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenSortingByStringNullLast_thenLastNull() { + service.create(new Foo()); + service.create(new Foo(randomAlphabetic(6))); + + final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + } + + @Test + public final void whenSortingByStringNullFirst_thenFirstNull() { + service.create(new Foo()); + + final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + } + +} From f0b106ab600f31c132b58c534b3870c1585c5d7b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 3 Jun 2014 19:58:42 +0200 Subject: [PATCH 526/796] persistence cleanup work --- .../baeldung/config/PersistenceJPAConfig.java | 2 +- ... => FooServiceSortingWitNullsManualTest.java} | 2 +- .../service/PersistenceTestSuite.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) rename spring-jpa/src/test/java/org/baeldung/persistence/service/{FooServiceSortingTestsWithNulls.java => FooServiceSortingWitNullsManualTest.java} (97%) create mode 100644 spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java diff --git a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java index 2e6882c684e4..76fc96b3ce32 100644 --- a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java @@ -37,7 +37,7 @@ public PersistenceJPAConfig() { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualTest.java similarity index 97% rename from spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java rename to spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualTest.java index 7af2c1b6924b..986e4e4a7d38 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTestsWithNulls.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualTest.java @@ -20,7 +20,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServiceSortingTestsWithNulls { +public class FooServiceSortingWitNullsManualTest { @PersistenceContext private EntityManager entityManager; diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java new file mode 100644 index 000000000000..35f648b5a086 --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java @@ -0,0 +1,16 @@ +package org.baeldung.persistence.service; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({// @formatter:off + FooPaginationPersistenceIntegrationTest.class + ,FooServicePersistenceIntegrationTest.class + ,FooServiceSortingTests.class + // manual only + // ,FooServiceSortingWitNullsManualTest.class +}) // @formatter:on +public class PersistenceTestSuite { + // +} From bb662b42528cbca9fc209ca4b6b1760496052ce7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 4 Jun 2014 12:14:34 +0200 Subject: [PATCH 527/796] cleanup work (mostly formating) --- .../org/baeldung/controller/MyController.java | 28 ++--- ...SimpleUrlAuthenticationSuccessHandler.java | 4 +- .../org/baeldung/security/SecurityRole.java | 5 +- .../SecurityWebApplicationInitializer.java | 2 +- .../service/MyUserDetailsService.java | 118 +++++++++--------- .../org/baeldung/spring/DatabaseConfig.java | 4 +- .../org/baeldung/spring/SecurityConfig.java | 14 +-- 7 files changed, 83 insertions(+), 92 deletions(-) diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java index bf3da5045d4a..51202225eeb8 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/controller/MyController.java @@ -13,23 +13,21 @@ @Controller public class MyController { - /** - * Build the view model for the login page (add authentication error - * information in the event of an unsuccessful login attempt). - */ - @RequestMapping(value = "/login", method = RequestMethod.GET) - public ModelAndView login( - @RequestParam(value = "error", required = false) String error) { + /** + * Build the view model for the login page (add authentication error + * information in the event of an unsuccessful login attempt). + */ + @RequestMapping(value = "/login", method = RequestMethod.GET) + public ModelAndView login(@RequestParam(value = "error", required = false) String error) { - ModelAndView model = new ModelAndView(); - if (error != null) { - model.addObject("message", - "Username or password not recognised - please try again."); - } + ModelAndView model = new ModelAndView(); + if (error != null) { + model.addObject("message", "Username or password not recognised - please try again."); + } - model.setViewName("login"); - return model; + model.setViewName("login"); + return model; - } + } } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index becc321e251f..22fd2cdcb629 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -17,9 +17,9 @@ import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.stereotype.Component; -@Component(value="mySimpleUrlAuthenticationSuccessHandler") +@Component(value = "mySimpleUrlAuthenticationSuccessHandler") public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { - + private final Log logger = LogFactory.getLog(this.getClass()); private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java index 750f672ba961..e41e7a4c4fd1 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityRole.java @@ -6,7 +6,6 @@ */ public enum SecurityRole { - ROLE_USER, - ROLE_ADMIN; - + ROLE_USER, ROLE_ADMIN; + } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java index c4c4b0bb9805..75f782e7dc80 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java @@ -6,6 +6,6 @@ * Registers the springSecurityFilterChain Filter for every URL in the application. * */ -public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer{ +public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java index 017f6eeb81ef..ac2aa6beb658 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/service/MyUserDetailsService.java @@ -23,65 +23,61 @@ @Service public class MyUserDetailsService implements UserDetailsService { - private final Log logger = LogFactory.getLog(this.getClass()); - - private Map availableUsers = new HashMap(); - - public MyUserDetailsService() { - - populateDemoUsers(); - - } - - @Override - public UserDetails loadUserByUsername(String username) - throws UsernameNotFoundException { - - logger.info("Load user by username " + username); - - UserDetails user = availableUsers.get(username); - if (user == null) { - throw new UsernameNotFoundException("Username not found"); - } else { - return availableUsers.get(username); - } - - } - - /** - * Create demo users (note: obviously in a real system these would be persisted - * in database or retrieved from another system). - */ - private void populateDemoUsers(){ - - logger.info("Populate demo users"); - - availableUsers.put("user", - createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER))); - availableUsers.put("admin", - createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN))); - } - - - /** - * Create a demo User. - * - * @param username - * Username - * @param password - * Password - * @param roles - * Role names user is assigned to - * @return User - */ - private User createUser(String username, String password, List roles) { - - logger.info("Create user " + username); - - List authorities = new ArrayList(); - for (SecurityRole role : roles) { - authorities.add(new SimpleGrantedAuthority(role.toString())); - } - return new User(username, password, true, true, true, true, authorities); - } + private final Log logger = LogFactory.getLog(this.getClass()); + + private Map availableUsers = new HashMap(); + + public MyUserDetailsService() { + + populateDemoUsers(); + + } + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + + logger.info("Load user by username " + username); + + UserDetails user = availableUsers.get(username); + if (user == null) { + throw new UsernameNotFoundException("Username not found"); + } else { + return availableUsers.get(username); + } + + } + + /** + * Create demo users (note: obviously in a real system these would be persisted + * in database or retrieved from another system). + */ + private void populateDemoUsers() { + + logger.info("Populate demo users"); + + availableUsers.put("user", createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER))); + availableUsers.put("admin", createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN))); + } + + /** + * Create a demo User. + * + * @param username + * Username + * @param password + * Password + * @param roles + * Role names user is assigned to + * @return User + */ + private User createUser(String username, String password, List roles) { + + logger.info("Create user " + username); + + List authorities = new ArrayList(); + for (SecurityRole role : roles) { + authorities.add(new SimpleGrantedAuthority(role.toString())); + } + return new User(username, password, true, true, true, true, authorities); + } } diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java index 4fbcca7886b1..7f0428df77b9 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/DatabaseConfig.java @@ -20,10 +20,10 @@ @PropertySource({ "classpath:persistence-h2.properties" }) public class DatabaseConfig { - @Autowired + @Autowired private Environment env; - @Bean + @Bean public DataSource dataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); diff --git a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java index 6d8584ff26bc..b3549511fc30 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java +++ b/spring-security-mvc-persisted-remember-me/src/main/java/org/baeldung/spring/SecurityConfig.java @@ -15,13 +15,11 @@ @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecurityConfig extends WebSecurityConfigurerAdapter { - @Autowired - private AuthenticationSuccessHandler mySimpleUrlAuthenticationSuccessHandler; - - public SecurityConfig() { - super(); - } - -} + @Autowired + private AuthenticationSuccessHandler mySimpleUrlAuthenticationSuccessHandler; + public SecurityConfig() { + super(); + } +} From 51b61e552e451bb06e0c6b813b222963b1bff2cc Mon Sep 17 00:00:00 2001 From: Adrian Milne Date: Wed, 4 Jun 2014 16:33:02 +0100 Subject: [PATCH 528/796] initial commit --- spring-security-ldap/README.md | 12 + spring-security-ldap/pom.xml | 266 ++++++++++++++++++ .../persistence/service/FooService.java | 23 ++ .../MyBasicAuthenticationEntryPoint.java | 31 ++ .../java/org/baeldung/spring/MvcConfig.java | 39 +++ .../baeldung/spring/PersistenceConfig.java | 14 + .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 17 ++ .../web/controller/FooController.java | 74 +++++ .../org/baeldung/web/controller/LinkUtil.java | 30 ++ .../web/controller/ResourceCreated.java | 35 +++ ...esourceCreatedDiscoverabilityListener.java | 35 +++ .../controller/SingleResourceRetrieved.java | 29 ++ ...ourceRetrievedDiscoverabilityListener.java | 32 +++ .../web/controller/TestController.java | 28 ++ .../main/java/org/baeldung/web/dto/Foo.java | 11 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 25 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 42 +++ .../src/test/resources/.gitignore | 13 + 22 files changed, 804 insertions(+) create mode 100644 spring-security-ldap/README.md create mode 100644 spring-security-ldap/pom.xml create mode 100644 spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-ldap/src/main/resources/logback.xml create mode 100644 spring-security-ldap/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-ldap/src/test/resources/.gitignore diff --git a/spring-security-ldap/README.md b/spring-security-ldap/README.md new file mode 100644 index 000000000000..95e45ae519cb --- /dev/null +++ b/spring-security-ldap/README.md @@ -0,0 +1,12 @@ +========= + +## Spring Security with Basic Authentication Example Project + + +### Relevant Article: +- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) + + +### Notes +- the project includes both views as well as a REST layer \ No newline at end of file diff --git a/spring-security-ldap/pom.xml b/spring-security-ldap/pom.xml new file mode 100644 index 000000000000..607ddf50d100 --- /dev/null +++ b/spring-security-ldap/pom.xml @@ -0,0 +1,266 @@ + + 4.0.0 + org.baeldung + spring-security-ldap + 0.1-SNAPSHOT + + spring-security-ldap + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-basic-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 4.0.5.RELEASE + 3.2.4.RELEASE + + + 4.3.5.Final + 5.1.30 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.8 + + + + diff --git a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..02db7a733a6b --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,23 @@ +package org.baeldung.persistence.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public FooService() { + super(); + } + + // API + + public Foo getById(final Long id) { + return null; + } + + public Long create(final Foo resource) { + return null; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 000000000000..968237227f63 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,31 @@ +package org.baeldung.security.basic; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..74c11478ee2e --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java new file mode 100644 index 000000000000..4ea0053f4845 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.persistence") +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..fa6f5f6d5626 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..daa797ee368e --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,74 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.service.FooService; +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private FooService service; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java new file mode 100644 index 000000000000..a41ebb5a5cdd --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java new file mode 100644 index 000000000000..a67788810161 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfNewResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 000000000000..8d19ef82fc63 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletRequest request = resourceCreatedEvent.getRequest(); + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(request, response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + final String requestUrl = request.getRequestURL().toString(); + final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java new file mode 100644 index 000000000000..3de791810549 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java @@ -0,0 +1,29 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..45cd7c4d131a --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,32 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletRequest request = resourceRetrievedEvent.getRequest(); + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(request, response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { + final StringBuffer requestURL = request.getRequestURL(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader("Link", linkHeaderValue); + } + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java new file mode 100644 index 000000000000..f68cfb2eb7dc --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..352045989daa --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/resources/logback.xml b/spring-security-ldap/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-ldap/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-ldap/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..e5310da18704 --- /dev/null +++ b/spring-security-ldap/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..d6e8f7549aff --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..08183daa249f --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + Spring Security Basic Auth Application + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + + + \ No newline at end of file diff --git a/spring-security-ldap/src/test/resources/.gitignore b/spring-security-ldap/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-ldap/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 9c3ff77d8f76b23bb58a58bcc993d55c08d34130 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 10 Jun 2014 17:08:29 +0300 Subject: [PATCH 529/796] minor java testing work --- .../JavaCollectionCleanupUnitTest.java | 53 +++++++++++++++++ spring-security-rest/pom.xml | 58 +++++++++++++------ 2 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java new file mode 100644 index 000000000000..70befc6c19fc --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java @@ -0,0 +1,53 @@ +package org.baeldung.java.collections; + +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.PredicateUtils; +import org.junit.Test; + +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +public class JavaCollectionCleanupUnitTest { + + // removing nulls + + @Test + public final void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorrect() { + final List list = Lists.newArrayList(null, 1, null); + while (list.remove(null)) + ; + + assertThat(list, hasSize(1)); + } + + @Test + public final void givenListContainsNulls_whenRemovingNullsWithGuavaV1_thenCorrect() { + final List listWithNulls = Lists.newArrayList(null, 1, null); + Iterables.removeIf(listWithNulls, Predicates.isNull()); + + assertThat(listWithNulls, hasSize(1)); + } + + @Test + public final void givenListContainsNulls_whenRemovingNullsWithGuavaV2_thenCorrect() { + final List listWithNulls = Lists.newArrayList(null, 1, null, 2, 3); + final List listWithoutNulls = Lists.newArrayList(Iterables.filter(listWithNulls, Predicates.notNull())); + + assertThat(listWithoutNulls, hasSize(3)); + } + + @Test + public final void givenListContainsNulls_whenRemovingNullsWithCommonsCollections_thenCorrect() { + final List list = Lists.newArrayList(null, 1, 2, null, 3, null); + CollectionUtils.filter(list, PredicateUtils.notNullPredicate()); + + assertThat(list, hasSize(3)); + } + +} diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 5e1048071b3e..27e629e363e4 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -30,10 +30,10 @@ spring-core ${org.springframework.version} - - commons-logging - commons-logging - + + commons-logging + commons-logging + @@ -93,7 +93,7 @@ 1.2 runtime - + @@ -101,7 +101,7 @@ jackson-databind 2.2.2 - + @@ -114,7 +114,31 @@ commons-lang3 3.1 + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + @@ -157,16 +181,16 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + org.apache.maven.plugins maven-war-plugin @@ -247,7 +271,7 @@ 2.4 2.17 1.4.8 - +
\ No newline at end of file From ce42d596c179b2468044a72cc763429d13dd24a6 Mon Sep 17 00:00:00 2001 From: corsoft Date: Tue, 10 Jun 2014 19:34:55 +0100 Subject: [PATCH 530/796] updated gitignore --- .gitignore | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 0f182a0349c4..72f3338a99c1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,23 @@ *.jar *.war *.ear + + +# Eclipse +.classpath +.project +.settings/ +.prefs +*.prefs + +# Intellij +.idea/ +*.iml +*.iws + +# Mac +.DS_Store + +# Maven +log/ +target/ From 05593115393981650ba08e2c1f773be0089c94e3 Mon Sep 17 00:00:00 2001 From: corsoft Date: Wed, 11 Jun 2014 07:16:07 +0100 Subject: [PATCH 531/796] Created holder for ldap project (based on trimmed down basic auth project) --- .../persistence/service/FooService.java | 23 ------ .../baeldung/spring/PersistenceConfig.java | 14 ---- .../web/controller/FooController.java | 74 ------------------- .../org/baeldung/web/controller/LinkUtil.java | 30 -------- .../web/controller/ResourceCreated.java | 35 --------- ...esourceCreatedDiscoverabilityListener.java | 35 --------- .../controller/SingleResourceRetrieved.java | 29 -------- ...ourceRetrievedDiscoverabilityListener.java | 32 -------- .../web/controller/TestController.java | 28 ------- .../main/java/org/baeldung/web/dto/Foo.java | 11 --- .../src/main/webapp/WEB-INF/web.xml | 42 ----------- .../README.md | 0 .../pom.xml | 6 +- .../MyBasicAuthenticationEntryPoint.java | 0 .../java/org/baeldung/spring/MvcConfig.java | 0 .../baeldung/spring/SecSecurityConfig.java | 1 + .../java/org/baeldung/spring/WebConfig.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 36 +++++++++ .../src/test/resources/.gitignore | 0 23 files changed, 40 insertions(+), 356 deletions(-) delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java delete mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/web.xml rename {spring-security-ldap => spring-security-mvc-ldap}/README.md (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/pom.xml (98%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/MvcConfig.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (98%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/WebConfig.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/resources/logback.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) create mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml rename {spring-security-ldap => spring-security-mvc-ldap}/src/test/resources/.gitignore (100%) diff --git a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java deleted file mode 100644 index 02db7a733a6b..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.web.dto.Foo; -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - public FooService() { - super(); - } - - // API - - public Foo getById(final Long id) { - return null; - } - - public Long create(final Foo resource) { - return null; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java deleted file mode 100644 index 4ea0053f4845..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.persistence") -public class PersistenceConfig { - - public PersistenceConfig() { - super(); - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java deleted file mode 100644 index daa797ee368e..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.baeldung.persistence.service.FooService; -import org.baeldung.web.dto.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.util.UriComponentsBuilder; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; - -@Controller -@RequestMapping(value = "/foo") -public class FooController { - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Autowired - private FooService service; - - public FooController() { - super(); - } - - // API - - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - return new Foo(); - } - - @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); - - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); - return resourceById; - } - - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { - Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource); - - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); - } - - @RequestMapping(value = "admin", method = RequestMethod.GET) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { - final String rootUri = request.getRequestURL().toString(); - - final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); - final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); - response.addHeader("Link", linkToFoo); - } -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java deleted file mode 100644 index a41ebb5a5cdd..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletResponse; - -/** - * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object - */ -public final class LinkUtil { - - private LinkUtil() { - throw new AssertionError(); - } - - // - - /** - * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user - * - * @param uri - * the base uri - * @param rel - * the relative path - * - * @return the complete url - */ - public static String createLinkHeader(final String uri, final String rel) { - return "<" + uri + ">; rel=\"" + rel + "\""; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java deleted file mode 100644 index a67788810161..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class ResourceCreated extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - private final long idOfNewResource; - - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - super(source); - - this.request = request; - this.response = response; - this.idOfNewResource = idOfNewResource; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - - public long getIdOfNewResource() { - return idOfNewResource; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java deleted file mode 100644 index 8d19ef82fc63..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; -import com.google.common.net.HttpHeaders; - -@Component -class ResourceCreatedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { - Preconditions.checkNotNull(resourceCreatedEvent); - - final HttpServletRequest request = resourceCreatedEvent.getRequest(); - final HttpServletResponse response = resourceCreatedEvent.getResponse(); - final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); - - addLinkHeaderOnResourceCreation(request, response, idOfNewResource); - } - - void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - final String requestUrl = request.getRequestURL().toString(); - final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); - response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); - } - -} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java deleted file mode 100644 index 3de791810549..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class SingleResourceRetrieved extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { - super(source); - - this.request = request; - this.response = response; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java deleted file mode 100644 index 45cd7c4d131a..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -@Component -class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { - Preconditions.checkNotNull(resourceRetrievedEvent); - - final HttpServletRequest request = resourceRetrievedEvent.getRequest(); - final HttpServletResponse response = resourceRetrievedEvent.getResponse(); - addLinkHeaderOnSingleResourceRetrieval(request, response); - } - - void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { - final StringBuffer requestURL = request.getRequestURL(); - final int positionOfLastSlash = requestURL.lastIndexOf("/"); - final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); - - final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); - response.addHeader("Link", linkHeaderValue); - } - -} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java deleted file mode 100644 index f68cfb2eb7dc..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class TestController { - - public TestController() { - super(); - } - - // API - - @RequestMapping("/permitAll") - @ResponseBody - public String permitAll() { - return "Permit All"; - } - - @RequestMapping("/securityNone") - @ResponseBody - public String securityNone() { - return "Security None"; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java deleted file mode 100644 index 352045989daa..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.baeldung.web.dto; - -import java.io.Serializable; - -public class Foo implements Serializable { - - public Foo() { - super(); - } - -} diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 08183daa249f..000000000000 --- a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - Spring Security Basic Auth Application - - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - index.html - - - \ No newline at end of file diff --git a/spring-security-ldap/README.md b/spring-security-mvc-ldap/README.md similarity index 100% rename from spring-security-ldap/README.md rename to spring-security-mvc-ldap/README.md diff --git a/spring-security-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml similarity index 98% rename from spring-security-ldap/pom.xml rename to spring-security-mvc-ldap/pom.xml index 607ddf50d100..11e875a07158 100644 --- a/spring-security-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-ldap + spring-security-mvc-ldap 0.1-SNAPSHOT - spring-security-ldap + spring-security-mvc-ldap war @@ -159,7 +159,7 @@ - spring-security-mvc-basic-auth + spring-security-mvc-ldap src/main/resources diff --git a/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 98% rename from spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4ce80dab9f1c..9f0591d7dbb0 100644 --- a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -13,4 +13,5 @@ public SecSecurityConfig() { super(); } + } diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java diff --git a/spring-security-ldap/src/main/resources/logback.xml b/spring-security-mvc-ldap/src/main/resources/logback.xml similarity index 100% rename from spring-security-ldap/src/main/resources/logback.xml rename to spring-security-mvc-ldap/src/main/resources/logback.xml diff --git a/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-ldap/src/main/resources/webSecurityConfig.xml rename to spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..fe4d56026291 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + Spring Security Basic Auth Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + index.html + + \ No newline at end of file diff --git a/spring-security-ldap/src/test/resources/.gitignore b/spring-security-mvc-ldap/src/test/resources/.gitignore similarity index 100% rename from spring-security-ldap/src/test/resources/.gitignore rename to spring-security-mvc-ldap/src/test/resources/.gitignore From 0e97dc8605e77aa93f3061d93065980d2b8b2d6f Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 11 Jun 2014 12:39:01 +0300 Subject: [PATCH 532/796] quick cleanup work --- .../collections/JavaCollectionCleanupUnitTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java index 70befc6c19fc..c6aeb19730c7 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java @@ -28,16 +28,16 @@ public final void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorr @Test public final void givenListContainsNulls_whenRemovingNullsWithGuavaV1_thenCorrect() { - final List listWithNulls = Lists.newArrayList(null, 1, null); - Iterables.removeIf(listWithNulls, Predicates.isNull()); + final List list = Lists.newArrayList(null, 1, null); + Iterables.removeIf(list, Predicates.isNull()); - assertThat(listWithNulls, hasSize(1)); + assertThat(list, hasSize(1)); } @Test public final void givenListContainsNulls_whenRemovingNullsWithGuavaV2_thenCorrect() { - final List listWithNulls = Lists.newArrayList(null, 1, null, 2, 3); - final List listWithoutNulls = Lists.newArrayList(Iterables.filter(listWithNulls, Predicates.notNull())); + final List list = Lists.newArrayList(null, 1, null, 2, 3); + final List listWithoutNulls = Lists.newArrayList(Iterables.filter(list, Predicates.notNull())); assertThat(listWithoutNulls, hasSize(3)); } From 25a64f5d4ff5c6b93ede00f8d419bacb39ef3732 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 12 Jun 2014 20:42:20 +0300 Subject: [PATCH 533/796] java 8 new tests and quick maven upgrades --- core-java-8/pom.xml | 21 +++++----- .../java8/Java8CollectionCleanupUnitTest.java | 41 +++++++++++++++++++ .../org/baeldung/java8/Java8SortUnitTest.java | 1 - 3 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index 33585a5667ae..7968c2681088 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -14,7 +14,7 @@ com.google.guava guava - 16.0.1 + 17.0 @@ -26,7 +26,7 @@ org.apache.commons commons-lang3 - 3.1 + 3.3.2 @@ -111,35 +111,34 @@ 5.1.27 - 2.3.0 + 2.4.0 1.7.5 1.0.11 - 5.0.1.Final + 5.1.1.Final - 15.0 - 3.1 + 17.0 + 3.3.2 1.3 4.11 1.9.5 - 4.3 - 4.3.1 + 4.3.2 + 4.3.4 - 2.1.0 + 2.3.2 3.1 2.4 - 2.16 + 2.17 2.6 - 1.4.5 diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java new file mode 100644 index 000000000000..acca829b7864 --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java @@ -0,0 +1,41 @@ +package org.baeldung.java8; + +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; + +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class Java8CollectionCleanupUnitTest { + + // tests - + + @Test + public void givenListContainsNulls_whenFilteringParallel_thenCorrect() { + final List list = Lists.newArrayList(null, 1, 2, null, 3, null); + final List listWithoutNulls = list.parallelStream().filter(i -> i != null).collect(Collectors.toList()); + + assertThat(listWithoutNulls, hasSize(3)); + } + + @Test + public void givenListContainsNulls_whenFilteringSerial_thenCorrect() { + final List list = Lists.newArrayList(null, 1, 2, null, 3, null); + final List listWithoutNulls = list.stream().filter(i -> i != null).collect(Collectors.toList()); + + assertThat(listWithoutNulls, hasSize(3)); + } + + @Test + public void givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() { + final List listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3); + final List listWithoutDuplicates = listWithDuplicates.parallelStream().distinct().collect(Collectors.toList()); + + assertThat(listWithoutDuplicates, hasSize(3)); + } + +} diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java index 5398198a7b9d..f6b89dd4c9a0 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java @@ -1,6 +1,5 @@ package org.baeldung.java8; -import static org.baeldung.java8.entity.Human.compareByNameThenAge; import static org.hamcrest.Matchers.equalTo; import java.util.Collections; From 809554dd443544b297f50d5f2c5db44f0bbf6c83 Mon Sep 17 00:00:00 2001 From: corsoft Date: Fri, 13 Jun 2014 07:24:22 +0100 Subject: [PATCH 534/796] LDAP working - MVC needs fixing --- spring-security-mvc-ldap/pom.xml | 63 +++++++++++++++++-- .../baeldung/controller/HomeController.java | 15 +++++ .../MyBasicAuthenticationEntryPoint.java | 31 --------- .../java/org/baeldung/spring/Application.java | 17 +++++ .../java/org/baeldung/spring/MvcConfig.java | 39 ------------ .../baeldung/spring/SecSecurityConfig.java | 17 ----- .../org/baeldung/spring/SecurityConfig.java | 29 +++++++++ .../java/org/baeldung/spring/WebConfig.java | 17 ----- .../src/main/resources/users.ldif | 14 +++++ .../src/main/resources/webSecurityConfig.xml | 11 +++- 10 files changed, 142 insertions(+), 111 deletions(-) create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-mvc-ldap/src/main/resources/users.ldif diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 11e875a07158..57af0f1d48a6 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -7,11 +7,16 @@ spring-security-mvc-ldap war + + + org.springframework.boot + spring-boot-starter-parent + 1.1.1.RELEASE + - org.springframework.security spring-security-web @@ -30,10 +35,10 @@ spring-core ${org.springframework.version} - - commons-logging - commons-logging - + + commons-logging + commons-logging + @@ -78,6 +83,52 @@ ${org.springframework.version} + + + + + org.springframework.boot + spring-boot-starter-web + 1.1.1.RELEASE + + + + org.springframework.security + spring-security-ldap + 3.2.4.RELEASE + + + + org.springframework.ldap + spring-ldap-core + 2.0.2.RELEASE + + + org.springframework.ldap + spring-ldap-core-tiger + 2.0.2.RELEASE + + + + + org.apache.directory.server + apacheds-server-jndi + 1.5.5 + + + + commons-collections + commons-collections + 3.2.1 + + + org.apache.mina + mina-core + 2.0.7 + + + + @@ -126,7 +177,7 @@ log4j-over-slf4j ${org.slf4j.version} - + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java new file mode 100644 index 000000000000..7d9a8365009f --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java @@ -0,0 +1,15 @@ +package org.baeldung.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class HomeController { + + @RequestMapping("/homepage.html") + public @ResponseBody String index() { + return "homepage"; + } +} + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java deleted file mode 100644 index 968237227f63..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.security.basic; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; -import org.springframework.stereotype.Component; - -@Component -public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { - - @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - final PrintWriter writer = response.getWriter(); - writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); - } - - @Override - public void afterPropertiesSet() throws Exception { - setRealmName("Baeldung"); - super.afterPropertiesSet(); - } - -} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java new file mode 100644 index 000000000000..6d0621e3dde6 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +@EnableAutoConfiguration +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java deleted file mode 100644 index 74c11478ee2e..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@Configuration -@EnableWebMvc -public class MvcConfig extends WebMvcConfigurerAdapter { - - public MvcConfig() { - super(); - } - - // API - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/homepage.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java deleted file mode 100644 index 9f0591d7dbb0..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; - -@Configuration -@ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.security") -public class SecSecurityConfig { - - public SecSecurityConfig() { - super(); - } - - -} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java new file mode 100644 index 000000000000..026afa114a9e --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java @@ -0,0 +1,29 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; + +@Configuration +@EnableWebMvcSecurity +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) + throws Exception { + + auth.ldapAuthentication() + .userSearchBase("ou=people") + .userSearchFilter("(uid={0})") + .groupSearchBase("ou=groups") + .groupSearchFilter("member={0}") + .contextSource() + .root("dc=baeldung,dc=com") + .ldif("classpath:users.ldif"); + + } + + + +} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java deleted file mode 100644 index fa6f5f6d5626..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@ComponentScan("org.baeldung.web") -public class WebConfig extends WebMvcConfigurerAdapter { - - public WebConfig() { - super(); - } - - // API - -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/users.ldif b/spring-security-mvc-ldap/src/main/resources/users.ldif new file mode 100644 index 000000000000..59712d59e12f --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/users.ldif @@ -0,0 +1,14 @@ +dn: ou=people,dc=baeldung,dc=com +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=baeldung,ou=people,dc=baeldung,dc=com +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: David Lightman +sn: Lightman +uid: baeldung +userPassword: password \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml index e5310da18704..67db0dba6dd0 100644 --- a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml @@ -13,6 +13,9 @@ + + + + + + + \ No newline at end of file From 9ea4563680aacf7ad94830355aad6d2a5a824639 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 14 Jun 2014 13:10:36 +0300 Subject: [PATCH 535/796] moving some tests to individual packages to clean up the structure --- httpclient/pom.xml | 12 ++++++------ .../HttpClientConnectionManagementTest.java | 5 +++++ .../{ => base}/HttpClientBasicLiveTest.java | 2 +- .../{ => base}/HttpClientBasicPostLiveTest.java | 2 +- .../httpclient/{ => base}/HttpClientLiveTest.java | 2 +- .../{ => base}/HttpClientSandboxLiveTest.java | 2 +- .../{ => rare}/HttpClientUnshortenLiveTest.java | 2 +- .../httpclient/{ => sec}/HttpClientAuthLiveTest.java | 2 +- .../{ => sec}/HttpClientCookieLiveTest.java | 2 +- 9 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java rename httpclient/src/test/java/org/baeldung/httpclient/{ => base}/HttpClientBasicLiveTest.java (98%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => base}/HttpClientBasicPostLiveTest.java (98%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => base}/HttpClientLiveTest.java (99%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => base}/HttpClientSandboxLiveTest.java (98%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => rare}/HttpClientUnshortenLiveTest.java (99%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => sec}/HttpClientAuthLiveTest.java (99%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => sec}/HttpClientCookieLiveTest.java (99%) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 17675efcea2f..a4ec3efaa0a0 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -45,13 +45,13 @@ org.apache.httpcomponents fluent-hc - 4.3.3 + ${httpclient.version} org.apache.httpcomponents httpmime - 4.3.3 + ${httpclient.version} @@ -157,8 +157,8 @@ 5.1.30 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 5.1.1.Final @@ -173,9 +173,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.4 - 2.3.1 + 2.3.2 3.1 diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java new file mode 100644 index 000000000000..a761338738bf --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -0,0 +1,5 @@ +package org.baeldung.httpclient; + +public class HttpClientConnectionManagementTest { + // +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java index 10f0b9e149da..2a101ec81623 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.base; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java index 3dd4a988b04a..7eb078b18be6 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientBasicPostLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.base; import java.io.IOException; import java.io.InputStream; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java index 3a54b7e1b84e..23c1fdf43094 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.base; import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.not; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index d8e687df1b5b..ff2f1cd194f1 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.base; import java.io.IOException; import java.io.InputStream; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java index 7eef1cade88c..8fd61664a2e3 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientUnshortenLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.rare; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java index 65aa059e6241..2f9a2a60588a 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientAuthLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.sec; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java index 3cca95b7bc45..a36569a34bb1 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientCookieLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.sec; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; From 1f02eeaa2a417ddc4e61dc1134c2b070fc5171e3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 14 Jun 2014 20:52:50 +0300 Subject: [PATCH 536/796] new configuration work --- .../HttpClientConnectionManagementTest.java | 19 ++++++++++++++++++- .../baeldung/spring/PersistenceConfig.java | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java index a761338738bf..3a54dfb9ec37 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -1,5 +1,22 @@ package org.baeldung.httpclient; +import org.apache.http.HttpHost; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.conn.ConnectionRequest; +import org.apache.http.conn.routing.HttpRoute; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.junit.Test; + public class HttpClientConnectionManagementTest { - // + + // tests + + @Test + public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() { + final HttpClientContext context = HttpClientContext.create(); + final BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager(); + final HttpRoute route = new HttpRoute(new HttpHost("localhost", 80)); + final ConnectionRequest connRequest = connManager.requestConnection(route, null); + } + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java index 160650afaf43..dad4808a563e 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -23,7 +23,7 @@ @Configuration @EnableTransactionManagement -@PropertySource({ "classpath:persistence-mysql.properties" }) +@PropertySource({ "classpath:persistence-${envTarget:mysql}.properties" }) @ComponentScan({ "org.baeldung.persistence" }) // @ImportResource("classpath*:springDataPersistenceConfig.xml") @EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") From 81d63f1dccdfbabde94e8cdadce86147c956b2a8 Mon Sep 17 00:00:00 2001 From: corsoft Date: Sun, 15 Jun 2014 13:17:38 +0100 Subject: [PATCH 537/796] Working version - LDAP + Spring Boot --- spring-security-mvc-ldap/pom.xml | 276 ++---------------- .../org/baeldung/SampleLDAPApplication.java | 27 ++ .../baeldung/controller/HomeController.java | 15 - .../org/baeldung/controller/MyController.java | 74 +++++ .../org/baeldung/security/SecurityConfig.java | 51 ++++ .../java/org/baeldung/spring/Application.java | 17 -- .../org/baeldung/spring/SecurityConfig.java | 29 -- .../src/main/resources/logback.xml | 4 +- .../resources/static/css/bootstrap.min.css | 13 + .../src/main/resources/templates/error.html | 32 ++ .../src/main/resources/templates/home.html | 37 +++ .../src/main/resources/templates/login.html | 36 +++ .../src/main/resources/users.ldif | 23 +- .../src/main/resources/webSecurityConfig.xml | 34 --- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 - .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 - .../src/main/webapp/WEB-INF/web.xml | 36 --- 17 files changed, 310 insertions(+), 406 deletions(-) create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java create mode 100644 spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/error.html create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/home.html create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/login.html delete mode 100644 spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 57af0f1d48a6..12353021f0e3 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -7,7 +7,7 @@ spring-security-mvc-ldap war - + org.springframework.boot spring-boot-starter-parent @@ -16,88 +16,23 @@ - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - + - org.springframework - spring-web - ${org.springframework.version} + org.springframework.boot + spring-boot-starter-security - org.springframework - spring-webmvc - ${org.springframework.version} + org.springframework.boot + spring-boot-starter-thymeleaf - - - + - org.springframework.boot - spring-boot-starter-web - 1.1.1.RELEASE + org.springframework.security + spring-security-ldap + 3.2.4.RELEASE - - org.springframework.security - spring-security-ldap - 3.2.4.RELEASE - - org.springframework.ldap spring-ldap-core @@ -108,103 +43,17 @@ spring-ldap-core-tiger 2.0.2.RELEASE - - - - org.apache.directory.server - apacheds-server-jndi - 1.5.5 - - - - commons-collections - commons-collections - 3.2.1 - - - org.apache.mina - mina-core - 2.0.7 - - - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - 14.0.1 - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test + + org.apache.directory.server + apacheds-server-jndi + 1.5.5 - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test + org.apache.mina + mina-core + 2.0.7 @@ -217,100 +66,9 @@ true - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - 4.0.5.RELEASE - 3.2.4.RELEASE - - - 4.3.5.Final - 5.1.30 - - - 1.7.6 - 1.1.1 - - - 5.1.1.Final - - - 17.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.3 - - 2.3.1 - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.8 diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java new file mode 100644 index 000000000000..8bbf97de8fc2 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java @@ -0,0 +1,27 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +/** + * Main Application Class - uses Spring Boot. Just run this as a normal Java + * class to run up a Jetty Server (on http://localhost:8080) + * + */ +@EnableAutoConfiguration +@ComponentScan("org.baeldung") +public class SampleLDAPApplication extends WebMvcConfigurerAdapter { + + public static void main(String[] args) { + SpringApplication.run(SampleLDAPApplication.class, args); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/login").setViewName("login"); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java deleted file mode 100644 index 7d9a8365009f..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.baeldung.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class HomeController { - - @RequestMapping("/homepage.html") - public @ResponseBody String index() { - return "homepage"; - } -} - diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java new file mode 100644 index 000000000000..f65cf0493920 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java @@ -0,0 +1,74 @@ +package org.baeldung.controller; + +import java.security.Principal; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Spring Controller Definitions. + */ +@Controller +public class MyController { + + @RequestMapping("/") + public String init(Map model, Principal principal) { + model.put("title", "PUBLIC AREA"); + model.put("message", "Any user can view this page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } + + @RequestMapping("/secure") + public String secure(Map model, Principal principal) { + model.put("title", "SECURE AREA"); + model.put("message", "Only Authorised Users Can See This Page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } + + private String getUserName(Principal principal){ + + if(principal == null){ + return "anonymous"; + }else{ + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for(GrantedAuthority grantedAuthority : authorities) { + System.out.println(grantedAuthority.getAuthority()); + } + return principal.getName(); + } + } + + private Collection getUserRoles(Principal principal){ + + if(principal == null){ + return Arrays.asList("none"); + }else{ + + Set roles = new HashSet(); + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for(GrantedAuthority grantedAuthority : authorities) { + roles.add(grantedAuthority.getAuthority()); + } + return roles; + } + } + +} + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java new file mode 100644 index 000000000000..97bbaf83027c --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java @@ -0,0 +1,51 @@ +package org.baeldung.security; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.stereotype.Controller; + +/** + * Security Configuration - LDAP and HTTP Authorizations. + */ +@EnableAutoConfiguration +@ComponentScan +@Controller +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) + throws Exception { + + auth.ldapAuthentication() + .userSearchBase("ou=people") + .userSearchFilter("(uid={0})") + .groupSearchBase("ou=groups") + .groupSearchFilter("member={0}") + .contextSource() + .root("dc=baeldung,dc=com") + .ldif("classpath:users.ldif"); + + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http + .authorizeRequests() + .antMatchers("/", "/home").permitAll() + .anyRequest().authenticated(); + http + .formLogin() + .loginPage("/login") + .permitAll() + .and() + .logout() + .logoutSuccessUrl("/"); + + + } + +} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java deleted file mode 100644 index 6d0621e3dde6..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan -@EnableAutoConfiguration -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java deleted file mode 100644 index 026afa114a9e..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; - -@Configuration -@EnableWebMvcSecurity -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(AuthenticationManagerBuilder auth) - throws Exception { - - auth.ldapAuthentication() - .userSearchBase("ou=people") - .userSearchFilter("(uid={0})") - .groupSearchBase("ou=groups") - .groupSearchFilter("member={0}") - .contextSource() - .root("dc=baeldung,dc=com") - .ldif("classpath:users.ldif"); - - } - - - -} diff --git a/spring-security-mvc-ldap/src/main/resources/logback.xml b/spring-security-mvc-ldap/src/main/resources/logback.xml index 1146dade632e..2dc76c96f305 100644 --- a/spring-security-mvc-ldap/src/main/resources/logback.xml +++ b/spring-security-mvc-ldap/src/main/resources/logback.xml @@ -10,9 +10,11 @@ - + + + diff --git a/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css b/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css new file mode 100644 index 000000000000..6e7c69f08876 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css @@ -0,0 +1,13 @@ +/*! + * Bootstrap v2.0.4 + * + * Copyright 2012 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world @twitter by @mdo and @fat. + */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.127659574%;*margin-left:2.0744680846382977%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.99999998999999%;*width:99.94680850063828%}.row-fluid .span11{width:91.489361693%;*width:91.4361702036383%}.row-fluid .span10{width:82.97872339599999%;*width:82.92553190663828%}.row-fluid .span9{width:74.468085099%;*width:74.4148936096383%}.row-fluid .span8{width:65.95744680199999%;*width:65.90425531263828%}.row-fluid .span7{width:57.446808505%;*width:57.3936170156383%}.row-fluid .span6{width:48.93617020799999%;*width:48.88297871863829%}.row-fluid .span5{width:40.425531911%;*width:40.3723404216383%}.row-fluid .span4{width:31.914893614%;*width:31.8617021246383%}.row-fluid .span3{width:23.404255317%;*width:23.3510638276383%}.row-fluid .span2{width:14.89361702%;*width:14.8404255306383%}.row-fluid .span1{width:6.382978723%;*width:6.329787233638298%}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;content:""}.container-fluid:after{clear:both}p{margin:0 0 9px}p small{font-size:11px;color:#999}.lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px}h1,h2,h3,h4,h5,h6{margin:0;font-family:inherit;font-weight:bold;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{font-size:18px;line-height:27px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}.page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eee}.page-header h1{line-height:1}ul,ol{padding:0;margin:0 0 9px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}ul{list-style:disc}ol{list-style:decimal}li{line-height:18px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}dl{margin-bottom:18px}dt,dd{line-height:18px}dt{font-weight:bold;line-height:17px}dd{margin-left:9px}.dl-horizontal dt{float:left;width:120px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:130px}hr{margin:18px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}strong{font-weight:bold}em{font-style:italic}.muted{color:#999}abbr[title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px}blockquote small{display:block;line-height:18px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:18px;font-style:normal;line-height:18px}small{font-size:100%}cite{font-style:normal}code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:8.5px;margin:0 0 9px;font-size:12.025px;line-height:18px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:18px}pre code{padding:0;color:inherit;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 18px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:27px;font-size:19.5px;line-height:36px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:13.5px;color:#999}label,input,button,select,textarea{font-size:13px;font-weight:normal;line-height:18px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:18px;padding:4px;margin-bottom:9px;font-size:13px;line-height:18px;color:#555}input,textarea{width:210px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-ms-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:3px 0;*margin-top:0;line-height:normal;cursor:pointer}input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}.uneditable-textarea{width:auto;height:auto}select,input[type="file"]{height:28px;*margin-top:4px;line-height:28px}select{width:220px;border:1px solid #bbb}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.radio,.checkbox{min-height:18px;padding-left:18px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-18px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:930px}input.span11,textarea.span11,.uneditable-input.span11{width:850px}input.span10,textarea.span10,.uneditable-input.span10{width:770px}input.span9,textarea.span9,.uneditable-input.span9{width:690px}input.span8,textarea.span8,.uneditable-input.span8{width:610px}input.span7,textarea.span7,.uneditable-input.span7{width:530px}input.span6,textarea.span6,.uneditable-input.span6{width:450px}input.span5,textarea.span5,.uneditable-input.span5{width:370px}input.span4,textarea.span4,.uneditable-input.span4{width:290px}input.span3,textarea.span3,.uneditable-input.span3{width:210px}input.span2,textarea.span2,.uneditable-input.span2{width:130px}input.span1,textarea.span1,.uneditable-input.span1{width:50px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee;border-color:#ddd}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning>label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;border-color:#c09853}.control-group.warning .checkbox:focus,.control-group.warning .radio:focus,.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:0 0 6px #dbc59e;-moz-box-shadow:0 0 6px #dbc59e;box-shadow:0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error>label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;border-color:#b94a48}.control-group.error .checkbox:focus,.control-group.error .radio:focus,.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:0 0 6px #d59392;-moz-box-shadow:0 0 6px #d59392;box-shadow:0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success>label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;border-color:#468847}.control-group.success .checkbox:focus,.control-group.success .radio:focus,.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:0 0 6px #7aba7b;-moz-box-shadow:0 0 6px #7aba7b;box-shadow:0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}input:focus:required:invalid,textarea:focus:required:invalid,select:focus:required:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:required:invalid:focus,textarea:focus:required:invalid:focus,select:focus:required:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:17px 20px 18px;margin-top:18px;margin-bottom:18px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;content:""}.form-actions:after{clear:both}.uneditable-input{overflow:hidden;white-space:nowrap;cursor:not-allowed;background-color:#fff;border-color:#eee;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}:-moz-placeholder{color:#999}:-ms-input-placeholder{color:#999}::-webkit-input-placeholder{color:#999}.help-block,.help-inline{color:#555}.help-block{display:block;margin-bottom:9px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-prepend,.input-append{margin-bottom:5px}.input-prepend input,.input-append input,.input-prepend select,.input-append select,.input-prepend .uneditable-input,.input-append .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:middle;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend input:focus,.input-append input:focus,.input-prepend select:focus,.input-append select:focus,.input-prepend .uneditable-input:focus,.input-append .uneditable-input:focus{z-index:2}.input-prepend .uneditable-input,.input-append .uneditable-input{border-left-color:#ccc}.input-prepend .add-on,.input-append .add-on{display:inline-block;width:auto;height:18px;min-width:16px;padding:4px 5px;font-weight:normal;line-height:18px;text-align:center;text-shadow:0 1px 0 #fff;vertical-align:middle;background-color:#eee;border:1px solid #ccc}.input-prepend .add-on,.input-append .add-on,.input-prepend .btn,.input-append .btn{margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend .active,.input-append .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append .uneditable-input{border-right-color:#ccc;border-left-color:#eee}.input-append .add-on:last-child,.input-append .btn:last-child{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:14px;-moz-border-radius:14px;border-radius:14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:9px}legend+.control-group{margin-top:18px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:18px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:140px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:160px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:160px}.form-horizontal .help-block{margin-top:9px;margin-bottom:0}.form-horizontal .form-actions{padding-left:160px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:18px}.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapsed;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5}table .span1{float:none;width:44px;margin-left:0}table .span2{float:none;width:124px;margin-left:0}table .span3{float:none;width:204px;margin-left:0}table .span4{float:none;width:284px;margin-left:0}table .span5{float:none;width:364px;margin-left:0}table .span6{float:none;width:444px;margin-left:0}table .span7{float:none;width:524px;margin-left:0}table .span8{float:none;width:604px;margin-left:0}table .span9{float:none;width:684px;margin-left:0}table .span10{float:none;width:764px;margin-left:0}table .span11{float:none;width:844px;margin-left:0}table .span12{float:none;width:924px;margin-left:0}table .span13{float:none;width:1004px;margin-left:0}table .span14{float:none;width:1084px;margin-left:0}table .span15{float:none;width:1164px;margin-left:0}table .span16{float:none;width:1244px;margin-left:0}table .span17{float:none;width:1324px;margin-left:0}table .span18{float:none;width:1404px;margin-left:0}table .span19{float:none;width:1484px;margin-left:0}table .span20{float:none;width:1564px;margin-left:0}table .span21{float:none;width:1644px;margin-left:0}table .span22{float:none;width:1724px;margin-left:0}table .span23{float:none;width:1804px;margin-left:0}table .span24{float:none;width:1884px;margin-left:0}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}[class^="icon-"]:last-child,[class*=" icon-"]:last-child{*margin-left:0}.icon-white{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{background-position:-384px -120px}.icon-folder-open{background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:"";opacity:.3;filter:alpha(opacity=30)}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown:hover .caret,.open .caret{opacity:1;filter:alpha(opacity=100)}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:4px 0;margin:1px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu a{display:block;padding:3px 15px;clear:both;font-weight:normal;line-height:18px;color:#333;white-space:nowrap}.dropdown-menu li>a:hover,.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#fff;text-decoration:none;background-color:#08c}.open{*z-index:1000}.open>.dropdown-menu{display:block}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:"\2191"}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.typeahead{margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #eee;border:1px solid rgba(0,0,0,0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-ms-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-ms-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 10px 4px;margin-bottom:0;*margin-left:.3em;font-size:13px;line-height:18px;*line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-ms-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(top,#fff,#e6e6e6);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #ccc;*border:0;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;*background-color:#d9d9d9;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-ms-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-color:#e6e6e6;background-color:#d9d9d9 \9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-color:#e6e6e6;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.btn-large [class^="icon-"]{margin-top:1px}.btn-small{padding:5px 9px;font-size:11px;line-height:16px}.btn-small [class^="icon-"]{margin-top:-1px}.btn-mini{padding:2px 6px;font-size:11px;line-height:14px}.btn-primary,.btn-primary:hover,.btn-warning,.btn-warning:hover,.btn-danger,.btn-danger:hover,.btn-success,.btn-success:hover,.btn-info,.btn-info:hover,.btn-inverse,.btn-inverse:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#ccc;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn-primary{background-color:#0074cc;*background-color:#05c;background-image:-ms-linear-gradient(top,#08c,#05c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#05c));background-image:-webkit-linear-gradient(top,#08c,#05c);background-image:-o-linear-gradient(top,#08c,#05c);background-image:-moz-linear-gradient(top,#08c,#05c);background-image:linear-gradient(top,#08c,#05c);background-repeat:repeat-x;border-color:#05c #05c #003580;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#0088cc',endColorstr='#0055cc',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{background-color:#05c;*background-color:#004ab3}.btn-primary:active,.btn-primary.active{background-color:#004099 \9}.btn-warning{background-color:#faa732;*background-color:#f89406;background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{background-color:#da4f49;*background-color:#bd362f;background-image:-ms-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(top,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#bd362f',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{background-color:#5bb75b;*background-color:#51a351;background-image:-ms-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(top,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#51a351',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{background-color:#49afcd;*background-color:#2f96b4;background-image:-ms-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(top,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#2f96b4',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{background-color:#414141;*background-color:#222;background-image:-ms-linear-gradient(top,#555,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#222));background-image:-webkit-linear-gradient(top,#555,#222);background-image:-o-linear-gradient(top,#555,#222);background-image:-moz-linear-gradient(top,#555,#222);background-image:linear-gradient(top,#555,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#555555',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-group{position:relative;*margin-left:.3em;*zoom:1}.btn-group:before,.btn-group:after{display:table;content:""}.btn-group:after{clear:both}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:9px;margin-bottom:9px}.btn-toolbar .btn-group{display:inline-block;*display:inline;*zoom:1}.btn-group>.btn{position:relative;float:left;margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.dropdown-toggle{*padding-top:4px;padding-right:8px;*padding-bottom:4px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini.dropdown-toggle{padding-right:5px;padding-left:5px}.btn-group>.btn-small.dropdown-toggle{*padding-top:4px;*padding-bottom:4px}.btn-group>.btn-large.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#05c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:7px;margin-left:0}.btn:hover .caret,.open.btn-group .caret{opacity:1;filter:alpha(opacity=100)}.btn-mini .caret{margin-top:5px}.btn-small .caret{margin-top:6px}.btn-large .caret{margin-top:6px;border-top-width:5px;border-right-width:5px;border-left-width:5px}.dropup .btn-large .caret{border-top:0;border-bottom:5px solid #000}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:.75;filter:alpha(opacity=75)}.alert{padding:8px 35px 8px 14px;margin-bottom:18px;color:#c09853;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert-heading{color:inherit}.alert .close{position:relative;top:-2px;right:-21px;line-height:18px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:18px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>.pull-right{float:right}.nav .nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:18px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:18px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.nav-tabs.nav-stacked>li>a:hover{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px}.nav-pills .dropdown-menu{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-tabs .dropdown-toggle .caret,.nav-pills .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav-tabs .dropdown-toggle:hover .caret,.nav-pills .dropdown-toggle:hover .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .active .dropdown-toggle .caret,.nav-pills .active .dropdown-toggle .caret{border-top-color:#333;border-bottom-color:#333}.nav>.dropdown.active>a:hover{color:#000;cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.navbar{*position:relative;*z-index:2;margin-bottom:18px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#2c2c2c;background-image:-moz-linear-gradient(top,#333,#222);background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)}.navbar .container{width:auto}.nav-collapse.collapse{height:auto}.navbar{color:#999}.navbar .brand:hover{text-decoration:none}.navbar .brand{display:block;float:left;padding:8px 20px 12px;margin-left:-20px;font-size:20px;font-weight:200;line-height:1;color:#999}.navbar .navbar-text{margin-bottom:0;line-height:40px}.navbar .navbar-link{color:#999}.navbar .navbar-link:hover{color:#fff}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn{margin:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:6px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:6px;margin-bottom:0}.navbar-search .search-query{padding:4px 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;color:#fff;background-color:#626262;border:1px solid #151515;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none}.navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-search .search-query:focus,.navbar-search .search-query.focused{padding:5px 10px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-bottom{bottom:0}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right}.navbar .nav>li{display:block;float:left}.navbar .nav>li>a{float:none;padding:9px 10px 11px;line-height:19px;color:#999;text-decoration:none;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar .btn{display:inline-block;padding:4px 10px 4px;margin:5px 5px 6px;line-height:18px}.navbar .btn-group{padding:5px 5px 6px;margin:0}.navbar .nav>li>a:hover{color:#fff;text-decoration:none;background-color:transparent}.navbar .nav .active>a,.navbar .nav .active>a:hover{color:#fff;text-decoration:none;background-color:#222}.navbar .divider-vertical{width:1px;height:40px;margin:0 9px;overflow:hidden;background-color:#222;border-right:1px solid #333}.navbar .nav.pull-right{margin-right:0;margin-left:10px}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;background-color:#2c2c2c;*background-color:#222;background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-image:-moz-linear-gradient(top,#333,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{background-color:#222;*background-color:#151515}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#080808 \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown .dropdown-toggle .caret,.navbar .nav li.dropdown.open .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar .nav li.dropdown.active .caret{opacity:1;filter:alpha(opacity=100)}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{background-color:transparent}.navbar .nav li.dropdown.active>.dropdown-toggle:hover{color:#fff}.navbar .pull-right .dropdown-menu,.navbar .dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right .dropdown-menu:before,.navbar .dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right .dropdown-menu:after,.navbar .dropdown-menu.pull-right:after{right:13px;left:auto}.breadcrumb{padding:7px 14px;margin:0 0 18px;list-style:none;background-color:#fbfbfb;background-image:-moz-linear-gradient(top,#fff,#f5f5f5);background-image:-ms-linear-gradient(top,#fff,#f5f5f5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f5f5f5));background-image:-webkit-linear-gradient(top,#fff,#f5f5f5);background-image:-o-linear-gradient(top,#fff,#f5f5f5);background-image:linear-gradient(top,#fff,#f5f5f5);background-repeat:repeat-x;border:1px solid #ddd;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#f5f5f5',GradientType=0);-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.breadcrumb li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb .divider{padding:0 5px;color:#999}.breadcrumb .active a{color:#333}.pagination{height:36px;margin:18px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination li{display:inline}.pagination a{float:left;padding:0 14px;line-height:34px;text-decoration:none;border:1px solid #ddd;border-left-width:0}.pagination a:hover,.pagination .active a{background-color:#f5f5f5}.pagination .active a{color:#999;cursor:default}.pagination .disabled span,.pagination .disabled a,.pagination .disabled a:hover{color:#999;cursor:default;background-color:transparent}.pagination li:first-child a{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.pagination li:last-child a{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pager{margin-bottom:18px;margin-left:0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;content:""}.pager:after{clear:both}.pager li{display:inline}.pager a{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager a:hover{text-decoration:none;background-color:#f5f5f5}.pager .next a{float:right}.pager .previous a{float:left}.pager .disabled a,.pager .disabled a:hover{color:#999;cursor:default;background-color:#fff}.modal-open .dropdown-menu{z-index:2050}.modal-open .dropdown.open{*z-index:2050}.modal-open .popover{z-index:2060}.modal-open .tooltip{z-index:2070}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:50%;left:50%;z-index:1050;width:560px;margin:-250px 0 0 -280px;overflow:auto;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-ms-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:50%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-body{max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.tooltip{position:absolute;z-index:1020;display:block;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{margin-top:-2px}.tooltip.right{margin-left:2px}.tooltip.bottom{margin-top:2px}.tooltip.left{margin-left:-2px}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px}.popover.top{margin-top:-5px}.popover.right{margin-left:5px}.popover.bottom{margin-top:5px}.popover.left{margin-left:-5px}.popover.top .arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.popover.bottom .arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.popover .arrow{position:absolute;width:0;height:0}.popover-inner{width:280px;padding:3px;overflow:hidden;background:#000;background:rgba(0,0,0,0.8);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.popover-title{padding:9px 15px;line-height:1;background-color:#f5f5f5;border-bottom:1px solid #eee;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.popover-content{padding:14px;background-color:#fff;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:18px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:1;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.075);box-shadow:0 1px 1px rgba(0,0,0,0.075)}a.thumbnail:hover{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px}.label,.badge{font-size:10.998px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{padding:1px 4px 2px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding:1px 9px 2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}a.label:hover,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:18px;margin-bottom:18px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-ms-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(top,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5',endColorstr='#f9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{width:0;height:18px;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(top,#149bdf,#0480be);background-image:-ms-linear-gradient(top,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#149bdf',endColorstr='#0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-ms-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-striped .bar{background-color:#149bdf;background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-ms-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(top,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#c43c35',GradientType=0)}.progress-danger.progress-striped .bar{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-ms-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(top,#62c462,#57a957);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#57a957',GradientType=0)}.progress-success.progress-striped .bar{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-ms-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(top,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#339bb9',GradientType=0)}.progress-info.progress-striped .bar{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0)}.progress-warning.progress-striped .bar{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:18px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:18px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel .item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-ms-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel .item>img{display:block;line-height:1}.carousel .active,.carousel .next,.carousel .prev{display:block}.carousel .active{left:0}.carousel .next,.carousel .prev{position:absolute;top:0;width:100%}.carousel .next{left:100%}.carousel .prev{left:-100%}.carousel .next.left,.carousel .prev.right{left:0}.carousel .active.left{left:-100%}.carousel .active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:10px 15px 5px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{color:#fff}.hero-unit{padding:60px;margin-bottom:30px;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit p{font-size:18px;font-weight:200;line-height:27px;color:inherit}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden} + + input.field-error, textarea.field-error { border: 1px solid #B94A48; } + + #footer { border-top: 1px solid #000000; } \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/templates/error.html b/spring-security-mvc-ldap/src/main/resources/templates/error.html new file mode 100644 index 000000000000..a75936a24a52 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/error.html @@ -0,0 +1,32 @@ + + + +Error + + + +
+ +

+
+
+ There was an unexpected error (type=Bad, status=500). +
+
Fake content
+
+ Please contact the operator with the above information. +
+ +
+ + diff --git a/spring-security-mvc-ldap/src/main/resources/templates/home.html b/spring-security-mvc-ldap/src/main/resources/templates/home.html new file mode 100644 index 000000000000..2632a3bb93c4 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/home.html @@ -0,0 +1,37 @@ + + + +Title + + + +
+ + + + +
+

+

+

+

+
+ + +
+ + diff --git a/spring-security-mvc-ldap/src/main/resources/templates/login.html b/spring-security-mvc-ldap/src/main/resources/templates/login.html new file mode 100644 index 000000000000..e3a18c2e486a --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/login.html @@ -0,0 +1,36 @@ + + + +Login + + + +
+ +
+

You have been logged out

+

There was an error, please try again

+

Login with Username and Password

+
+
+ + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/users.ldif b/spring-security-mvc-ldap/src/main/resources/users.ldif index 59712d59e12f..228237da0598 100644 --- a/spring-security-mvc-ldap/src/main/resources/users.ldif +++ b/spring-security-mvc-ldap/src/main/resources/users.ldif @@ -1,3 +1,8 @@ +dn: ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: organizationalUnit +ou: groups + dn: ou=people,dc=baeldung,dc=com objectclass: top objectclass: organizationalUnit @@ -8,7 +13,19 @@ objectclass: top objectclass: person objectclass: organizationalPerson objectclass: inetOrgPerson -cn: David Lightman -sn: Lightman +cn: Jim Beam +sn: Beam uid: baeldung -userPassword: password \ No newline at end of file +userPassword: password + +dn: cn=admin,ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: groupOfNames +cn: admin +member: uid=baeldung,ou=people,dc=baeldung,dc=com + +dn: cn=user,ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=baeldung,ou=people,dc=baeldung,dc=com \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 67db0dba6dd0..000000000000 --- a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index d6e8f7549aff..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index fe4d56026291..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - Spring Security Basic Auth Application - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - index.html - - \ No newline at end of file From a634bf5cb9b5431724f7be050ad98c58f040e364 Mon Sep 17 00:00:00 2001 From: Adrian Milne Date: Wed, 4 Jun 2014 16:33:02 +0100 Subject: [PATCH 538/796] initial commit --- spring-security-ldap/README.md | 12 + spring-security-ldap/pom.xml | 266 ++++++++++++++++++ .../persistence/service/FooService.java | 23 ++ .../MyBasicAuthenticationEntryPoint.java | 31 ++ .../java/org/baeldung/spring/MvcConfig.java | 39 +++ .../baeldung/spring/PersistenceConfig.java | 14 + .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 17 ++ .../web/controller/FooController.java | 74 +++++ .../org/baeldung/web/controller/LinkUtil.java | 30 ++ .../web/controller/ResourceCreated.java | 35 +++ ...esourceCreatedDiscoverabilityListener.java | 35 +++ .../controller/SingleResourceRetrieved.java | 29 ++ ...ourceRetrievedDiscoverabilityListener.java | 32 +++ .../web/controller/TestController.java | 28 ++ .../main/java/org/baeldung/web/dto/Foo.java | 11 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/webSecurityConfig.xml | 25 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 + .../src/main/webapp/WEB-INF/web.xml | 42 +++ .../src/test/resources/.gitignore | 13 + 22 files changed, 804 insertions(+) create mode 100644 spring-security-ldap/README.md create mode 100644 spring-security-ldap/pom.xml create mode 100644 spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java create mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 spring-security-ldap/src/main/resources/logback.xml create mode 100644 spring-security-ldap/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-ldap/src/test/resources/.gitignore diff --git a/spring-security-ldap/README.md b/spring-security-ldap/README.md new file mode 100644 index 000000000000..95e45ae519cb --- /dev/null +++ b/spring-security-ldap/README.md @@ -0,0 +1,12 @@ +========= + +## Spring Security with Basic Authentication Example Project + + +### Relevant Article: +- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) + + +### Notes +- the project includes both views as well as a REST layer \ No newline at end of file diff --git a/spring-security-ldap/pom.xml b/spring-security-ldap/pom.xml new file mode 100644 index 000000000000..607ddf50d100 --- /dev/null +++ b/spring-security-ldap/pom.xml @@ -0,0 +1,266 @@ + + 4.0.0 + org.baeldung + spring-security-ldap + 0.1-SNAPSHOT + + spring-security-ldap + war + + + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + com.google.guava + guava + 14.0.1 + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-mvc-basic-auth + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + + + + + + + 4.0.5.RELEASE + 3.2.4.RELEASE + + + 4.3.5.Final + 5.1.30 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.8 + + + + diff --git a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 000000000000..02db7a733a6b --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,23 @@ +package org.baeldung.persistence.service; + +import org.baeldung.web.dto.Foo; +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public FooService() { + super(); + } + + // API + + public Foo getById(final Long id) { + return null; + } + + public Long create(final Foo resource) { + return null; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 000000000000..968237227f63 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,31 @@ +package org.baeldung.security.basic; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..74c11478ee2e --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,39 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/homepage.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java new file mode 100644 index 000000000000..4ea0053f4845 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.persistence") +public class PersistenceConfig { + + public PersistenceConfig() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..4ce80dab9f1c --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 000000000000..fa6f5f6d5626 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@ComponentScan("org.baeldung.web") +public class WebConfig extends WebMvcConfigurerAdapter { + + public WebConfig() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 000000000000..daa797ee368e --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,74 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.persistence.service.FooService; +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; + +@Controller +@RequestMapping(value = "/foo") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private FooService service; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(); + } + + @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { + final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); + + eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + return resourceById; + } + + @RequestMapping(value = "admin/foo", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Long idOfCreatedResource = service.create(resource); + + eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); + } + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL().toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java new file mode 100644 index 000000000000..a41ebb5a5cdd --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java new file mode 100644 index 000000000000..a67788810161 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreated extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + private final long idOfNewResource; + + public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.request = request; + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 000000000000..8d19ef82fc63 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriTemplate; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletRequest request = resourceCreatedEvent.getRequest(); + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(request, response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { + final String requestUrl = request.getRequestURL().toString(); + final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java new file mode 100644 index 000000000000..3de791810549 --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java @@ -0,0 +1,29 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrieved extends ApplicationEvent { + private final HttpServletResponse response; + private final HttpServletRequest request; + + public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + super(source); + + this.request = request; + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public HttpServletRequest getRequest() { + return request; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 000000000000..45cd7c4d131a --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,32 @@ +package org.baeldung.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletRequest request = resourceRetrievedEvent.getRequest(); + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(request, response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { + final StringBuffer requestURL = request.getRequestURL(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader("Link", linkHeaderValue); + } + +} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java new file mode 100644 index 000000000000..f68cfb2eb7dc --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java @@ -0,0 +1,28 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestController { + + public TestController() { + super(); + } + + // API + + @RequestMapping("/permitAll") + @ResponseBody + public String permitAll() { + return "Permit All"; + } + + @RequestMapping("/securityNone") + @ResponseBody + public String securityNone() { + return "Security None"; + } + +} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 000000000000..352045989daa --- /dev/null +++ b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,11 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/spring-security-ldap/src/main/resources/logback.xml b/spring-security-ldap/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-ldap/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-ldap/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..e5310da18704 --- /dev/null +++ b/spring-security-ldap/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..d6e8f7549aff --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..7cc14b5dcddf --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..08183daa249f --- /dev/null +++ b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + Spring Security Basic Auth Application + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + + index.html + + + \ No newline at end of file diff --git a/spring-security-ldap/src/test/resources/.gitignore b/spring-security-ldap/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-security-ldap/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file From 2102bcc0b020d0e77f80e30bd82fdd2411e45a4a Mon Sep 17 00:00:00 2001 From: corsoft Date: Tue, 10 Jun 2014 19:34:55 +0100 Subject: [PATCH 539/796] updated gitignore --- .gitignore | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 0f182a0349c4..72f3338a99c1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,23 @@ *.jar *.war *.ear + + +# Eclipse +.classpath +.project +.settings/ +.prefs +*.prefs + +# Intellij +.idea/ +*.iml +*.iws + +# Mac +.DS_Store + +# Maven +log/ +target/ From 82d51cb08dd9e6c482ad0427238902f31bf9b1ce Mon Sep 17 00:00:00 2001 From: corsoft Date: Wed, 11 Jun 2014 07:16:07 +0100 Subject: [PATCH 540/796] Created holder for ldap project (based on trimmed down basic auth project) --- .../persistence/service/FooService.java | 23 ------ .../baeldung/spring/PersistenceConfig.java | 14 ---- .../web/controller/FooController.java | 74 ------------------- .../org/baeldung/web/controller/LinkUtil.java | 30 -------- .../web/controller/ResourceCreated.java | 35 --------- ...esourceCreatedDiscoverabilityListener.java | 35 --------- .../controller/SingleResourceRetrieved.java | 29 -------- ...ourceRetrievedDiscoverabilityListener.java | 32 -------- .../web/controller/TestController.java | 28 ------- .../main/java/org/baeldung/web/dto/Foo.java | 11 --- .../src/main/webapp/WEB-INF/web.xml | 42 ----------- .../README.md | 0 .../pom.xml | 6 +- .../MyBasicAuthenticationEntryPoint.java | 0 .../java/org/baeldung/spring/MvcConfig.java | 0 .../baeldung/spring/SecSecurityConfig.java | 1 + .../java/org/baeldung/spring/WebConfig.java | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 36 +++++++++ .../src/test/resources/.gitignore | 0 23 files changed, 40 insertions(+), 356 deletions(-) delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java delete mode 100644 spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java delete mode 100644 spring-security-ldap/src/main/webapp/WEB-INF/web.xml rename {spring-security-ldap => spring-security-mvc-ldap}/README.md (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/pom.xml (98%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/MvcConfig.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (98%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/java/org/baeldung/spring/WebConfig.java (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/resources/logback.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-security-ldap => spring-security-mvc-ldap}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) create mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml rename {spring-security-ldap => spring-security-mvc-ldap}/src/test/resources/.gitignore (100%) diff --git a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java b/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java deleted file mode 100644 index 02db7a733a6b..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.web.dto.Foo; -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - public FooService() { - super(); - } - - // API - - public Foo getById(final Long id) { - return null; - } - - public Long create(final Foo resource) { - return null; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java deleted file mode 100644 index 4ea0053f4845..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.baeldung.persistence") -public class PersistenceConfig { - - public PersistenceConfig() { - super(); - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java deleted file mode 100644 index daa797ee368e..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/FooController.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.baeldung.persistence.service.FooService; -import org.baeldung.web.dto.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.util.UriComponentsBuilder; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; - -@Controller -@RequestMapping(value = "/foo") -public class FooController { - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Autowired - private FooService service; - - public FooController() { - super(); - } - - // API - - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - return new Foo(); - } - - @RequestMapping(value = "admin/foo/{id}", method = RequestMethod.GET) - @ResponseBody - public Foo get(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { - final Foo resourceById = Preconditions.checkNotNull(service.getById(id)); - - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); - return resourceById; - } - - @RequestMapping(value = "admin/foo", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) { - Preconditions.checkNotNull(resource); - final Long idOfCreatedResource = service.create(resource); - - eventPublisher.publishEvent(new ResourceCreated(this, request, response, idOfCreatedResource)); - } - - @RequestMapping(value = "admin", method = RequestMethod.GET) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { - final String rootUri = request.getRequestURL().toString(); - - final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); - final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); - response.addHeader("Link", linkToFoo); - } -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java deleted file mode 100644 index a41ebb5a5cdd..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/LinkUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletResponse; - -/** - * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object - */ -public final class LinkUtil { - - private LinkUtil() { - throw new AssertionError(); - } - - // - - /** - * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user - * - * @param uri - * the base uri - * @param rel - * the relative path - * - * @return the complete url - */ - public static String createLinkHeader(final String uri, final String rel) { - return "<" + uri + ">; rel=\"" + rel + "\""; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java deleted file mode 100644 index a67788810161..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreated.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class ResourceCreated extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - private final long idOfNewResource; - - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - super(source); - - this.request = request; - this.response = response; - this.idOfNewResource = idOfNewResource; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - - public long getIdOfNewResource() { - return idOfNewResource; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java deleted file mode 100644 index 8d19ef82fc63..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/ResourceCreatedDiscoverabilityListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.baeldung.web.controller; - -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; -import org.springframework.web.util.UriTemplate; - -import com.google.common.base.Preconditions; -import com.google.common.net.HttpHeaders; - -@Component -class ResourceCreatedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { - Preconditions.checkNotNull(resourceCreatedEvent); - - final HttpServletRequest request = resourceCreatedEvent.getRequest(); - final HttpServletResponse response = resourceCreatedEvent.getResponse(); - final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); - - addLinkHeaderOnResourceCreation(request, response, idOfNewResource); - } - - void addLinkHeaderOnResourceCreation(final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - final String requestUrl = request.getRequestURL().toString(); - final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); - response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); - } - -} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java deleted file mode 100644 index 3de791810549..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrieved.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class SingleResourceRetrieved extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { - super(source); - - this.request = request; - this.response = response; - } - - // API - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java deleted file mode 100644 index 45cd7c4d131a..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/SingleResourceRetrievedDiscoverabilityListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.web.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -@Component -class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { - - @Override - public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { - Preconditions.checkNotNull(resourceRetrievedEvent); - - final HttpServletRequest request = resourceRetrievedEvent.getRequest(); - final HttpServletResponse response = resourceRetrievedEvent.getResponse(); - addLinkHeaderOnSingleResourceRetrieval(request, response); - } - - void addLinkHeaderOnSingleResourceRetrieval(final HttpServletRequest request, final HttpServletResponse response) { - final StringBuffer requestURL = request.getRequestURL(); - final int positionOfLastSlash = requestURL.lastIndexOf("/"); - final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); - - final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); - response.addHeader("Link", linkHeaderValue); - } - -} \ No newline at end of file diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java b/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java deleted file mode 100644 index f68cfb2eb7dc..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.baeldung.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class TestController { - - public TestController() { - super(); - } - - // API - - @RequestMapping("/permitAll") - @ResponseBody - public String permitAll() { - return "Permit All"; - } - - @RequestMapping("/securityNone") - @ResponseBody - public String securityNone() { - return "Security None"; - } - -} diff --git a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java deleted file mode 100644 index 352045989daa..000000000000 --- a/spring-security-ldap/src/main/java/org/baeldung/web/dto/Foo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.baeldung.web.dto; - -import java.io.Serializable; - -public class Foo implements Serializable { - - public Foo() { - super(); - } - -} diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-ldap/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 08183daa249f..000000000000 --- a/spring-security-ldap/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - Spring Security Basic Auth Application - - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - index.html - - - \ No newline at end of file diff --git a/spring-security-ldap/README.md b/spring-security-mvc-ldap/README.md similarity index 100% rename from spring-security-ldap/README.md rename to spring-security-mvc-ldap/README.md diff --git a/spring-security-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml similarity index 98% rename from spring-security-ldap/pom.xml rename to spring-security-mvc-ldap/pom.xml index 607ddf50d100..11e875a07158 100644 --- a/spring-security-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-security-ldap + spring-security-mvc-ldap 0.1-SNAPSHOT - spring-security-ldap + spring-security-mvc-ldap war @@ -159,7 +159,7 @@ - spring-security-mvc-basic-auth + spring-security-mvc-ldap src/main/resources diff --git a/spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/spring/MvcConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 98% rename from spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4ce80dab9f1c..9f0591d7dbb0 100644 --- a/spring-security-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -13,4 +13,5 @@ public SecSecurityConfig() { super(); } + } diff --git a/spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java similarity index 100% rename from spring-security-ldap/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java diff --git a/spring-security-ldap/src/main/resources/logback.xml b/spring-security-mvc-ldap/src/main/resources/logback.xml similarity index 100% rename from spring-security-ldap/src/main/resources/logback.xml rename to spring-security-mvc-ldap/src/main/resources/logback.xml diff --git a/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-ldap/src/main/resources/webSecurityConfig.xml rename to spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-ldap/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..fe4d56026291 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + Spring Security Basic Auth Application + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + index.html + + \ No newline at end of file diff --git a/spring-security-ldap/src/test/resources/.gitignore b/spring-security-mvc-ldap/src/test/resources/.gitignore similarity index 100% rename from spring-security-ldap/src/test/resources/.gitignore rename to spring-security-mvc-ldap/src/test/resources/.gitignore From cc15245e4d6ed4a50cd5df4e770fa317c1ade6a9 Mon Sep 17 00:00:00 2001 From: corsoft Date: Fri, 13 Jun 2014 07:24:22 +0100 Subject: [PATCH 541/796] LDAP working - MVC needs fixing --- spring-security-mvc-ldap/pom.xml | 63 +++++++++++++++++-- .../baeldung/controller/HomeController.java | 15 +++++ .../MyBasicAuthenticationEntryPoint.java | 31 --------- .../java/org/baeldung/spring/Application.java | 17 +++++ .../java/org/baeldung/spring/MvcConfig.java | 39 ------------ .../baeldung/spring/SecSecurityConfig.java | 17 ----- .../org/baeldung/spring/SecurityConfig.java | 29 +++++++++ .../java/org/baeldung/spring/WebConfig.java | 17 ----- .../src/main/resources/users.ldif | 14 +++++ .../src/main/resources/webSecurityConfig.xml | 11 +++- 10 files changed, 142 insertions(+), 111 deletions(-) create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 spring-security-mvc-ldap/src/main/resources/users.ldif diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 11e875a07158..57af0f1d48a6 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -7,11 +7,16 @@ spring-security-mvc-ldap war + + + org.springframework.boot + spring-boot-starter-parent + 1.1.1.RELEASE + - org.springframework.security spring-security-web @@ -30,10 +35,10 @@ spring-core ${org.springframework.version} - - commons-logging - commons-logging - + + commons-logging + commons-logging + @@ -78,6 +83,52 @@ ${org.springframework.version} + + + + + org.springframework.boot + spring-boot-starter-web + 1.1.1.RELEASE + + + + org.springframework.security + spring-security-ldap + 3.2.4.RELEASE + + + + org.springframework.ldap + spring-ldap-core + 2.0.2.RELEASE + + + org.springframework.ldap + spring-ldap-core-tiger + 2.0.2.RELEASE + + + + + org.apache.directory.server + apacheds-server-jndi + 1.5.5 + + + + commons-collections + commons-collections + 3.2.1 + + + org.apache.mina + mina-core + 2.0.7 + + + + @@ -126,7 +177,7 @@ log4j-over-slf4j ${org.slf4j.version} - + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java new file mode 100644 index 000000000000..7d9a8365009f --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java @@ -0,0 +1,15 @@ +package org.baeldung.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class HomeController { + + @RequestMapping("/homepage.html") + public @ResponseBody String index() { + return "homepage"; + } +} + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java deleted file mode 100644 index 968237227f63..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/basic/MyBasicAuthenticationEntryPoint.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.security.basic; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; -import org.springframework.stereotype.Component; - -@Component -public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { - - @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - final PrintWriter writer = response.getWriter(); - writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); - } - - @Override - public void afterPropertiesSet() throws Exception { - setRealmName("Baeldung"); - super.afterPropertiesSet(); - } - -} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java new file mode 100644 index 000000000000..6d0621e3dde6 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java @@ -0,0 +1,17 @@ +package org.baeldung.spring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +@EnableAutoConfiguration +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java deleted file mode 100644 index 74c11478ee2e..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/MvcConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@Configuration -@EnableWebMvc -public class MvcConfig extends WebMvcConfigurerAdapter { - - public MvcConfig() { - super(); - } - - // API - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - - registry.addViewController("/homepage.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - - return bean; - } -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java deleted file mode 100644 index 9f0591d7dbb0..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; - -@Configuration -@ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.security") -public class SecSecurityConfig { - - public SecSecurityConfig() { - super(); - } - - -} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java new file mode 100644 index 000000000000..026afa114a9e --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java @@ -0,0 +1,29 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; + +@Configuration +@EnableWebMvcSecurity +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) + throws Exception { + + auth.ldapAuthentication() + .userSearchBase("ou=people") + .userSearchFilter("(uid={0})") + .groupSearchBase("ou=groups") + .groupSearchFilter("member={0}") + .contextSource() + .root("dc=baeldung,dc=com") + .ldif("classpath:users.ldif"); + + } + + + +} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java deleted file mode 100644 index fa6f5f6d5626..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/WebConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@ComponentScan("org.baeldung.web") -public class WebConfig extends WebMvcConfigurerAdapter { - - public WebConfig() { - super(); - } - - // API - -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/users.ldif b/spring-security-mvc-ldap/src/main/resources/users.ldif new file mode 100644 index 000000000000..59712d59e12f --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/users.ldif @@ -0,0 +1,14 @@ +dn: ou=people,dc=baeldung,dc=com +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=baeldung,ou=people,dc=baeldung,dc=com +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: David Lightman +sn: Lightman +uid: baeldung +userPassword: password \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml index e5310da18704..67db0dba6dd0 100644 --- a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml @@ -13,6 +13,9 @@ + + + + + + + \ No newline at end of file From 81b4925a5e7e0be788d59974eb7ff3d1a57bf9d0 Mon Sep 17 00:00:00 2001 From: corsoft Date: Sun, 15 Jun 2014 13:17:38 +0100 Subject: [PATCH 542/796] Working version - LDAP + Spring Boot --- spring-security-mvc-ldap/pom.xml | 276 ++---------------- .../org/baeldung/SampleLDAPApplication.java | 27 ++ .../baeldung/controller/HomeController.java | 15 - .../org/baeldung/controller/MyController.java | 74 +++++ .../org/baeldung/security/SecurityConfig.java | 51 ++++ .../java/org/baeldung/spring/Application.java | 17 -- .../org/baeldung/spring/SecurityConfig.java | 29 -- .../src/main/resources/logback.xml | 4 +- .../resources/static/css/bootstrap.min.css | 13 + .../src/main/resources/templates/error.html | 32 ++ .../src/main/resources/templates/home.html | 37 +++ .../src/main/resources/templates/login.html | 36 +++ .../src/main/resources/users.ldif | 23 +- .../src/main/resources/webSecurityConfig.xml | 34 --- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 5 - .../src/main/webapp/WEB-INF/view/homepage.jsp | 7 - .../src/main/webapp/WEB-INF/web.xml | 36 --- 17 files changed, 310 insertions(+), 406 deletions(-) create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java create mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java delete mode 100644 spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java create mode 100644 spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/error.html create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/home.html create mode 100644 spring-security-mvc-ldap/src/main/resources/templates/login.html delete mode 100644 spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 57af0f1d48a6..12353021f0e3 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -7,7 +7,7 @@ spring-security-mvc-ldap war - + org.springframework.boot spring-boot-starter-parent @@ -16,88 +16,23 @@ - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - + - org.springframework - spring-web - ${org.springframework.version} + org.springframework.boot + spring-boot-starter-security - org.springframework - spring-webmvc - ${org.springframework.version} + org.springframework.boot + spring-boot-starter-thymeleaf - - - + - org.springframework.boot - spring-boot-starter-web - 1.1.1.RELEASE + org.springframework.security + spring-security-ldap + 3.2.4.RELEASE - - org.springframework.security - spring-security-ldap - 3.2.4.RELEASE - - org.springframework.ldap spring-ldap-core @@ -108,103 +43,17 @@ spring-ldap-core-tiger 2.0.2.RELEASE - - - - org.apache.directory.server - apacheds-server-jndi - 1.5.5 - - - - commons-collections - commons-collections - 3.2.1 - - - org.apache.mina - mina-core - 2.0.7 - - - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.google.guava - guava - 14.0.1 - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test + + org.apache.directory.server + apacheds-server-jndi + 1.5.5 - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test + org.apache.mina + mina-core + 2.0.7 @@ -217,100 +66,9 @@ true - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - 4.0.5.RELEASE - 3.2.4.RELEASE - - - 4.3.5.Final - 5.1.30 - - - 1.7.6 - 1.1.1 - - - 5.1.1.Final - - - 17.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.3 - - 2.3.1 - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.8 diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java new file mode 100644 index 000000000000..8bbf97de8fc2 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java @@ -0,0 +1,27 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +/** + * Main Application Class - uses Spring Boot. Just run this as a normal Java + * class to run up a Jetty Server (on http://localhost:8080) + * + */ +@EnableAutoConfiguration +@ComponentScan("org.baeldung") +public class SampleLDAPApplication extends WebMvcConfigurerAdapter { + + public static void main(String[] args) { + SpringApplication.run(SampleLDAPApplication.class, args); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/login").setViewName("login"); + } + +} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java deleted file mode 100644 index 7d9a8365009f..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/HomeController.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.baeldung.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class HomeController { - - @RequestMapping("/homepage.html") - public @ResponseBody String index() { - return "homepage"; - } -} - diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java new file mode 100644 index 000000000000..f65cf0493920 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java @@ -0,0 +1,74 @@ +package org.baeldung.controller; + +import java.security.Principal; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Spring Controller Definitions. + */ +@Controller +public class MyController { + + @RequestMapping("/") + public String init(Map model, Principal principal) { + model.put("title", "PUBLIC AREA"); + model.put("message", "Any user can view this page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } + + @RequestMapping("/secure") + public String secure(Map model, Principal principal) { + model.put("title", "SECURE AREA"); + model.put("message", "Only Authorised Users Can See This Page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } + + private String getUserName(Principal principal){ + + if(principal == null){ + return "anonymous"; + }else{ + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for(GrantedAuthority grantedAuthority : authorities) { + System.out.println(grantedAuthority.getAuthority()); + } + return principal.getName(); + } + } + + private Collection getUserRoles(Principal principal){ + + if(principal == null){ + return Arrays.asList("none"); + }else{ + + Set roles = new HashSet(); + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for(GrantedAuthority grantedAuthority : authorities) { + roles.add(grantedAuthority.getAuthority()); + } + return roles; + } + } + +} + diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java new file mode 100644 index 000000000000..97bbaf83027c --- /dev/null +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java @@ -0,0 +1,51 @@ +package org.baeldung.security; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.stereotype.Controller; + +/** + * Security Configuration - LDAP and HTTP Authorizations. + */ +@EnableAutoConfiguration +@ComponentScan +@Controller +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) + throws Exception { + + auth.ldapAuthentication() + .userSearchBase("ou=people") + .userSearchFilter("(uid={0})") + .groupSearchBase("ou=groups") + .groupSearchFilter("member={0}") + .contextSource() + .root("dc=baeldung,dc=com") + .ldif("classpath:users.ldif"); + + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http + .authorizeRequests() + .antMatchers("/", "/home").permitAll() + .anyRequest().authenticated(); + http + .formLogin() + .loginPage("/login") + .permitAll() + .and() + .logout() + .logoutSuccessUrl("/"); + + + } + +} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java deleted file mode 100644 index 6d0621e3dde6..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/Application.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan -@EnableAutoConfiguration -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java deleted file mode 100644 index 026afa114a9e..000000000000 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/spring/SecurityConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; - -@Configuration -@EnableWebMvcSecurity -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(AuthenticationManagerBuilder auth) - throws Exception { - - auth.ldapAuthentication() - .userSearchBase("ou=people") - .userSearchFilter("(uid={0})") - .groupSearchBase("ou=groups") - .groupSearchFilter("member={0}") - .contextSource() - .root("dc=baeldung,dc=com") - .ldif("classpath:users.ldif"); - - } - - - -} diff --git a/spring-security-mvc-ldap/src/main/resources/logback.xml b/spring-security-mvc-ldap/src/main/resources/logback.xml index 1146dade632e..2dc76c96f305 100644 --- a/spring-security-mvc-ldap/src/main/resources/logback.xml +++ b/spring-security-mvc-ldap/src/main/resources/logback.xml @@ -10,9 +10,11 @@ - + + + diff --git a/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css b/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css new file mode 100644 index 000000000000..6e7c69f08876 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css @@ -0,0 +1,13 @@ +/*! + * Bootstrap v2.0.4 + * + * Copyright 2012 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world @twitter by @mdo and @fat. + */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.127659574%;*margin-left:2.0744680846382977%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.99999998999999%;*width:99.94680850063828%}.row-fluid .span11{width:91.489361693%;*width:91.4361702036383%}.row-fluid .span10{width:82.97872339599999%;*width:82.92553190663828%}.row-fluid .span9{width:74.468085099%;*width:74.4148936096383%}.row-fluid .span8{width:65.95744680199999%;*width:65.90425531263828%}.row-fluid .span7{width:57.446808505%;*width:57.3936170156383%}.row-fluid .span6{width:48.93617020799999%;*width:48.88297871863829%}.row-fluid .span5{width:40.425531911%;*width:40.3723404216383%}.row-fluid .span4{width:31.914893614%;*width:31.8617021246383%}.row-fluid .span3{width:23.404255317%;*width:23.3510638276383%}.row-fluid .span2{width:14.89361702%;*width:14.8404255306383%}.row-fluid .span1{width:6.382978723%;*width:6.329787233638298%}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;content:""}.container-fluid:after{clear:both}p{margin:0 0 9px}p small{font-size:11px;color:#999}.lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px}h1,h2,h3,h4,h5,h6{margin:0;font-family:inherit;font-weight:bold;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{font-size:18px;line-height:27px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}.page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eee}.page-header h1{line-height:1}ul,ol{padding:0;margin:0 0 9px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}ul{list-style:disc}ol{list-style:decimal}li{line-height:18px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}dl{margin-bottom:18px}dt,dd{line-height:18px}dt{font-weight:bold;line-height:17px}dd{margin-left:9px}.dl-horizontal dt{float:left;width:120px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:130px}hr{margin:18px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}strong{font-weight:bold}em{font-style:italic}.muted{color:#999}abbr[title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px}blockquote small{display:block;line-height:18px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:18px;font-style:normal;line-height:18px}small{font-size:100%}cite{font-style:normal}code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:8.5px;margin:0 0 9px;font-size:12.025px;line-height:18px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:18px}pre code{padding:0;color:inherit;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 18px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:27px;font-size:19.5px;line-height:36px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:13.5px;color:#999}label,input,button,select,textarea{font-size:13px;font-weight:normal;line-height:18px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:18px;padding:4px;margin-bottom:9px;font-size:13px;line-height:18px;color:#555}input,textarea{width:210px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-ms-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:3px 0;*margin-top:0;line-height:normal;cursor:pointer}input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}.uneditable-textarea{width:auto;height:auto}select,input[type="file"]{height:28px;*margin-top:4px;line-height:28px}select{width:220px;border:1px solid #bbb}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.radio,.checkbox{min-height:18px;padding-left:18px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-18px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:930px}input.span11,textarea.span11,.uneditable-input.span11{width:850px}input.span10,textarea.span10,.uneditable-input.span10{width:770px}input.span9,textarea.span9,.uneditable-input.span9{width:690px}input.span8,textarea.span8,.uneditable-input.span8{width:610px}input.span7,textarea.span7,.uneditable-input.span7{width:530px}input.span6,textarea.span6,.uneditable-input.span6{width:450px}input.span5,textarea.span5,.uneditable-input.span5{width:370px}input.span4,textarea.span4,.uneditable-input.span4{width:290px}input.span3,textarea.span3,.uneditable-input.span3{width:210px}input.span2,textarea.span2,.uneditable-input.span2{width:130px}input.span1,textarea.span1,.uneditable-input.span1{width:50px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee;border-color:#ddd}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning>label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;border-color:#c09853}.control-group.warning .checkbox:focus,.control-group.warning .radio:focus,.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:0 0 6px #dbc59e;-moz-box-shadow:0 0 6px #dbc59e;box-shadow:0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error>label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;border-color:#b94a48}.control-group.error .checkbox:focus,.control-group.error .radio:focus,.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:0 0 6px #d59392;-moz-box-shadow:0 0 6px #d59392;box-shadow:0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success>label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;border-color:#468847}.control-group.success .checkbox:focus,.control-group.success .radio:focus,.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:0 0 6px #7aba7b;-moz-box-shadow:0 0 6px #7aba7b;box-shadow:0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}input:focus:required:invalid,textarea:focus:required:invalid,select:focus:required:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:required:invalid:focus,textarea:focus:required:invalid:focus,select:focus:required:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:17px 20px 18px;margin-top:18px;margin-bottom:18px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;content:""}.form-actions:after{clear:both}.uneditable-input{overflow:hidden;white-space:nowrap;cursor:not-allowed;background-color:#fff;border-color:#eee;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}:-moz-placeholder{color:#999}:-ms-input-placeholder{color:#999}::-webkit-input-placeholder{color:#999}.help-block,.help-inline{color:#555}.help-block{display:block;margin-bottom:9px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-prepend,.input-append{margin-bottom:5px}.input-prepend input,.input-append input,.input-prepend select,.input-append select,.input-prepend .uneditable-input,.input-append .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:middle;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend input:focus,.input-append input:focus,.input-prepend select:focus,.input-append select:focus,.input-prepend .uneditable-input:focus,.input-append .uneditable-input:focus{z-index:2}.input-prepend .uneditable-input,.input-append .uneditable-input{border-left-color:#ccc}.input-prepend .add-on,.input-append .add-on{display:inline-block;width:auto;height:18px;min-width:16px;padding:4px 5px;font-weight:normal;line-height:18px;text-align:center;text-shadow:0 1px 0 #fff;vertical-align:middle;background-color:#eee;border:1px solid #ccc}.input-prepend .add-on,.input-append .add-on,.input-prepend .btn,.input-append .btn{margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend .active,.input-append .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append .uneditable-input{border-right-color:#ccc;border-left-color:#eee}.input-append .add-on:last-child,.input-append .btn:last-child{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:14px;-moz-border-radius:14px;border-radius:14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:9px}legend+.control-group{margin-top:18px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:18px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:140px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:160px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:160px}.form-horizontal .help-block{margin-top:9px;margin-bottom:0}.form-horizontal .form-actions{padding-left:160px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:18px}.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapsed;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5}table .span1{float:none;width:44px;margin-left:0}table .span2{float:none;width:124px;margin-left:0}table .span3{float:none;width:204px;margin-left:0}table .span4{float:none;width:284px;margin-left:0}table .span5{float:none;width:364px;margin-left:0}table .span6{float:none;width:444px;margin-left:0}table .span7{float:none;width:524px;margin-left:0}table .span8{float:none;width:604px;margin-left:0}table .span9{float:none;width:684px;margin-left:0}table .span10{float:none;width:764px;margin-left:0}table .span11{float:none;width:844px;margin-left:0}table .span12{float:none;width:924px;margin-left:0}table .span13{float:none;width:1004px;margin-left:0}table .span14{float:none;width:1084px;margin-left:0}table .span15{float:none;width:1164px;margin-left:0}table .span16{float:none;width:1244px;margin-left:0}table .span17{float:none;width:1324px;margin-left:0}table .span18{float:none;width:1404px;margin-left:0}table .span19{float:none;width:1484px;margin-left:0}table .span20{float:none;width:1564px;margin-left:0}table .span21{float:none;width:1644px;margin-left:0}table .span22{float:none;width:1724px;margin-left:0}table .span23{float:none;width:1804px;margin-left:0}table .span24{float:none;width:1884px;margin-left:0}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}[class^="icon-"]:last-child,[class*=" icon-"]:last-child{*margin-left:0}.icon-white{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{background-position:-384px -120px}.icon-folder-open{background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:"";opacity:.3;filter:alpha(opacity=30)}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown:hover .caret,.open .caret{opacity:1;filter:alpha(opacity=100)}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:4px 0;margin:1px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu a{display:block;padding:3px 15px;clear:both;font-weight:normal;line-height:18px;color:#333;white-space:nowrap}.dropdown-menu li>a:hover,.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#fff;text-decoration:none;background-color:#08c}.open{*z-index:1000}.open>.dropdown-menu{display:block}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:"\2191"}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.typeahead{margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #eee;border:1px solid rgba(0,0,0,0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-ms-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-ms-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 10px 4px;margin-bottom:0;*margin-left:.3em;font-size:13px;line-height:18px;*line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-ms-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(top,#fff,#e6e6e6);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #ccc;*border:0;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;*background-color:#d9d9d9;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-ms-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-color:#e6e6e6;background-color:#d9d9d9 \9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-color:#e6e6e6;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.btn-large [class^="icon-"]{margin-top:1px}.btn-small{padding:5px 9px;font-size:11px;line-height:16px}.btn-small [class^="icon-"]{margin-top:-1px}.btn-mini{padding:2px 6px;font-size:11px;line-height:14px}.btn-primary,.btn-primary:hover,.btn-warning,.btn-warning:hover,.btn-danger,.btn-danger:hover,.btn-success,.btn-success:hover,.btn-info,.btn-info:hover,.btn-inverse,.btn-inverse:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#ccc;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn-primary{background-color:#0074cc;*background-color:#05c;background-image:-ms-linear-gradient(top,#08c,#05c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#05c));background-image:-webkit-linear-gradient(top,#08c,#05c);background-image:-o-linear-gradient(top,#08c,#05c);background-image:-moz-linear-gradient(top,#08c,#05c);background-image:linear-gradient(top,#08c,#05c);background-repeat:repeat-x;border-color:#05c #05c #003580;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#0088cc',endColorstr='#0055cc',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{background-color:#05c;*background-color:#004ab3}.btn-primary:active,.btn-primary.active{background-color:#004099 \9}.btn-warning{background-color:#faa732;*background-color:#f89406;background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{background-color:#da4f49;*background-color:#bd362f;background-image:-ms-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(top,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#bd362f',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{background-color:#5bb75b;*background-color:#51a351;background-image:-ms-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(top,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#51a351',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{background-color:#49afcd;*background-color:#2f96b4;background-image:-ms-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(top,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#2f96b4',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{background-color:#414141;*background-color:#222;background-image:-ms-linear-gradient(top,#555,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#222));background-image:-webkit-linear-gradient(top,#555,#222);background-image:-o-linear-gradient(top,#555,#222);background-image:-moz-linear-gradient(top,#555,#222);background-image:linear-gradient(top,#555,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#555555',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-group{position:relative;*margin-left:.3em;*zoom:1}.btn-group:before,.btn-group:after{display:table;content:""}.btn-group:after{clear:both}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:9px;margin-bottom:9px}.btn-toolbar .btn-group{display:inline-block;*display:inline;*zoom:1}.btn-group>.btn{position:relative;float:left;margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.dropdown-toggle{*padding-top:4px;padding-right:8px;*padding-bottom:4px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini.dropdown-toggle{padding-right:5px;padding-left:5px}.btn-group>.btn-small.dropdown-toggle{*padding-top:4px;*padding-bottom:4px}.btn-group>.btn-large.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#05c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:7px;margin-left:0}.btn:hover .caret,.open.btn-group .caret{opacity:1;filter:alpha(opacity=100)}.btn-mini .caret{margin-top:5px}.btn-small .caret{margin-top:6px}.btn-large .caret{margin-top:6px;border-top-width:5px;border-right-width:5px;border-left-width:5px}.dropup .btn-large .caret{border-top:0;border-bottom:5px solid #000}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:.75;filter:alpha(opacity=75)}.alert{padding:8px 35px 8px 14px;margin-bottom:18px;color:#c09853;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert-heading{color:inherit}.alert .close{position:relative;top:-2px;right:-21px;line-height:18px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:18px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>.pull-right{float:right}.nav .nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:18px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:18px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.nav-tabs.nav-stacked>li>a:hover{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px}.nav-pills .dropdown-menu{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-tabs .dropdown-toggle .caret,.nav-pills .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav-tabs .dropdown-toggle:hover .caret,.nav-pills .dropdown-toggle:hover .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .active .dropdown-toggle .caret,.nav-pills .active .dropdown-toggle .caret{border-top-color:#333;border-bottom-color:#333}.nav>.dropdown.active>a:hover{color:#000;cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.navbar{*position:relative;*z-index:2;margin-bottom:18px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#2c2c2c;background-image:-moz-linear-gradient(top,#333,#222);background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)}.navbar .container{width:auto}.nav-collapse.collapse{height:auto}.navbar{color:#999}.navbar .brand:hover{text-decoration:none}.navbar .brand{display:block;float:left;padding:8px 20px 12px;margin-left:-20px;font-size:20px;font-weight:200;line-height:1;color:#999}.navbar .navbar-text{margin-bottom:0;line-height:40px}.navbar .navbar-link{color:#999}.navbar .navbar-link:hover{color:#fff}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn{margin:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:6px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:6px;margin-bottom:0}.navbar-search .search-query{padding:4px 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;color:#fff;background-color:#626262;border:1px solid #151515;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none}.navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-search .search-query:focus,.navbar-search .search-query.focused{padding:5px 10px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-bottom{bottom:0}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right}.navbar .nav>li{display:block;float:left}.navbar .nav>li>a{float:none;padding:9px 10px 11px;line-height:19px;color:#999;text-decoration:none;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar .btn{display:inline-block;padding:4px 10px 4px;margin:5px 5px 6px;line-height:18px}.navbar .btn-group{padding:5px 5px 6px;margin:0}.navbar .nav>li>a:hover{color:#fff;text-decoration:none;background-color:transparent}.navbar .nav .active>a,.navbar .nav .active>a:hover{color:#fff;text-decoration:none;background-color:#222}.navbar .divider-vertical{width:1px;height:40px;margin:0 9px;overflow:hidden;background-color:#222;border-right:1px solid #333}.navbar .nav.pull-right{margin-right:0;margin-left:10px}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;background-color:#2c2c2c;*background-color:#222;background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-image:-moz-linear-gradient(top,#333,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{background-color:#222;*background-color:#151515}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#080808 \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown .dropdown-toggle .caret,.navbar .nav li.dropdown.open .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar .nav li.dropdown.active .caret{opacity:1;filter:alpha(opacity=100)}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{background-color:transparent}.navbar .nav li.dropdown.active>.dropdown-toggle:hover{color:#fff}.navbar .pull-right .dropdown-menu,.navbar .dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right .dropdown-menu:before,.navbar .dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right .dropdown-menu:after,.navbar .dropdown-menu.pull-right:after{right:13px;left:auto}.breadcrumb{padding:7px 14px;margin:0 0 18px;list-style:none;background-color:#fbfbfb;background-image:-moz-linear-gradient(top,#fff,#f5f5f5);background-image:-ms-linear-gradient(top,#fff,#f5f5f5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f5f5f5));background-image:-webkit-linear-gradient(top,#fff,#f5f5f5);background-image:-o-linear-gradient(top,#fff,#f5f5f5);background-image:linear-gradient(top,#fff,#f5f5f5);background-repeat:repeat-x;border:1px solid #ddd;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#f5f5f5',GradientType=0);-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.breadcrumb li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb .divider{padding:0 5px;color:#999}.breadcrumb .active a{color:#333}.pagination{height:36px;margin:18px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination li{display:inline}.pagination a{float:left;padding:0 14px;line-height:34px;text-decoration:none;border:1px solid #ddd;border-left-width:0}.pagination a:hover,.pagination .active a{background-color:#f5f5f5}.pagination .active a{color:#999;cursor:default}.pagination .disabled span,.pagination .disabled a,.pagination .disabled a:hover{color:#999;cursor:default;background-color:transparent}.pagination li:first-child a{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.pagination li:last-child a{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pager{margin-bottom:18px;margin-left:0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;content:""}.pager:after{clear:both}.pager li{display:inline}.pager a{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager a:hover{text-decoration:none;background-color:#f5f5f5}.pager .next a{float:right}.pager .previous a{float:left}.pager .disabled a,.pager .disabled a:hover{color:#999;cursor:default;background-color:#fff}.modal-open .dropdown-menu{z-index:2050}.modal-open .dropdown.open{*z-index:2050}.modal-open .popover{z-index:2060}.modal-open .tooltip{z-index:2070}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:50%;left:50%;z-index:1050;width:560px;margin:-250px 0 0 -280px;overflow:auto;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-ms-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:50%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-body{max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.tooltip{position:absolute;z-index:1020;display:block;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{margin-top:-2px}.tooltip.right{margin-left:2px}.tooltip.bottom{margin-top:2px}.tooltip.left{margin-left:-2px}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px}.popover.top{margin-top:-5px}.popover.right{margin-left:5px}.popover.bottom{margin-top:5px}.popover.left{margin-left:-5px}.popover.top .arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.popover.bottom .arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.popover .arrow{position:absolute;width:0;height:0}.popover-inner{width:280px;padding:3px;overflow:hidden;background:#000;background:rgba(0,0,0,0.8);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.popover-title{padding:9px 15px;line-height:1;background-color:#f5f5f5;border-bottom:1px solid #eee;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.popover-content{padding:14px;background-color:#fff;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:18px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:1;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.075);box-shadow:0 1px 1px rgba(0,0,0,0.075)}a.thumbnail:hover{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px}.label,.badge{font-size:10.998px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{padding:1px 4px 2px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding:1px 9px 2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}a.label:hover,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:18px;margin-bottom:18px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-ms-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(top,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5',endColorstr='#f9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{width:0;height:18px;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(top,#149bdf,#0480be);background-image:-ms-linear-gradient(top,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#149bdf',endColorstr='#0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-ms-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-striped .bar{background-color:#149bdf;background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-ms-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(top,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#c43c35',GradientType=0)}.progress-danger.progress-striped .bar{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-ms-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(top,#62c462,#57a957);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#57a957',GradientType=0)}.progress-success.progress-striped .bar{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-ms-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(top,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#339bb9',GradientType=0)}.progress-info.progress-striped .bar{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0)}.progress-warning.progress-striped .bar{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:18px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:18px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel .item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-ms-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel .item>img{display:block;line-height:1}.carousel .active,.carousel .next,.carousel .prev{display:block}.carousel .active{left:0}.carousel .next,.carousel .prev{position:absolute;top:0;width:100%}.carousel .next{left:100%}.carousel .prev{left:-100%}.carousel .next.left,.carousel .prev.right{left:0}.carousel .active.left{left:-100%}.carousel .active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:10px 15px 5px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{color:#fff}.hero-unit{padding:60px;margin-bottom:30px;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit p{font-size:18px;font-weight:200;line-height:27px;color:inherit}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden} + + input.field-error, textarea.field-error { border: 1px solid #B94A48; } + + #footer { border-top: 1px solid #000000; } \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/templates/error.html b/spring-security-mvc-ldap/src/main/resources/templates/error.html new file mode 100644 index 000000000000..a75936a24a52 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/error.html @@ -0,0 +1,32 @@ + + + +Error + + + +
+ +

+
+
+ There was an unexpected error (type=Bad, status=500). +
+
Fake content
+
+ Please contact the operator with the above information. +
+ +
+ + diff --git a/spring-security-mvc-ldap/src/main/resources/templates/home.html b/spring-security-mvc-ldap/src/main/resources/templates/home.html new file mode 100644 index 000000000000..2632a3bb93c4 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/home.html @@ -0,0 +1,37 @@ + + + +Title + + + +
+ + + + +
+

+

+

+

+
+ + +
+ + diff --git a/spring-security-mvc-ldap/src/main/resources/templates/login.html b/spring-security-mvc-ldap/src/main/resources/templates/login.html new file mode 100644 index 000000000000..e3a18c2e486a --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/templates/login.html @@ -0,0 +1,36 @@ + + + +Login + + + +
+ +
+

You have been logged out

+

There was an error, please try again

+

Login with Username and Password

+
+
+ + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/users.ldif b/spring-security-mvc-ldap/src/main/resources/users.ldif index 59712d59e12f..228237da0598 100644 --- a/spring-security-mvc-ldap/src/main/resources/users.ldif +++ b/spring-security-mvc-ldap/src/main/resources/users.ldif @@ -1,3 +1,8 @@ +dn: ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: organizationalUnit +ou: groups + dn: ou=people,dc=baeldung,dc=com objectclass: top objectclass: organizationalUnit @@ -8,7 +13,19 @@ objectclass: top objectclass: person objectclass: organizationalPerson objectclass: inetOrgPerson -cn: David Lightman -sn: Lightman +cn: Jim Beam +sn: Beam uid: baeldung -userPassword: password \ No newline at end of file +userPassword: password + +dn: cn=admin,ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: groupOfNames +cn: admin +member: uid=baeldung,ou=people,dc=baeldung,dc=com + +dn: cn=user,ou=groups,dc=baeldung,dc=com +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=baeldung,ou=people,dc=baeldung,dc=com \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 67db0dba6dd0..000000000000 --- a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index d6e8f7549aff..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index fe4d56026291..000000000000 --- a/spring-security-mvc-ldap/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - Spring Security Basic Auth Application - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - index.html - - \ No newline at end of file From 6ab8c1e4d6f7fd283f90275d493fdcfd3dfffdf9 Mon Sep 17 00:00:00 2001 From: corsoft Date: Sun, 15 Jun 2014 13:26:17 +0100 Subject: [PATCH 543/796] Updated README.md --- spring-security-mvc-ldap/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-security-mvc-ldap/README.md b/spring-security-mvc-ldap/README.md index 95e45ae519cb..54487164eea5 100644 --- a/spring-security-mvc-ldap/README.md +++ b/spring-security-mvc-ldap/README.md @@ -1,6 +1,6 @@ ========= -## Spring Security with Basic Authentication Example Project +## Spring Security with LDAP Example Project ### Relevant Article: @@ -9,4 +9,9 @@ ### Notes -- the project includes both views as well as a REST layer \ No newline at end of file +- the project uses Spring Boot - simply run 'SampleLDAPApplication.java' to start up Spring Boot with a Tomcat container and embedded LDAP server. +- Once started, open 'http://localhost:8080' +- This will display the publicly available Home Page +- Navigate to 'Secure Page' to trigger authentication +- Username: 'baeldung', password: 'password' +- This will authenticate you, and display your allocated roles (as defined in the 'users.ldif' file) From 89d3f723334873cacf398ae6bb52fdc70be754c8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 16 Jun 2014 16:51:19 +0300 Subject: [PATCH 544/796] minor cleanup --- .../JavaCollectionCleanupUnitTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java index c6aeb19730c7..85f5d3f00920 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java @@ -3,6 +3,8 @@ import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import org.apache.commons.collections4.CollectionUtils; @@ -12,10 +14,11 @@ import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; public class JavaCollectionCleanupUnitTest { - // removing nulls + // tests - removing nulls @Test public final void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorrect() { @@ -50,4 +53,22 @@ public final void givenListContainsNulls_whenRemovingNullsWithCommonsCollections assertThat(list, hasSize(3)); } + // tests - remove duplicates + + @Test + public final void givenListContainsDuplicates_whenRemovingDuplicatesWithPlainJava_thenCorrect() { + final List listWithDuplicates = Lists.newArrayList(0, 1, 2, 3, 0, 0); + final List listWithoutDuplicates = new ArrayList<>(new HashSet<>(listWithDuplicates)); + + assertThat(listWithoutDuplicates, hasSize(4)); + } + + @Test + public final void givenListContainsDuplicates_whenRemovingDuplicatesWithGuava_thenCorrect() { + final List listWithDuplicates = Lists.newArrayList(0, 1, 2, 3, 0, 0); + final List listWithoutDuplicates = Lists.newArrayList(Sets.newHashSet(listWithDuplicates)); + + assertThat(listWithoutDuplicates, hasSize(4)); + } + } From a910ebae4419b9f235a1d73a5d2a1bb830804b16 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 16 Jun 2014 17:19:26 +0300 Subject: [PATCH 545/796] quick formatting work --- .../org/baeldung/SampleLDAPApplication.java | 14 +-- .../org/baeldung/controller/MyController.java | 98 +++++++++---------- .../org/baeldung/security/SecurityConfig.java | 40 ++------ 3 files changed, 63 insertions(+), 89 deletions(-) diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java index 8bbf97de8fc2..e380ea960237 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java @@ -15,13 +15,13 @@ @ComponentScan("org.baeldung") public class SampleLDAPApplication extends WebMvcConfigurerAdapter { - public static void main(String[] args) { - SpringApplication.run(SampleLDAPApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(SampleLDAPApplication.class, args); + } - @Override - public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/login").setViewName("login"); - } + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/login").setViewName("login"); + } } \ No newline at end of file diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java index f65cf0493920..e347bd863306 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; @@ -20,55 +19,52 @@ @Controller public class MyController { - @RequestMapping("/") - public String init(Map model, Principal principal) { - model.put("title", "PUBLIC AREA"); - model.put("message", "Any user can view this page"); - model.put("username", getUserName(principal)); - model.put("userroles", getUserRoles(principal)); - return "home"; - } + @RequestMapping("/") + public String init(Map model, Principal principal) { + model.put("title", "PUBLIC AREA"); + model.put("message", "Any user can view this page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } - @RequestMapping("/secure") - public String secure(Map model, Principal principal) { - model.put("title", "SECURE AREA"); - model.put("message", "Only Authorised Users Can See This Page"); - model.put("username", getUserName(principal)); - model.put("userroles", getUserRoles(principal)); - return "home"; - } - - private String getUserName(Principal principal){ - - if(principal == null){ - return "anonymous"; - }else{ - - final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); - Collection authorities = currentUser.getAuthorities(); - for(GrantedAuthority grantedAuthority : authorities) { - System.out.println(grantedAuthority.getAuthority()); - } - return principal.getName(); - } - } - - private Collection getUserRoles(Principal principal){ - - if(principal == null){ - return Arrays.asList("none"); - }else{ - - Set roles = new HashSet(); - - final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); - Collection authorities = currentUser.getAuthorities(); - for(GrantedAuthority grantedAuthority : authorities) { - roles.add(grantedAuthority.getAuthority()); - } - return roles; - } - } - -} + @RequestMapping("/secure") + public String secure(Map model, Principal principal) { + model.put("title", "SECURE AREA"); + model.put("message", "Only Authorised Users Can See This Page"); + model.put("username", getUserName(principal)); + model.put("userroles", getUserRoles(principal)); + return "home"; + } + + private String getUserName(Principal principal) { + if (principal == null) { + return "anonymous"; + } else { + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for (GrantedAuthority grantedAuthority : authorities) { + System.out.println(grantedAuthority.getAuthority()); + } + return principal.getName(); + } + } + + private Collection getUserRoles(Principal principal) { + if (principal == null) { + return Arrays.asList("none"); + } else { + Set roles = new HashSet(); + + final UserDetails currentUser = (UserDetails) ((Authentication) principal).getPrincipal(); + Collection authorities = currentUser.getAuthorities(); + for (GrantedAuthority grantedAuthority : authorities) { + roles.add(grantedAuthority.getAuthority()); + } + return roles; + } + } + +} diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java index 97bbaf83027c..c9bb5b74ae70 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java @@ -15,37 +15,15 @@ @Controller public class SecurityConfig extends WebSecurityConfigurerAdapter { - @Override - protected void configure(AuthenticationManagerBuilder auth) - throws Exception { - - auth.ldapAuthentication() - .userSearchBase("ou=people") - .userSearchFilter("(uid={0})") - .groupSearchBase("ou=groups") - .groupSearchFilter("member={0}") - .contextSource() - .root("dc=baeldung,dc=com") - .ldif("classpath:users.ldif"); - - } - - @Override - protected void configure(HttpSecurity http) throws Exception { + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("member={0}").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif"); + } - http - .authorizeRequests() - .antMatchers("/", "/home").permitAll() - .anyRequest().authenticated(); - http - .formLogin() - .loginPage("/login") - .permitAll() - .and() - .logout() - .logoutSuccessUrl("/"); + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated(); + http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/"); + } - - } - } From c1fed77c54d6b03174b5af54536f2ecdd8b9d0ab Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 17 Jun 2014 22:33:08 +0300 Subject: [PATCH 546/796] cleanup work --- .../org/baeldung/web/controller/FooController.java | 1 + .../org/baeldung/web/controller/FooController.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java index 6f68defcd642..ed6b1504034f 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -37,4 +37,5 @@ public Foo updateFoo(@PathVariable("id") final String id, @RequestBody final Foo System.out.println(foo); return foo; } + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index f8fcbbe1dc61..627a3b095f0c 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -85,4 +85,18 @@ public void create(@RequestBody final Foo resource, final HttpServletResponse re eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource)); } + @RequestMapping(method = RequestMethod.PUT) + @ResponseStatus(HttpStatus.OK) + public void update(@RequestBody final Foo resource) { + Preconditions.checkNotNull(resource); + RestPreconditions.checkFound(service.findOne(resource.getId())); + service.update(resource); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.OK) + public void delete(@PathVariable("id") final Long id) { + service.deleteById(id); + } + } From f18520d30df0bff2b566584ddb985ec2534a526f Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 19 Jun 2014 12:56:34 +0300 Subject: [PATCH 547/796] update operation fix --- .../main/java/org/baeldung/web/controller/FooController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 627a3b095f0c..e2191a929d69 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -85,9 +85,9 @@ public void create(@RequestBody final Foo resource, final HttpServletResponse re eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource)); } - @RequestMapping(method = RequestMethod.PUT) + @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) - public void update(@RequestBody final Foo resource) { + public void update(@PathVariable("id") final Long id, @RequestBody final Foo resource) { Preconditions.checkNotNull(resource); RestPreconditions.checkFound(service.findOne(resource.getId())); service.update(resource); From 59cd8a8baf75a8c7e914932fe7fe981e8f0b7a4b Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 19 Jun 2014 21:19:14 +0300 Subject: [PATCH 548/796] cleanup work and starting new tests --- .../JavaInputStreamToXUnitTest.java} | 4 +- .../java/io/JavaXToInputStreamUnitTest.java | 41 +++++++++++++++++++ .../HttpClientConnectionManagementTest.java | 9 +++- 3 files changed, 51 insertions(+), 3 deletions(-) rename core-java/src/test/java/org/baeldung/java/{CoreJavaIoUnitTest.java => io/JavaInputStreamToXUnitTest.java} (98%) create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java similarity index 98% rename from core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java rename to core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index d860d1ab4246..579d4b3a728d 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaIoUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package org.baeldung.java.io; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.hamcrest.Matchers.equalTo; @@ -25,7 +25,7 @@ import com.google.common.io.CharStreams; import com.google.common.io.InputSupplier; -public class CoreJavaIoUnitTest { +public class JavaInputStreamToXUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); private static final int DEFAULT_SIZE = 150000000; diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java new file mode 100644 index 000000000000..c5b35bc9f56e --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java @@ -0,0 +1,41 @@ +package org.baeldung.java.io; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSource; + +@SuppressWarnings("unused") +public class JavaXToInputStreamUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + @Test + public void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); + final byte[] buffer = new byte[targetStream.available()]; + targetStream.read(buffer); + final String targetString = new String(buffer); + } + + @Test + public void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final CharSource source = CharSource.wrap(initialString); + final Reader targetStream = source.openStream(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = IOUtils.toInputStream(initialString); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java index 3a54dfb9ec37..5096725eced3 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -1,5 +1,9 @@ package org.baeldung.httpclient; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.conn.ConnectionRequest; @@ -7,16 +11,19 @@ import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.junit.Test; +@SuppressWarnings("unused") public class HttpClientConnectionManagementTest { // tests @Test - public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() { + public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() throws IOException, HttpException, InterruptedException, ExecutionException { final HttpClientContext context = HttpClientContext.create(); final BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager(); final HttpRoute route = new HttpRoute(new HttpHost("localhost", 80)); final ConnectionRequest connRequest = connManager.requestConnection(route, null); + + connManager.shutdown(); } } From d8a7a0b70c06648ce7d92fef061c152dc335670d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Jun 2014 11:49:21 +0300 Subject: [PATCH 549/796] java conversion work --- .../java/io/JavaInputStreamToXUnitTest.java | 32 +++++++++++++++---- .../java/io/JavaXToInputStreamUnitTest.java | 18 +++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index 579d4b3a728d..eb1215fdc65f 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -22,20 +22,20 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Charsets; +import com.google.common.io.ByteSource; +import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; import com.google.common.io.InputSupplier; +@SuppressWarnings("unused") public class JavaInputStreamToXUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); - private static final int DEFAULT_SIZE = 150000000; - - // private static final int DEFAULT_SIZE = 8; + private static final int DEFAULT_SIZE = 1500000; // tests - InputStream to String - // 11s @Test - public void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + public final void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); @@ -49,7 +49,6 @@ public void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() t assertEquals(textBuilder.toString(), originalString); } - // 8s @Test public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { final String originalString = randomAlphabetic(DEFAULT_SIZE); @@ -120,4 +119,25 @@ public final void givenUsingCommonsIoWithCopy_whenConvertingAnInputStreamToAStri assertThat(writer.toString(), equalTo(originalString)); } + // tests - InputStream to byte[] + + @Test + public final void givenUsingPlainJava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + final byte[] targetArray = new byte[initialStream.available()]; + initialStream.read(targetArray); + } + + @Test + public final void givenUsingGuava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream initialStream = ByteSource.wrap(new byte[] { 0, 1, 2 }).openStream(); + final byte[] targetArray = ByteStreams.toByteArray(initialStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final ByteArrayInputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + final byte[] targetArray = IOUtils.toByteArray(initialStream); + } + } diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java index c5b35bc9f56e..e6a89cb3b0b1 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java @@ -3,9 +3,9 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.Reader; import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.ReaderInputStream; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,26 +16,26 @@ public class JavaXToInputStreamUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); + // tests - String - InputStream + @Test - public void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); - final byte[] buffer = new byte[targetStream.available()]; - targetStream.read(buffer); - final String targetString = new String(buffer); } @Test - public void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; - final CharSource source = CharSource.wrap(initialString); - final Reader targetStream = source.openStream(); + final InputStream targetStream = new ReaderInputStream(CharSource.wrap(initialString).openStream()); } @Test - public void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { + public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; final InputStream targetStream = IOUtils.toInputStream(initialString); } + // + } From 7e5f20e16620f5800c606013192696948e4a4ac9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Jun 2014 12:48:47 +0300 Subject: [PATCH 550/796] conversion work --- core-java/src/main/resources/sample.txt | 2 + .../java/io/JavaXToInputStreamUnitTest.java | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 core-java/src/main/resources/sample.txt diff --git a/core-java/src/main/resources/sample.txt b/core-java/src/main/resources/sample.txt new file mode 100644 index 000000000000..20f137b41622 --- /dev/null +++ b/core-java/src/main/resources/sample.txt @@ -0,0 +1,2 @@ +line 1 +a second line \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java index e6a89cb3b0b1..f58d66818b0a 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java @@ -1,18 +1,22 @@ package org.baeldung.java.io; import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.ReaderInputStream; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.io.ByteSource; import com.google.common.io.CharSource; +import com.google.common.io.Files; -@SuppressWarnings("unused") public class JavaXToInputStreamUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); @@ -22,20 +26,68 @@ public class JavaXToInputStreamUnitTest { public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); + + IOUtils.closeQuietly(targetStream); } @Test public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; final InputStream targetStream = new ReaderInputStream(CharSource.wrap(initialString).openStream()); + + IOUtils.closeQuietly(targetStream); } @Test public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { final String initialString = "text"; final InputStream targetStream = IOUtils.toInputStream(initialString); + + IOUtils.closeQuietly(targetStream); + } + + // byte array - InputStream + + @Test + public final void givenUsingPlainJava_whenConvertingByteArrayToInputStream_thenCorrect() throws IOException { + final byte[] initialArray = { 0, 1, 2 }; + final InputStream targetStream = new ByteArrayInputStream(initialArray); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingGuava_whenConvertingByteArrayToInputStream_thenCorrect() throws IOException { + final byte[] initialArray = { 0, 1, 2 }; + final InputStream targetStream = ByteSource.wrap(initialArray).openStream(); + + IOUtils.closeQuietly(targetStream); } - // + // File - InputStream + + @Test + public final void givenUsingPlainJava_whenConvertingFileToInputStream_thenCorrect() throws IOException { + final File initialFile = new File("src/main/resources/sample.txt"); + final InputStream targetStream = new FileInputStream(initialFile); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingGuava_whenConvertingFileToInputStream_thenCorrect() throws IOException { + final File initialFile = new File("src/main/resources/sample.txt"); + final InputStream targetStream = Files.asByteSource(initialFile).openStream(); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingFileToInputStream_thenCorrect() throws IOException { + final File initialFile = new File("src/main/resources/sample.txt"); + final InputStream targetStream = FileUtils.openInputStream(initialFile); + + IOUtils.closeQuietly(targetStream); + } } From df3b2605e33d8b426c67946e010b1c35ff027f44 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 21 Jun 2014 18:31:20 +0300 Subject: [PATCH 551/796] file conversion work --- core-java/src/main/resources/targetFile.tmp | 2 + .../java/io/JavaInputStreamToXUnitTest.java | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 core-java/src/main/resources/targetFile.tmp diff --git a/core-java/src/main/resources/targetFile.tmp b/core-java/src/main/resources/targetFile.tmp new file mode 100644 index 000000000000..20f137b41622 --- /dev/null +++ b/core-java/src/main/resources/targetFile.tmp @@ -0,0 +1,2 @@ +line 1 +a second line \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index eb1215fdc65f..7247ab1eb93c 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -7,15 +7,20 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.Reader; import java.io.StringWriter; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Scanner; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.slf4j.Logger; @@ -25,6 +30,7 @@ import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; +import com.google.common.io.Files; import com.google.common.io.InputSupplier; @SuppressWarnings("unused") @@ -140,4 +146,41 @@ public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_th final byte[] targetArray = IOUtils.toByteArray(initialStream); } + // tests - InputStream to File + + @Test + public final void givenUsingPlainJava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt")); + final byte[] buffer = new byte[initialStream.available()]; + initialStream.read(buffer); + + final File targetFile = new File("src/main/resources/targetFile.tmp"); + final OutputStream outStream = new FileOutputStream(targetFile); + outStream.write(buffer); + + IOUtils.closeQuietly(initialStream); + IOUtils.closeQuietly(outStream); + } + + @Test + public final void givenUsingGuava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt")); + final byte[] buffer = new byte[initialStream.available()]; + initialStream.read(buffer); + + final File targetFile = new File("src/main/resources/targetFile.tmp"); + Files.write(buffer, targetFile); + + IOUtils.closeQuietly(initialStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException { + final InputStream initialStream = FileUtils.openInputStream(new File("src/main/resources/sample.txt")); + + final File targetFile = new File("src/main/resources/targetFile.tmp"); + + FileUtils.copyInputStreamToFile(initialStream, targetFile); + } + } From a48a53ad57403b035bd2cde1ae192eeb6906c494 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Jun 2014 01:05:20 +0300 Subject: [PATCH 552/796] early testing work --- .../java/io/JavaFileIntegrationTest.java | 75 +++++++++++++++++++ core-java/src/test/resources/fileMoved.txt | 0 core-java/src/test/resources/newFile1.txt | 0 core-java/src/test/resources/newFile2.txt | 0 core-java/src/test/resources/newFile3.txt | 0 5 files changed, 75 insertions(+) create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java create mode 100644 core-java/src/test/resources/fileMoved.txt create mode 100644 core-java/src/test/resources/newFile1.txt create mode 100644 core-java/src/test/resources/newFile2.txt create mode 100644 core-java/src/test/resources/newFile3.txt diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java new file mode 100644 index 000000000000..5f8bf0ee84ad --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java @@ -0,0 +1,75 @@ +package org.baeldung.java.io; + +import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystemException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.junit.Test; + +public class JavaFileIntegrationTest { + + // create a file + + @Test + public void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException { + final File newFile = new File("src/test/resources/newFile_jdk6.txt"); + newFile.createNewFile(); + } + + @Test + public void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOException { + final Path newFilePath = Paths.get("src/test/resources/newFile_jdk7.txt"); + Files.createFile(newFilePath); + } + + @Test + public void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException { + FileUtils.touch(new File("src/test/resources/newFile_commonsio.txt")); + } + + // move a file + + @Test + public void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException { + final File fileToMove = new File("src/test/resources/toMoveFile_jdk6.txt"); + fileToMove.exists(); + final File destDir = new File("src/test/resources/"); + destDir.mkdir(); + + final boolean isMoved = fileToMove.renameTo(new File("src/test/resources/movedFile_jdk6.txt")); + if (!isMoved) { + throw new FileSystemException("src/test/resources/movedFile_jdk6.txt"); + } + } + + @Test + public void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException { + final Path fileToMovePath = Files.createFile(Paths.get("src/test/resources/fileToMove.txt")); + final Path dirPath = Paths.get("src/test/resources/"); + final Path targetPath = Files.createDirectory(dirPath); + + Files.move(fileToMovePath, targetPath.resolve(fileToMovePath.getFileName())); + } + + @Test + public void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException { + final File fileToMove = new File("src/test/resources/fileToMove.txt"); + fileToMove.createNewFile(); + final File destDir = new File("src/test/resources/"); + final File targetFile = new File(destDir, fileToMove.getName()); + com.google.common.io.Files.createParentDirs(targetFile); + com.google.common.io.Files.move(fileToMove, targetFile); + } + + @Test + public void givenUsingApache_whenMovingFile_thenCorrect() throws IOException { + FileUtils.moveFile(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/test/resources/fileMoved.txt")); + } + + // rename a file + +} diff --git a/core-java/src/test/resources/fileMoved.txt b/core-java/src/test/resources/fileMoved.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/core-java/src/test/resources/newFile1.txt b/core-java/src/test/resources/newFile1.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/core-java/src/test/resources/newFile2.txt b/core-java/src/test/resources/newFile2.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/core-java/src/test/resources/newFile3.txt b/core-java/src/test/resources/newFile3.txt new file mode 100644 index 000000000000..e69de29bb2d1 From 0c7f708028b3a00d36b4e06bbf55d19c4ac9110c Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 25 Jun 2014 12:54:06 +0300 Subject: [PATCH 553/796] IO work --- .../resources/fileToMove.txt} | 0 .../java/io/JavaFileIntegrationTest.java | 20 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) rename core-java/src/{test/resources/fileMoved.txt => main/resources/fileToMove.txt} (100%) diff --git a/core-java/src/test/resources/fileMoved.txt b/core-java/src/main/resources/fileToMove.txt similarity index 100% rename from core-java/src/test/resources/fileMoved.txt rename to core-java/src/main/resources/fileToMove.txt diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java index 5f8bf0ee84ad..0ce720c80a99 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java @@ -15,26 +15,26 @@ public class JavaFileIntegrationTest { // create a file @Test - public void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException { + public final void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException { final File newFile = new File("src/test/resources/newFile_jdk6.txt"); newFile.createNewFile(); } @Test - public void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOException { + public final void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOException { final Path newFilePath = Paths.get("src/test/resources/newFile_jdk7.txt"); Files.createFile(newFilePath); } @Test - public void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException { + public final void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException { FileUtils.touch(new File("src/test/resources/newFile_commonsio.txt")); } // move a file @Test - public void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException { + public final void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException { final File fileToMove = new File("src/test/resources/toMoveFile_jdk6.txt"); fileToMove.exists(); final File destDir = new File("src/test/resources/"); @@ -47,7 +47,7 @@ public void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException { } @Test - public void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException { + public final void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException { final Path fileToMovePath = Files.createFile(Paths.get("src/test/resources/fileToMove.txt")); final Path dirPath = Paths.get("src/test/resources/"); final Path targetPath = Files.createDirectory(dirPath); @@ -56,7 +56,7 @@ public void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException { } @Test - public void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException { + public final void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException { final File fileToMove = new File("src/test/resources/fileToMove.txt"); fileToMove.createNewFile(); final File destDir = new File("src/test/resources/"); @@ -66,10 +66,16 @@ public void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException { } @Test - public void givenUsingApache_whenMovingFile_thenCorrect() throws IOException { + public final void givenUsingApache_whenMovingFile_thenCorrect() throws IOException { FileUtils.moveFile(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/test/resources/fileMoved.txt")); } + @Test + public final void givenUsingApache_whenMovingFileApproach2_thenCorrect() throws IOException { + FileUtils.touch(new File("src/test/resources/fileToMove.txt")); + FileUtils.moveFileToDirectory(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/main/resources/"), true); + } + // rename a file } From a1ff4c69002a92cf28a45e50f59ca88fac03ac57 Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Wed, 25 Jun 2014 07:06:38 -0400 Subject: [PATCH 554/796] Map ignore null value and null key serializer --- .../jackson/dtos/MyDtoNullKeySerializer.java | 19 +++++ .../JacksonSerializationIgnoreUnitTest.java | 79 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java new file mode 100644 index 000000000000..ab8ac6249d12 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java @@ -0,0 +1,19 @@ +package org.baeldung.jackson.dtos; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class MyDtoNullKeySerializer extends JsonSerializer { + + @Override + public void serialize(final Object value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + + jgen.writeFieldName(""); + + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java index 062bcc99dffa..c973584f9be2 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -5,9 +5,12 @@ import static org.junit.Assert.assertThat; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.baeldung.jackson.dtos.MyDto; import org.baeldung.jackson.dtos.MyDtoIncludeNonDefault; +import org.baeldung.jackson.dtos.MyDtoNullKeySerializer; import org.baeldung.jackson.dtos.MyDtoWithFilter; import org.baeldung.jackson.dtos.MyMixInForString; import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreField; @@ -20,6 +23,7 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; import com.fasterxml.jackson.databind.ser.FilterProvider; @@ -183,4 +187,79 @@ public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField System.out.println(dtoAsString); } + @Test + public final void givenIgnoringMapNullValue_whenWritingMapObjectWithNullValue_thenIgnored() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); + + final MyDto dtoObject1 = new MyDto(); + + final Map dtoMap = new HashMap(); + dtoMap.put("dtoObject1", dtoObject1); + dtoMap.put("dtoObject2", null); + + final String dtoMapAsString = mapper.writeValueAsString(dtoMap); + + assertThat(dtoMapAsString, containsString("dtoObject1")); + assertThat(dtoMapAsString, not(containsString("dtoObject2"))); + System.out.println(dtoMapAsString); + } + + @Test + public final void givenIgnoringMapValueObjectWithNullField_whenWritingMapValueObjectWithNullField_thenIgnored() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + + final MyDto dtoObject = new MyDto(); + + final Map dtoMap = new HashMap(); + dtoMap.put("dtoObject", dtoObject); + + final String dtoMapAsString = mapper.writeValueAsString(dtoMap); + + assertThat(dtoMapAsString, containsString("dtoObject")); + assertThat(dtoMapAsString, not(containsString("stringValue"))); + System.out.println(dtoMapAsString); + } + + @Test + public final void givenAllowingMapObjectWithNullKey_whenWritingMapObjectWithNullKey_thenAllowed() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.getSerializerProvider().setNullKeySerializer(new MyDtoNullKeySerializer()); + + final MyDto dtoObject = new MyDto(); + dtoObject.setStringValue("dtoObjectString"); + + final Map dtoMap = new HashMap(); + dtoMap.put(null, dtoObject); + + final String dtoMapAsString = mapper.writeValueAsString(dtoMap); + + assertThat(dtoMapAsString, containsString("")); + assertThat(dtoMapAsString, containsString("dtoObjectString")); + System.out.println(dtoMapAsString); + } + + @Test + public final void givenAllowingMapObjectOneNullKey_whenWritingMapObjectWithTwoNullKeys_thenOverride() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.getSerializerProvider().setNullKeySerializer(new MyDtoNullKeySerializer()); + + final MyDto dtoObject1 = new MyDto(); + dtoObject1.setStringValue("dtoObject1String"); + + final MyDto dtoObject2 = new MyDto(); + dtoObject2.setStringValue("dtoObject2String"); + + final Map dtoMap = new HashMap(); + dtoMap.put(null, dtoObject1); + dtoMap.put(null, dtoObject2); + + final String dtoMapAsString = mapper.writeValueAsString(dtoMap); + + assertThat(dtoMapAsString, not(containsString("dtoObject1String"))); + assertThat(dtoMapAsString, containsString("dtoObject2String")); + System.out.println(dtoMapAsString); + } + } From e5c20ff0ba8ff516422f5102ff2c46544bf068e8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 26 Jun 2014 01:37:52 +0300 Subject: [PATCH 555/796] cleanup work --- .../{dtos => serialization}/MyDtoNullKeySerializer.java | 4 +--- .../jackson/test/JacksonSerializationIgnoreUnitTest.java | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) rename jackson/src/test/java/org/baeldung/jackson/{dtos => serialization}/MyDtoNullKeySerializer.java (89%) diff --git a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java b/jackson/src/test/java/org/baeldung/jackson/serialization/MyDtoNullKeySerializer.java similarity index 89% rename from jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java rename to jackson/src/test/java/org/baeldung/jackson/serialization/MyDtoNullKeySerializer.java index ab8ac6249d12..8219abaddf7a 100644 --- a/jackson/src/test/java/org/baeldung/jackson/dtos/MyDtoNullKeySerializer.java +++ b/jackson/src/test/java/org/baeldung/jackson/serialization/MyDtoNullKeySerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.jackson.dtos; +package org.baeldung.jackson.serialization; import java.io.IOException; @@ -11,9 +11,7 @@ public class MyDtoNullKeySerializer extends JsonSerializer { @Override public void serialize(final Object value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { - jgen.writeFieldName(""); - } } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java index c973584f9be2..d0e0426ff0d5 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java @@ -10,12 +10,12 @@ import org.baeldung.jackson.dtos.MyDto; import org.baeldung.jackson.dtos.MyDtoIncludeNonDefault; -import org.baeldung.jackson.dtos.MyDtoNullKeySerializer; import org.baeldung.jackson.dtos.MyDtoWithFilter; import org.baeldung.jackson.dtos.MyMixInForString; import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreField; import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreFieldByName; import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreNull; +import org.baeldung.jackson.serialization.MyDtoNullKeySerializer; import org.junit.Test; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -187,6 +187,8 @@ public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField System.out.println(dtoAsString); } + // map + @Test public final void givenIgnoringMapNullValue_whenWritingMapObjectWithNullValue_thenIgnored() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); From a4c585e489e35530a2a5306eb44788ea436a47b8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 28 Jun 2014 16:06:47 +0300 Subject: [PATCH 556/796] IO work --- .../java/io/JavaFileIntegrationTest.java | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java index 0ce720c80a99..cc0014dc7caa 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java @@ -1,5 +1,7 @@ package org.baeldung.java.io; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.nio.file.FileSystemException; @@ -17,7 +19,9 @@ public class JavaFileIntegrationTest { @Test public final void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException { final File newFile = new File("src/test/resources/newFile_jdk6.txt"); - newFile.createNewFile(); + final boolean success = newFile.createNewFile(); + + assertTrue(success); } @Test @@ -27,7 +31,7 @@ public final void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOExc } @Test - public final void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException { + public final void givenUsingCommonsIo_whenCreatingFile_thenCorrect() throws IOException { FileUtils.touch(new File("src/test/resources/newFile_commonsio.txt")); } @@ -76,6 +80,41 @@ public final void givenUsingApache_whenMovingFileApproach2_thenCorrect() throws FileUtils.moveFileToDirectory(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/main/resources/"), true); } - // rename a file + // delete a file + + @Test + public final void givenUsingJDK6_whenDeletingAFile_thenCorrect() throws IOException { + new File("src/test/resources/fileToDelete_jdk6.txt").createNewFile(); + + final File fileToDelete = new File("src/test/resources/fileToDelete_jdk6.txt"); + final boolean success = fileToDelete.delete(); + + assertTrue(success); + } + + @Test + public final void givenUsingJDK7nio2_whenDeletingAFile_thenCorrect() throws IOException { + // Files.createFile(Paths.get("src/test/resources/fileToDelete_jdk7.txt")); + + final Path fileToDeletePath = Paths.get("src/test/resources/fileToDelete_jdk7.txt"); + Files.delete(fileToDeletePath); + } + + @Test + public final void givenUsingCommonsIo_whenDeletingAFileV1_thenCorrect() throws IOException { + FileUtils.touch(new File("src/test/resources/fileToDelete_commonsIo.txt")); + + final File fileToDelete = FileUtils.getFile("src/test/resources/fileToDelete_commonsIo.txt"); + final boolean success = FileUtils.deleteQuietly(fileToDelete); + + assertTrue(success); + } + + @Test + public void givenUsingCommonsIo_whenDeletingAFileV2_thenCorrect() throws IOException { + // FileUtils.touch(new File("src/test/resources/fileToDelete.txt")); + + FileUtils.forceDelete(FileUtils.getFile("src/test/resources/fileToDelete.txt")); + } } From 463f14a965d9c3176931afaeab980db2371f5791 Mon Sep 17 00:00:00 2001 From: Dheeraj-Baluja Date: Tue, 1 Jul 2014 01:06:33 +0530 Subject: [PATCH 557/796] adde a new project for Using Spring Forms --- .../WebContent/META-INF/MANIFEST.MF | 3 ++ .../WebContent/WEB-INF/dispatcher-servlet.xml | 27 +++++++++++++ .../WEB-INF/views/employeeAdded.jsp | 24 ++++++++++++ .../WebContent/WEB-INF/views/employeeHome.jsp | 38 +++++++++++++++++++ .../WebContent/WEB-INF/views/error.jsp | 20 ++++++++++ .../WebContent/WEB-INF/web.xml | 16 ++++++++ SpringMVCFormExample/WebContent/index.jsp | 18 +++++++++ .../demo/controllers/EmployeeController.java | 34 +++++++++++++++++ .../src/com/demo/form/Employee.java | 33 ++++++++++++++++ 9 files changed, 213 insertions(+) create mode 100644 SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF create mode 100644 SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml create mode 100644 SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp create mode 100644 SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp create mode 100644 SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp create mode 100644 SpringMVCFormExample/WebContent/WEB-INF/web.xml create mode 100644 SpringMVCFormExample/WebContent/index.jsp create mode 100644 SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java create mode 100644 SpringMVCFormExample/src/com/demo/form/Employee.java diff --git a/SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF b/SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 000000000000..254272e1c074 --- /dev/null +++ b/SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml b/SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml new file mode 100644 index 000000000000..1fc94effba9a --- /dev/null +++ b/SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml @@ -0,0 +1,27 @@ + + + + + + + + + + /WEB-INF/views/ + + + .jsp + + + + \ No newline at end of file diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp b/SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp new file mode 100644 index 000000000000..1457bc5fc8d3 --- /dev/null +++ b/SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp @@ -0,0 +1,24 @@ +<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> + + +Spring MVC Form Handling + + + +

Submitted Employee Information

+ + + + + + + + + + + + + +
Name :${name}
ID :${id}
Contact Number :${contactNumber}
+ + \ No newline at end of file diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp b/SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp new file mode 100644 index 000000000000..f86fc1914675 --- /dev/null +++ b/SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp @@ -0,0 +1,38 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + + + +SpringMVCExample + + + +

Welcome, Enter The Employee Details

+ + + + + + + + + + + + + + + + + + +
Name
Id
Contact Number
+
+ + + + \ No newline at end of file diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp b/SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp new file mode 100644 index 000000000000..8f3d83af1767 --- /dev/null +++ b/SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp @@ -0,0 +1,20 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +SpringMVCExample + + + +

Pleas enter the correct details

+ + + + +
Retry
+ + + + \ No newline at end of file diff --git a/SpringMVCFormExample/WebContent/WEB-INF/web.xml b/SpringMVCFormExample/WebContent/WEB-INF/web.xml new file mode 100644 index 000000000000..47dd114f2aa9 --- /dev/null +++ b/SpringMVCFormExample/WebContent/WEB-INF/web.xml @@ -0,0 +1,16 @@ + + + SpringMVCFormExample + + dispatcher + org.springframework.web.servlet.DispatcherServlet + 1 + + + dispatcher + / + + + index.jsp + + \ No newline at end of file diff --git a/SpringMVCFormExample/WebContent/index.jsp b/SpringMVCFormExample/WebContent/index.jsp new file mode 100644 index 000000000000..1ecfcec9d755 --- /dev/null +++ b/SpringMVCFormExample/WebContent/index.jsp @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Spring MVC Examples + + + +

Spring MVC Examples

+ + + + \ No newline at end of file diff --git a/SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java b/SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java new file mode 100644 index 000000000000..d4bc8e44ad64 --- /dev/null +++ b/SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java @@ -0,0 +1,34 @@ +package com.demo.controllers; + +import javax.validation.Valid; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +import com.demo.form.Employee; + +@Controller +public class EmployeeController { + + @RequestMapping(value = "/employee", method = RequestMethod.GET) + public ModelAndView showForm() { + return new ModelAndView("employeeHome", "employee", new Employee()); + } + + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) + public String submit(@Valid @ModelAttribute("employee")Employee employee, BindingResult result, + ModelMap model) { + if (result.hasErrors()) { + return "error"; + } + model.addAttribute("name", employee.getName()); + model.addAttribute("contactNumber", employee.getContactNumber()); + model.addAttribute("id", employee.getId()); + return "employeeAdded"; + } +} diff --git a/SpringMVCFormExample/src/com/demo/form/Employee.java b/SpringMVCFormExample/src/com/demo/form/Employee.java new file mode 100644 index 000000000000..cf7fb574cf0e --- /dev/null +++ b/SpringMVCFormExample/src/com/demo/form/Employee.java @@ -0,0 +1,33 @@ +package com.demo.form; + +public class Employee { + + private String name; + private long id; + private String contactNumber; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + +} From aad3a856d9be329abc779459f40f62f3483461b2 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 1 Jul 2014 08:44:37 -0500 Subject: [PATCH 558/796] HttpClientConnectionManager Tests First Pull --- .../HttpClientConnectionManagementTest.java | 356 +++++++++++++++++- .../IdleConnectionMonitorThread.java | 39 ++ .../httpclient/MultiHttpClientConnThread.java | 61 +++ ...sterVersion_MultiHttpClientConnThread.java | 49 +++ 4 files changed, 499 insertions(+), 6 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java index 5096725eced3..37f7b07145fd 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -1,29 +1,373 @@ package org.baeldung.httpclient; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import org.apache.http.HeaderElement; +import org.apache.http.HeaderElementIterator; +import org.apache.http.HttpClientConnection; import org.apache.http.HttpException; import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.config.SocketConfig; +import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.conn.ConnectionRequest; import org.apache.http.conn.routing.HttpRoute; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.message.BasicHeaderElementIterator; +import org.apache.http.protocol.HTTP; +import org.apache.http.protocol.HttpContext; +import org.apache.http.protocol.HttpCoreContext; +import org.apache.http.protocol.HttpRequestExecutor; +import org.apache.http.util.EntityUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -@SuppressWarnings("unused") + public class HttpClientConnectionManagementTest { + private BasicHttpClientConnectionManager basicConnManager; + private HttpClientContext context; + private HttpRoute route; + private static final String SERVER1 = "http://echo.200please.com"; + private static final String SERVER7 = "http://localhost"; + private HttpGet get1; + private HttpGet get2; + private static CloseableHttpResponse response; + private HttpClientConnection conn1; + private HttpClientConnection conn; + private HttpClientConnection conn2; + private PoolingHttpClientConnectionManager poolingConnManager; + private CloseableHttpClient client; + + @Before + public final void before() { + get1 = new HttpGet(SERVER1); + get2 = new HttpGet(SERVER7); + route = new HttpRoute(new HttpHost("localhost", 80)); + } + + @After + public final void after() throws IllegalStateException, IOException { + if (conn != null) + conn.close(); + if (conn1 != null) + conn1.close(); + if (conn2 != null) + conn2.close(); + if (poolingConnManager != null) + poolingConnManager.shutdown(); + if (basicConnManager != null) + basicConnManager.shutdown(); + if (client != null) + client.close(); + if (response != null) + response.close(); + + } // tests @Test + @Ignore + // 2.1 IN ARTCLE public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() throws IOException, HttpException, InterruptedException, ExecutionException { - final HttpClientContext context = HttpClientContext.create(); - final BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager(); - final HttpRoute route = new HttpRoute(new HttpHost("localhost", 80)); - final ConnectionRequest connRequest = connManager.requestConnection(route, null); + basicConnManager = new BasicHttpClientConnectionManager(); + final ConnectionRequest connRequest = basicConnManager.requestConnection(route, null); + assertTrue(connRequest.get(1000, TimeUnit.SECONDS) != null); + } + + @Test + @Ignore + // 2.2 IN ARTICLE + public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { + basicConnManager = new BasicHttpClientConnectionManager(); + context = HttpClientContext.create(); + final ConnectionRequest connRequest = basicConnManager.requestConnection(route, null); + conn = connRequest.get(1000, TimeUnit.SECONDS); + if (!conn.isOpen()) + basicConnManager.connect(conn, route, 1000, context); + conn.setSocketTimeout(30000); + + assertTrue(conn.getSocketTimeout() == 30000); + assertTrue(conn.isOpen()); + } + + @Test + @Ignore + // Example 3.1. TESTER VERSION + public final void WhenTwoConnectionsForTwoRequests_ThenLeaseTwoConnectionsNoExceptions() throws InterruptedException { + get1 = new HttpGet("http://localhost"); + get2 = new HttpGet("http://google.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client1, get1, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client2, get2, poolingConnManager); + thread1.start(); + thread1.join(); + thread2.start(); + assertTrue(poolingConnManager.getTotalStats().getLeased() == 1); + thread2.join(1000); + assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); + } + + @Test + @Ignore + // Example 3.1.ARTICLE VERSION + public final void WhenTwoConnectionsForTwoRequests_ThensNoExceptions() throws InterruptedException { + get1 = new HttpGet("http://localhost"); + get2 = new HttpGet("http://google.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client1, get1); + final MultiHttpClientConnThread thread2 = new MultiHttpClientConnThread(client2, get2); + thread1.start(); + thread1.join(); + thread2.start(); + thread2.join(); + } + + @Test + @Ignore + // 3.3 + public final void whenIncreasingConnectionPool_thenNoEceptions() { + + poolingConnManager = new PoolingHttpClientConnectionManager(); + poolingConnManager.setMaxTotal(5); + poolingConnManager.setDefaultMaxPerRoute(4); + final HttpHost localhost = new HttpHost("locahost", 80); + poolingConnManager.setMaxPerRoute(new HttpRoute(localhost), 5); + } + + @Test + @Ignore + // 3.4 Tester Version + public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimitNoExceptions() throws InterruptedException, IOException { + final HttpGet get = new HttpGet("http://google.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread3 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + thread1.start(); + thread1.join(1000); + assertTrue(poolingConnManager.getTotalStats().getLeased() == 1); + thread2.start(); + thread2.join(1000); + assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); + thread3.start(); + thread3.join(1000); + } + + @Test + @Ignore + // 3.4 Article version + public final void whenExecutingSameRequestsInDifferentThreads_thenExxecuteReuqesttNoExceptions() throws InterruptedException { + final HttpGet get = new HttpGet("http://localhost"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client, get); + final MultiHttpClientConnThread thread2 = new MultiHttpClientConnThread(client, get); + final MultiHttpClientConnThread thread3 = new MultiHttpClientConnThread(client, get); + thread1.start(); + thread2.start(); + thread3.start(); + thread1.join(); + thread2.join(); + thread3.join(); + } + + @Test + @Ignore + // 4.1 + public final void whenCustomizingKeepAliveStrategy_thenNoExceptions() throws ClientProtocolException, IOException { + final ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() { + @Override + public long getKeepAliveDuration(final HttpResponse myResponse, final HttpContext myContext) { + final HeaderElementIterator it = new BasicHeaderElementIterator(myResponse.headerIterator(HTTP.CONN_KEEP_ALIVE)); + while (it.hasNext()) { + final HeaderElement he = it.nextElement(); + final String param = he.getName(); + final String value = he.getValue(); + if (value != null && param.equalsIgnoreCase("timeout")) { + return Long.parseLong(value) * 1000; + } + } + final HttpHost target = (HttpHost) myContext.getAttribute(HttpCoreContext.HTTP_TARGET_HOST); + if ("localhost".equalsIgnoreCase(target.getHostName())) { + return 10 * 1000; + } else { + return 5 * 1000; + } + } + + }; + client = HttpClients.custom().setKeepAliveStrategy(myStrategy).setConnectionManager(poolingConnManager).build(); + client.execute(get1); + client.execute(get2); + } + + @Test + @Ignore + // 5.1 + public final void GivenBasicHttpClientConnManager_whenConnectionReuse_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { + basicConnManager = new BasicHttpClientConnectionManager(); + context = HttpClientContext.create(); + final HttpGet get = new HttpGet("http://localhost"); + HttpResponse thisResponse = null; + final ConnectionRequest connRequest = basicConnManager.requestConnection(route, null); + client = HttpClients.custom().setConnectionManager(basicConnManager).build(); + boolean respAvail = false; + conn = connRequest.get(10, TimeUnit.SECONDS); + if (!conn.isOpen()) { + basicConnManager.connect(conn, route, 1000, context); + basicConnManager.routeComplete(conn, route, context); + final HttpRequestExecutor exeRequest = new HttpRequestExecutor(); + context.setTargetHost((new HttpHost("localhost", 80))); + thisResponse = exeRequest.execute(get, conn, context); + respAvail = conn.isResponseAvailable(1000); + } + basicConnManager.releaseConnection(conn, null, 1, TimeUnit.SECONDS); + if (respAvail) { + client.execute(get); + } + } + + @Test + @Ignore + // 5.2 TESTER VERSION + public final void WhenConnectionsNeededGreaterThanMaxTotal_thenReuseConnectionsNoExceptions() throws InterruptedException { + poolingConnManager = new PoolingHttpClientConnectionManager(); + poolingConnManager.setDefaultMaxPerRoute(5); + poolingConnManager.setMaxTotal(5); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final MultiHttpClientConnThread[] threads = new MultiHttpClientConnThread[10]; + int countConnMade = 0; + for (int i = 0; i < threads.length; i++) { + threads[i] = new MultiHttpClientConnThread(client, get1, poolingConnManager); + } + for (final MultiHttpClientConnThread thread : threads) { + thread.start(); + } + for (final MultiHttpClientConnThread thread : threads) { + thread.join(10000); + countConnMade++; + if (countConnMade == 0) + assertTrue(thread.getLeasedConn() == 5); + } + } + + @Test + // 5.2 ARTICLE VERSION + @Ignore + public final void WhenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuseNoExceptions() throws InterruptedException { + final HttpGet get = new HttpGet("http://echo.200please.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + poolingConnManager.setDefaultMaxPerRoute(5); + poolingConnManager.setMaxTotal(5); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final MultiHttpClientConnThread[] threads = new MultiHttpClientConnThread[10]; + for (int i = 0; i < threads.length; i++) { + threads[i] = new MultiHttpClientConnThread(client, get, poolingConnManager); + } + for (final MultiHttpClientConnThread thread : threads) { + thread.start(); + } + for (final MultiHttpClientConnThread thread : threads) { + thread.join(10000); + } + } - connManager.shutdown(); + @Test + @Ignore + // 6.2.1 + public final void whenConfiguringTimeOut_thenNoExceptions() { + route = new HttpRoute(new HttpHost("localhost", 80)); + poolingConnManager = new PoolingHttpClientConnectionManager(); + poolingConnManager.setSocketConfig(route.getTargetHost(), SocketConfig.custom().setSoTimeout(5000).build()); + assertTrue(poolingConnManager.getSocketConfig(route.getTargetHost()).getSoTimeout() == 5000); } + @Test + @Ignore + // 7.1 + public final void whenHttpClientChecksStaleConns_thenNoExceptions() { + poolingConnManager = new PoolingHttpClientConnectionManager(); + client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().setStaleConnectionCheckEnabled(true).build()).setConnectionManager(poolingConnManager).build(); + } + + @Test + @Ignore + // 7.2 TESTER VERSION + public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConnsNoExceptions() throws InterruptedException, IOException { + poolingConnManager = new PoolingHttpClientConnectionManager(); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager); + final HttpGet get = new HttpGet("http://google.com"); + // test this with new HttpGet("http://iotechperu.com")----First test will fail b/c there is redirect connection at that site + final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread3 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + staleMonitor.start(); + thread1.start(); + thread1.join(); + thread2.start(); + thread2.join(); + thread3.start(); + assertTrue(poolingConnManager.getTotalStats().getAvailable() == 1); + thread3.join(32000); + assertTrue(poolingConnManager.getTotalStats().getAvailable() == 0); + } + + @Test + @Ignore + // 7.2 ARTICLE VERSION + public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException { + final HttpGet get = new HttpGet("http://google.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager); + staleMonitor.start(); + staleMonitor.join(1000); + } + + @Test(expected = IllegalStateException.class) + @Ignore + // 8.1 + public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { + route = new HttpRoute(new HttpHost("google.com", 80)); + final HttpGet get = new HttpGet("http://google.com"); + poolingConnManager = new PoolingHttpClientConnectionManager(); + final ConnectionRequest connRequest = poolingConnManager.requestConnection(route, null); + context = HttpClientContext.create(); + conn = connRequest.get(10, TimeUnit.SECONDS); + poolingConnManager.connect(conn, route, 10000, context); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + response = client.execute(get); + EntityUtils.consume(response.getEntity()); + client.close(); + conn.close(); + response.close(); + poolingConnManager.close(); + poolingConnManager.shutdown(); + client.execute(get); + conn.sendRequestHeader(get); + assertTrue(!conn.isOpen()); + assertTrue(conn.isOpen()); + assertTrue(response.getEntity() == null); + } } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java b/httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java new file mode 100644 index 000000000000..4c4c7f36a1b8 --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java @@ -0,0 +1,39 @@ +package org.baeldung.httpclient; + +import java.util.concurrent.TimeUnit; + +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; + +public class IdleConnectionMonitorThread extends Thread { + private final HttpClientConnectionManager connMgr; + private volatile boolean shutdown; + + public IdleConnectionMonitorThread(final PoolingHttpClientConnectionManager connMgr) { + super(); + this.connMgr = connMgr; + } + + @Override + public void run() { + try { + while (!shutdown) { + synchronized (this) { + wait(1000); + connMgr.closeExpiredConnections(); + connMgr.closeIdleConnections(30, TimeUnit.SECONDS); + } + } + } catch (final InterruptedException ex) { + shutdown(); + + } + } + + public void shutdown() { + shutdown = true; + synchronized (this) { + notifyAll(); + } + } +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java new file mode 100644 index 000000000000..e2f8fabbdf6f --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java @@ -0,0 +1,61 @@ +package org.baeldung.httpclient; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.util.EntityUtils; + +public class MultiHttpClientConnThread extends Thread { + private final CloseableHttpClient client; + private final HttpGet get; + private PoolingHttpClientConnectionManager connManager = null; + private static HttpResponse response; + private Logger logger; + public int leasedConn; + + public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { + this.client = client; + this.get = get; + this.connManager = connManager; + logger = Logger.getLogger(MultiHttpClientConnThread.class.getName()); + leasedConn = 0; + } + + public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get) { + this.client = client; + this.get = get; + logger = Logger.getLogger(MultiHttpClientConnThread.class.getName()); + } + + public int getLeasedConn() { + return leasedConn; + } + + @Override + public void run() { + + try { + if (this != null) + logger.log(Level.SEVERE, "Thread Running: " + getName()); + response = client.execute(get); + if (connManager != null) { + logger.log(Level.SEVERE, "Leased Connections " + connManager.getTotalStats().getLeased()); + leasedConn = connManager.getTotalStats().getLeased(); + logger.log(Level.SEVERE, "Available Connections " + connManager.getTotalStats().getAvailable()); + } + EntityUtils.consume(response.getEntity()); + + } catch (final ClientProtocolException ex) { + + } catch (final IOException ex) { + + } + + } +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java new file mode 100644 index 000000000000..f71ac7462eca --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java @@ -0,0 +1,49 @@ +package org.baeldung.httpclient; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; + +public class TesterVersion_MultiHttpClientConnThread extends Thread { + private final CloseableHttpClient client; + private final HttpGet get; + private PoolingHttpClientConnectionManager connManager = null; + private Logger logger; + public int leasedConn; + public TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { + this.client = client; + this.get = get; + this.connManager = connManager; + logger = Logger.getLogger(TesterVersion_MultiHttpClientConnThread.class.getName()); + leasedConn = 0; + } + + public int getLeasedConn() { + return leasedConn; + } + + @Override + public void run() { + try { + if (this != null) + logger.log(Level.SEVERE, "Thread Running: " + getName()); + client.execute(get); + if (connManager != null) { + logger.log(Level.SEVERE, "Leased Connections " + connManager.getTotalStats().getLeased()); + leasedConn = connManager.getTotalStats().getLeased(); + logger.log(Level.SEVERE, "Available Connections " + connManager.getTotalStats().getAvailable()); + } + + } catch (final ClientProtocolException ex) { + + } catch (final IOException ex) { + + } + } + +} From c3d7000ff136314634421159969985526f180b47 Mon Sep 17 00:00:00 2001 From: Dheeraj-Baluja Date: Sat, 5 Jul 2014 01:18:51 +0530 Subject: [PATCH 559/796] Formatting done and renamed the project correctly --- .../WebContent/META-INF/MANIFEST.MF | 0 .../WebContent/WEB-INF/dispatcher-servlet.xml | 0 .../WebContent/WEB-INF/views/employeeAdded.jsp | 0 .../WebContent/WEB-INF/views/employeeHome.jsp | 0 .../WebContent/WEB-INF/views/error.jsp | 0 .../WebContent/WEB-INF/web.xml | 0 {SpringMVCFormExample => spring-mvc-forms}/WebContent/index.jsp | 0 .../src/com/demo/controllers/EmployeeController.java | 0 .../src/com/demo/form/Employee.java | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/META-INF/MANIFEST.MF (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/WEB-INF/dispatcher-servlet.xml (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/WEB-INF/views/employeeAdded.jsp (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/WEB-INF/views/employeeHome.jsp (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/WEB-INF/views/error.jsp (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/WEB-INF/web.xml (100%) rename {SpringMVCFormExample => spring-mvc-forms}/WebContent/index.jsp (100%) rename {SpringMVCFormExample => spring-mvc-forms}/src/com/demo/controllers/EmployeeController.java (100%) rename {SpringMVCFormExample => spring-mvc-forms}/src/com/demo/form/Employee.java (100%) diff --git a/SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF b/spring-mvc-forms/WebContent/META-INF/MANIFEST.MF similarity index 100% rename from SpringMVCFormExample/WebContent/META-INF/MANIFEST.MF rename to spring-mvc-forms/WebContent/META-INF/MANIFEST.MF diff --git a/SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml b/spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml similarity index 100% rename from SpringMVCFormExample/WebContent/WEB-INF/dispatcher-servlet.xml rename to spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp similarity index 100% rename from SpringMVCFormExample/WebContent/WEB-INF/views/employeeAdded.jsp rename to spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp similarity index 100% rename from SpringMVCFormExample/WebContent/WEB-INF/views/employeeHome.jsp rename to spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp diff --git a/SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/error.jsp similarity index 100% rename from SpringMVCFormExample/WebContent/WEB-INF/views/error.jsp rename to spring-mvc-forms/WebContent/WEB-INF/views/error.jsp diff --git a/SpringMVCFormExample/WebContent/WEB-INF/web.xml b/spring-mvc-forms/WebContent/WEB-INF/web.xml similarity index 100% rename from SpringMVCFormExample/WebContent/WEB-INF/web.xml rename to spring-mvc-forms/WebContent/WEB-INF/web.xml diff --git a/SpringMVCFormExample/WebContent/index.jsp b/spring-mvc-forms/WebContent/index.jsp similarity index 100% rename from SpringMVCFormExample/WebContent/index.jsp rename to spring-mvc-forms/WebContent/index.jsp diff --git a/SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java b/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java similarity index 100% rename from SpringMVCFormExample/src/com/demo/controllers/EmployeeController.java rename to spring-mvc-forms/src/com/demo/controllers/EmployeeController.java diff --git a/SpringMVCFormExample/src/com/demo/form/Employee.java b/spring-mvc-forms/src/com/demo/form/Employee.java similarity index 100% rename from SpringMVCFormExample/src/com/demo/form/Employee.java rename to spring-mvc-forms/src/com/demo/form/Employee.java From 8434f826e6a631409bdc9fbd705c4240fd7c5207 Mon Sep 17 00:00:00 2001 From: Dheeraj-Baluja Date: Sat, 5 Jul 2014 01:27:10 +0530 Subject: [PATCH 560/796] Formatted the code --- .../WebContent/WEB-INF/views/employeeHome.jsp | 2 +- spring-mvc-forms/WebContent/WEB-INF/web.xml | 31 +++++++------- .../demo/controllers/EmployeeController.java | 29 +++++++------ .../src/com/demo/form/Employee.java | 42 +++++++++---------- 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp index f86fc1914675..497eade8c717 100644 --- a/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp +++ b/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp @@ -12,7 +12,7 @@

Welcome, Enter The Employee Details

- diff --git a/spring-mvc-forms/WebContent/WEB-INF/web.xml b/spring-mvc-forms/WebContent/WEB-INF/web.xml index 47dd114f2aa9..4c122670e511 100644 --- a/spring-mvc-forms/WebContent/WEB-INF/web.xml +++ b/spring-mvc-forms/WebContent/WEB-INF/web.xml @@ -1,16 +1,19 @@ - - SpringMVCFormExample - - dispatcher - org.springframework.web.servlet.DispatcherServlet - 1 - - - dispatcher - / - - - index.jsp - + + SpringMVCFormExample + + dispatcher + org.springframework.web.servlet.DispatcherServlet + + 1 + + + dispatcher + / + + + index.jsp + \ No newline at end of file diff --git a/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java b/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java index d4bc8e44ad64..1dd76ae23f7f 100644 --- a/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java +++ b/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java @@ -15,20 +15,19 @@ @Controller public class EmployeeController { - @RequestMapping(value = "/employee", method = RequestMethod.GET) - public ModelAndView showForm() { - return new ModelAndView("employeeHome", "employee", new Employee()); - } + @RequestMapping(value = "/employee", method = RequestMethod.GET) + public ModelAndView showForm() { + return new ModelAndView("employeeHome", "employee", new Employee()); + } - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) - public String submit(@Valid @ModelAttribute("employee")Employee employee, BindingResult result, - ModelMap model) { - if (result.hasErrors()) { - return "error"; - } - model.addAttribute("name", employee.getName()); - model.addAttribute("contactNumber", employee.getContactNumber()); - model.addAttribute("id", employee.getId()); - return "employeeAdded"; - } + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) + public String submit(@Valid @ModelAttribute("employee") Employee employee, BindingResult result, ModelMap model) { + if (result.hasErrors()) { + return "error"; + } + model.addAttribute("name", employee.getName()); + model.addAttribute("contactNumber", employee.getContactNumber()); + model.addAttribute("id", employee.getId()); + return "employeeAdded"; + } } diff --git a/spring-mvc-forms/src/com/demo/form/Employee.java b/spring-mvc-forms/src/com/demo/form/Employee.java index cf7fb574cf0e..569347b62862 100644 --- a/spring-mvc-forms/src/com/demo/form/Employee.java +++ b/spring-mvc-forms/src/com/demo/form/Employee.java @@ -2,32 +2,32 @@ public class Employee { - private String name; - private long id; - private String contactNumber; + private String name; + private long id; + private String contactNumber; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public String getContactNumber() { - return contactNumber; - } + public String getContactNumber() { + return contactNumber; + } - public void setContactNumber(String contactNumber) { - this.contactNumber = contactNumber; - } + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } } From 0a76200ab4df8717b5fc7ab05ec601cf5de4fa07 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 11:37:59 +0300 Subject: [PATCH 561/796] work on java io tests --- .../java/io/JavaFileIntegrationTest.java | 5 ++ .../java/io/JavaReaderToXUnitTest.java | 46 +++++++++++++++++++ .../HttpClientConnectionManagementTest.java | 44 ++++++++---------- ...sterVersion_MultiHttpClientConnThread.java | 1 + 4 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java index cc0014dc7caa..c139e34afb35 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java @@ -35,6 +35,11 @@ public final void givenUsingCommonsIo_whenCreatingFile_thenCorrect() throws IOEx FileUtils.touch(new File("src/test/resources/newFile_commonsio.txt")); } + @Test + public final void givenUsingGuava_whenCreatingFile_thenCorrect() throws IOException { + com.google.common.io.Files.touch(new File("src/test/resources/newFile_guava.txt")); + } + // move a file @Test diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java new file mode 100644 index 000000000000..4e8b97f381ca --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -0,0 +1,46 @@ +package org.baeldung.java.io; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSource; +import com.google.common.io.CharStreams; + +@SuppressWarnings("unused") +public class JavaReaderToXUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + private static final int DEFAULT_SIZE = 1500000; + + // tests - Reader to String + + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoString_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("text"); + + final char[] mediationArray = new char["text".length()]; + initialReader.read(mediationArray); + initialReader.close(); + final String targetString = new String(mediationArray); + } + + @Test + public void givenUsingGuava_whenConvertingReaderIntoString_thenCorrect() throws IOException { + final Reader initialReader = CharSource.wrap("Google Guava v.17.0").openStream(); + final String targetString = CharStreams.toString(initialReader); + initialReader.close(); + } + + @Test + public void givenUsingCommonsIo_whenConvertingReaderIntoString_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("Apache Commons IO 2.4"); + final String targetString = IOUtils.toString(initialReader); + initialReader.close(); + } + +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java index 37f7b07145fd..2a923585b624 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -33,10 +33,8 @@ import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; - public class HttpClientConnectionManagementTest { private BasicHttpClientConnectionManager basicConnManager; private HttpClientContext context; @@ -75,13 +73,12 @@ public final void after() throws IllegalStateException, IOException { client.close(); if (response != null) response.close(); - } // tests @Test - @Ignore + // @Ignore // 2.1 IN ARTCLE public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() throws IOException, HttpException, InterruptedException, ExecutionException { basicConnManager = new BasicHttpClientConnectionManager(); @@ -90,7 +87,7 @@ public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() throws } @Test - @Ignore + // @Ignore // 2.2 IN ARTICLE public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { basicConnManager = new BasicHttpClientConnectionManager(); @@ -106,11 +103,11 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException } @Test - @Ignore + // @Ignore // Example 3.1. TESTER VERSION public final void WhenTwoConnectionsForTwoRequests_ThenLeaseTwoConnectionsNoExceptions() throws InterruptedException { - get1 = new HttpGet("http://localhost"); - get2 = new HttpGet("http://google.com"); + get1 = new HttpGet("http://www.petrikainulainen.net/"); + get2 = new HttpGet("http://www.baeldung.com/"); poolingConnManager = new PoolingHttpClientConnectionManager(); final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -119,13 +116,12 @@ public final void WhenTwoConnectionsForTwoRequests_ThenLeaseTwoConnectionsNoExce thread1.start(); thread1.join(); thread2.start(); - assertTrue(poolingConnManager.getTotalStats().getLeased() == 1); thread2.join(1000); assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); } @Test - @Ignore + // @Ignore // Example 3.1.ARTICLE VERSION public final void WhenTwoConnectionsForTwoRequests_ThensNoExceptions() throws InterruptedException { get1 = new HttpGet("http://localhost"); @@ -142,10 +138,9 @@ public final void WhenTwoConnectionsForTwoRequests_ThensNoExceptions() throws In } @Test - @Ignore + // @Ignore // 3.3 public final void whenIncreasingConnectionPool_thenNoEceptions() { - poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setMaxTotal(5); poolingConnManager.setDefaultMaxPerRoute(4); @@ -154,7 +149,7 @@ public final void whenIncreasingConnectionPool_thenNoEceptions() { } @Test - @Ignore + // @Ignore // 3.4 Tester Version public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimitNoExceptions() throws InterruptedException, IOException { final HttpGet get = new HttpGet("http://google.com"); @@ -174,7 +169,7 @@ public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConn } @Test - @Ignore + // @Ignore // 3.4 Article version public final void whenExecutingSameRequestsInDifferentThreads_thenExxecuteReuqesttNoExceptions() throws InterruptedException { final HttpGet get = new HttpGet("http://localhost"); @@ -192,7 +187,7 @@ public final void whenExecutingSameRequestsInDifferentThreads_thenExxecuteReuqes } @Test - @Ignore + // @Ignore // 4.1 public final void whenCustomizingKeepAliveStrategy_thenNoExceptions() throws ClientProtocolException, IOException { final ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() { @@ -222,7 +217,7 @@ public long getKeepAliveDuration(final HttpResponse myResponse, final HttpContex } @Test - @Ignore + // @Ignore // 5.1 public final void GivenBasicHttpClientConnManager_whenConnectionReuse_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { basicConnManager = new BasicHttpClientConnectionManager(); @@ -248,7 +243,7 @@ public final void GivenBasicHttpClientConnManager_whenConnectionReuse_thenNoExce } @Test - @Ignore + // @Ignore // 5.2 TESTER VERSION public final void WhenConnectionsNeededGreaterThanMaxTotal_thenReuseConnectionsNoExceptions() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -271,9 +266,9 @@ public final void WhenConnectionsNeededGreaterThanMaxTotal_thenReuseConnectionsN } } - @Test // 5.2 ARTICLE VERSION - @Ignore + @Test + // @Ignore public final void WhenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuseNoExceptions() throws InterruptedException { final HttpGet get = new HttpGet("http://echo.200please.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -293,7 +288,7 @@ public final void WhenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandR } @Test - @Ignore + // @Ignore // 6.2.1 public final void whenConfiguringTimeOut_thenNoExceptions() { route = new HttpRoute(new HttpHost("localhost", 80)); @@ -303,7 +298,7 @@ public final void whenConfiguringTimeOut_thenNoExceptions() { } @Test - @Ignore + // @Ignore // 7.1 public final void whenHttpClientChecksStaleConns_thenNoExceptions() { poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -311,7 +306,7 @@ public final void whenHttpClientChecksStaleConns_thenNoExceptions() { } @Test - @Ignore + // @Ignore // 7.2 TESTER VERSION public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConnsNoExceptions() throws InterruptedException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -334,7 +329,7 @@ public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConnsNoExceptio } @Test - @Ignore + // @Ignore // 7.2 ARTICLE VERSION public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException { final HttpGet get = new HttpGet("http://google.com"); @@ -346,7 +341,7 @@ public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws Interr } @Test(expected = IllegalStateException.class) - @Ignore + // @Ignore // 8.1 public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { route = new HttpRoute(new HttpHost("google.com", 80)); @@ -370,4 +365,5 @@ public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions() t assertTrue(conn.isOpen()); assertTrue(response.getEntity() == null); } + } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java index f71ac7462eca..131761b072f8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java @@ -15,6 +15,7 @@ public class TesterVersion_MultiHttpClientConnThread extends Thread { private PoolingHttpClientConnectionManager connManager = null; private Logger logger; public int leasedConn; + public TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; From 59917554029f536490903e119cc8f296e7ea3a9d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 16:35:52 +0300 Subject: [PATCH 562/796] connection management work --- .../HttpClientConnectionManagementTest.java | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java index 2a923585b624..293564086f9c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java @@ -36,18 +36,22 @@ import org.junit.Test; public class HttpClientConnectionManagementTest { + private static final String SERVER1 = "http://www.petrikainulainen.net/"; + private static final String SERVER7 = "http://www.baeldung.com/"; + private BasicHttpClientConnectionManager basicConnManager; + private PoolingHttpClientConnectionManager poolingConnManager; + private HttpClientContext context; private HttpRoute route; - private static final String SERVER1 = "http://echo.200please.com"; - private static final String SERVER7 = "http://localhost"; - private HttpGet get1; - private HttpGet get2; - private static CloseableHttpResponse response; private HttpClientConnection conn1; private HttpClientConnection conn; private HttpClientConnection conn2; - private PoolingHttpClientConnectionManager poolingConnManager; + + private CloseableHttpResponse response; + private HttpGet get1; + private HttpGet get2; + private CloseableHttpClient client; @Before @@ -75,7 +79,7 @@ public final void after() throws IllegalStateException, IOException { response.close(); } - // tests + // 2 @Test // @Ignore @@ -102,12 +106,11 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException assertTrue(conn.isOpen()); } + // 3 + @Test // @Ignore - // Example 3.1. TESTER VERSION - public final void WhenTwoConnectionsForTwoRequests_ThenLeaseTwoConnectionsNoExceptions() throws InterruptedException { - get1 = new HttpGet("http://www.petrikainulainen.net/"); - get2 = new HttpGet("http://www.baeldung.com/"); + public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -122,10 +125,24 @@ public final void WhenTwoConnectionsForTwoRequests_ThenLeaseTwoConnectionsNoExce @Test // @Ignore - // Example 3.1.ARTICLE VERSION - public final void WhenTwoConnectionsForTwoRequests_ThensNoExceptions() throws InterruptedException { - get1 = new HttpGet("http://localhost"); - get2 = new HttpGet("http://google.com"); + // Example 3.2. TESTER VERSION + /*tester*/public final void whenTwoConnectionsForTwoRequests_thenTwoConnectionsAreLeased() throws InterruptedException { + poolingConnManager = new PoolingHttpClientConnectionManager(); + final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client1, get1, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client2, get2, poolingConnManager); + thread1.start(); + thread1.join(); + thread2.start(); + thread2.join(1000); + assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); + } + + @Test + // @Ignore + // Example 3.2. ARTICLE VERSION + public final void whenTwoConnectionsForTwoRequests_thenNoExceptions() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -139,7 +156,7 @@ public final void WhenTwoConnectionsForTwoRequests_ThensNoExceptions() throws In @Test // @Ignore - // 3.3 + // 3.4 public final void whenIncreasingConnectionPool_thenNoEceptions() { poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setMaxTotal(5); @@ -150,8 +167,8 @@ public final void whenIncreasingConnectionPool_thenNoEceptions() { @Test // @Ignore - // 3.4 Tester Version - public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimitNoExceptions() throws InterruptedException, IOException { + // 3.5 Tester Version + /*tester*/public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit() throws InterruptedException, IOException { final HttpGet get = new HttpGet("http://google.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -170,8 +187,8 @@ public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConn @Test // @Ignore - // 3.4 Article version - public final void whenExecutingSameRequestsInDifferentThreads_thenExxecuteReuqesttNoExceptions() throws InterruptedException { + // 3.5 Article version + public final void whenExecutingSameRequestsInDifferentThreads_thenExecuteReuqest() throws InterruptedException { final HttpGet get = new HttpGet("http://localhost"); poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -186,6 +203,8 @@ public final void whenExecutingSameRequestsInDifferentThreads_thenExxecuteReuqes thread3.join(); } + // 4 + @Test // @Ignore // 4.1 @@ -216,10 +235,12 @@ public long getKeepAliveDuration(final HttpResponse myResponse, final HttpContex client.execute(get2); } + // 5 + @Test // @Ignore // 5.1 - public final void GivenBasicHttpClientConnManager_whenConnectionReuse_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { + public final void givenBasicHttpClientConnManager_whenConnectionReuse_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { basicConnManager = new BasicHttpClientConnectionManager(); context = HttpClientContext.create(); final HttpGet get = new HttpGet("http://localhost"); @@ -245,7 +266,7 @@ public final void GivenBasicHttpClientConnManager_whenConnectionReuse_thenNoExce @Test // @Ignore // 5.2 TESTER VERSION - public final void WhenConnectionsNeededGreaterThanMaxTotal_thenReuseConnectionsNoExceptions() throws InterruptedException { + /*tester*/public final void whenConnectionsNeededGreaterThanMaxTotal_thenReuseConnections() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setDefaultMaxPerRoute(5); poolingConnManager.setMaxTotal(5); @@ -266,10 +287,10 @@ public final void WhenConnectionsNeededGreaterThanMaxTotal_thenReuseConnectionsN } } - // 5.2 ARTICLE VERSION @Test + // 5.2 ARTICLE VERSION // @Ignore - public final void WhenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuseNoExceptions() throws InterruptedException { + public final void whenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuse() throws InterruptedException { final HttpGet get = new HttpGet("http://echo.200please.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setDefaultMaxPerRoute(5); @@ -308,7 +329,7 @@ public final void whenHttpClientChecksStaleConns_thenNoExceptions() { @Test // @Ignore // 7.2 TESTER VERSION - public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConnsNoExceptions() throws InterruptedException, IOException { + /*tester*/public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConns() throws InterruptedException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager); From 2b704f933addf8fdcea554403e18ad5b53c59878 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 16:41:37 +0300 Subject: [PATCH 563/796] further connection management work --- .../HttpClientConnectionManagementTest.java | 20 +++++++------------ .../IdleConnectionMonitorThread.java | 2 +- .../{ => conn}/MultiHttpClientConnThread.java | 2 +- ...sterVersion_MultiHttpClientConnThread.java | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) rename httpclient/src/test/java/org/baeldung/httpclient/{ => conn}/HttpClientConnectionManagementTest.java (95%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => conn}/IdleConnectionMonitorThread.java (96%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => conn}/MultiHttpClientConnThread.java (98%) rename httpclient/src/test/java/org/baeldung/httpclient/{ => conn}/TesterVersion_MultiHttpClientConnThread.java (97%) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java similarity index 95% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java rename to httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java index 293564086f9c..934c4bd76150 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.conn; import static org.junit.Assert.assertTrue; @@ -109,18 +109,12 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException // 3 @Test - // @Ignore - public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException { + public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException, ClientProtocolException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); - final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); - final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); - final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client1, get1, poolingConnManager); - final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client2, get2, poolingConnManager); - thread1.start(); - thread1.join(); - thread2.start(); - thread2.join(1000); - assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); + client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + client.execute(get1); + + assertTrue(poolingConnManager.getTotalStats().getLeased() == 1); } @Test @@ -149,8 +143,8 @@ public final void whenTwoConnectionsForTwoRequests_thenNoExceptions() throws Int final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client1, get1); final MultiHttpClientConnThread thread2 = new MultiHttpClientConnThread(client2, get2); thread1.start(); - thread1.join(); thread2.start(); + thread1.join(); thread2.join(); } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java similarity index 96% rename from httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java rename to httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java index 4c4c7f36a1b8..cd0acef09bfd 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.conn; import java.util.concurrent.TimeUnit; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java rename to httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java index e2f8fabbdf6f..b21684fdbbd1 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.conn; import java.io.IOException; import java.util.logging.Level; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java similarity index 97% rename from httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java rename to httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java index 131761b072f8..9562ffbae188 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package org.baeldung.httpclient.conn; import java.io.IOException; import java.util.logging.Level; From fc6e8af9ea053452560c37e0d9d61e698648f90d Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 16:51:41 +0300 Subject: [PATCH 564/796] cleanup work --- .../conn/MultiHttpClientConnThread.java | 38 ++++++++++--------- ...sterVersion_MultiHttpClientConnThread.java | 28 +++++++------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java index b21684fdbbd1..e29aa11a2bab 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java @@ -1,8 +1,6 @@ package org.baeldung.httpclient.conn; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; @@ -10,52 +8,56 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MultiHttpClientConnThread extends Thread { + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final CloseableHttpClient client; private final HttpGet get; - private PoolingHttpClientConnectionManager connManager = null; + + private PoolingHttpClientConnectionManager connManager; private static HttpResponse response; - private Logger logger; public int leasedConn; public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; this.connManager = connManager; - logger = Logger.getLogger(MultiHttpClientConnThread.class.getName()); - leasedConn = 0; + this.leasedConn = 0; } public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get) { this.client = client; this.get = get; - logger = Logger.getLogger(MultiHttpClientConnThread.class.getName()); } - public int getLeasedConn() { + // API + + public final int getLeasedConn() { return leasedConn; } - @Override - public void run() { + // + @Override + public final void run() { try { - if (this != null) - logger.log(Level.SEVERE, "Thread Running: " + getName()); + logger.info("Thread Running: " + getName()); + response = client.execute(get); if (connManager != null) { - logger.log(Level.SEVERE, "Leased Connections " + connManager.getTotalStats().getLeased()); + logger.info("Leased Connections " + connManager.getTotalStats().getLeased()); leasedConn = connManager.getTotalStats().getLeased(); - logger.log(Level.SEVERE, "Available Connections " + connManager.getTotalStats().getAvailable()); + logger.info("Available Connections " + connManager.getTotalStats().getAvailable()); } EntityUtils.consume(response.getEntity()); - } catch (final ClientProtocolException ex) { - + logger.error("", ex); } catch (final IOException ex) { - + logger.error("", ex); } - } + } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java index 9562ffbae188..99619d3023b8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java @@ -1,49 +1,49 @@ package org.baeldung.httpclient.conn; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TesterVersion_MultiHttpClientConnThread extends Thread { + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final CloseableHttpClient client; private final HttpGet get; - private PoolingHttpClientConnectionManager connManager = null; - private Logger logger; + private PoolingHttpClientConnectionManager connManager; public int leasedConn; public TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; this.connManager = connManager; - logger = Logger.getLogger(TesterVersion_MultiHttpClientConnThread.class.getName()); leasedConn = 0; } - public int getLeasedConn() { + // + + public final int getLeasedConn() { return leasedConn; } @Override - public void run() { + public final void run() { try { - if (this != null) - logger.log(Level.SEVERE, "Thread Running: " + getName()); + logger.info("Thread Running: " + getName()); client.execute(get); if (connManager != null) { - logger.log(Level.SEVERE, "Leased Connections " + connManager.getTotalStats().getLeased()); + logger.info("Leased Connections " + connManager.getTotalStats().getLeased()); leasedConn = connManager.getTotalStats().getLeased(); - logger.log(Level.SEVERE, "Available Connections " + connManager.getTotalStats().getAvailable()); + logger.info("Available Connections " + connManager.getTotalStats().getAvailable()); } - } catch (final ClientProtocolException ex) { - + logger.error("", ex); } catch (final IOException ex) { - + logger.error("", ex); } } From 40dc518df0abd8e4baa609ee61738505cc42629c Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 19:13:05 +0300 Subject: [PATCH 565/796] connection management work --- .../HttpClientConnectionManagementTest.java | 116 ++++++++++-------- .../conn/MultiHttpClientConnThread.java | 20 ++- ...sterVersion_MultiHttpClientConnThread.java | 24 ++-- 3 files changed, 88 insertions(+), 72 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java index 934c4bd76150..619e2539cf4b 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java @@ -33,6 +33,7 @@ import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; public class HttpClientConnectionManagementTest { @@ -58,31 +59,37 @@ public class HttpClientConnectionManagementTest { public final void before() { get1 = new HttpGet(SERVER1); get2 = new HttpGet(SERVER7); - route = new HttpRoute(new HttpHost("localhost", 80)); + route = new HttpRoute(new HttpHost("www.baeldung.com", 80)); } @After public final void after() throws IllegalStateException, IOException { - if (conn != null) + if (conn != null) { conn.close(); - if (conn1 != null) + } + if (conn1 != null) { conn1.close(); - if (conn2 != null) + } + if (conn2 != null) { conn2.close(); - if (poolingConnManager != null) + } + if (poolingConnManager != null) { poolingConnManager.shutdown(); - if (basicConnManager != null) + } + if (basicConnManager != null) { basicConnManager.shutdown(); - if (client != null) + } + if (client != null) { client.close(); - if (response != null) + } + if (response != null) { response.close(); + } } // 2 @Test - // @Ignore // 2.1 IN ARTCLE public final void whenLowLevelConnectionIsEstablished_thenNoExceptions() throws IOException, HttpException, InterruptedException, ExecutionException { basicConnManager = new BasicHttpClientConnectionManager(); @@ -98,8 +105,9 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException context = HttpClientContext.create(); final ConnectionRequest connRequest = basicConnManager.requestConnection(route, null); conn = connRequest.get(1000, TimeUnit.SECONDS); - if (!conn.isOpen()) + if (!conn.isOpen()) { basicConnManager.connect(conn, route, 1000, context); + } conn.setSocketTimeout(30000); assertTrue(conn.getSocketTimeout() == 30000); @@ -109,6 +117,7 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException // 3 @Test + // Example 3.1. public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException, ClientProtocolException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -127,8 +136,8 @@ public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExc final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client1, get1, poolingConnManager); final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client2, get2, poolingConnManager); thread1.start(); - thread1.join(); thread2.start(); + thread1.join(); thread2.join(1000); assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); } @@ -148,42 +157,40 @@ public final void whenTwoConnectionsForTwoRequests_thenNoExceptions() throws Int thread2.join(); } + // 4 + @Test - // @Ignore - // 3.4 + // Example 4.1 public final void whenIncreasingConnectionPool_thenNoEceptions() { poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setMaxTotal(5); poolingConnManager.setDefaultMaxPerRoute(4); + final HttpHost localhost = new HttpHost("locahost", 80); poolingConnManager.setMaxPerRoute(new HttpRoute(localhost), 5); } @Test // @Ignore - // 3.5 Tester Version + // 4.2 Tester Version /*tester*/public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit() throws InterruptedException, IOException { - final HttpGet get = new HttpGet("http://google.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); - final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); - final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); - final TesterVersion_MultiHttpClientConnThread thread3 = new TesterVersion_MultiHttpClientConnThread(client, get, poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager); + final TesterVersion_MultiHttpClientConnThread thread3 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager); thread1.start(); - thread1.join(1000); - assertTrue(poolingConnManager.getTotalStats().getLeased() == 1); thread2.start(); - thread2.join(1000); - assertTrue(poolingConnManager.getTotalStats().getLeased() == 2); thread3.start(); - thread3.join(1000); + thread1.join(10000); + thread2.join(10000); + thread3.join(10000); } @Test - // @Ignore - // 3.5 Article version + // 4.2 Article version public final void whenExecutingSameRequestsInDifferentThreads_thenExecuteReuqest() throws InterruptedException { - final HttpGet get = new HttpGet("http://localhost"); + final HttpGet get = new HttpGet("http://www.google.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client, get); @@ -197,11 +204,11 @@ public final void whenExecutingSameRequestsInDifferentThreads_thenExecuteReuqest thread3.join(); } - // 4 + // 5 @Test // @Ignore - // 4.1 + // 5.1 public final void whenCustomizingKeepAliveStrategy_thenNoExceptions() throws ClientProtocolException, IOException { final ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() { @Override @@ -229,37 +236,36 @@ public long getKeepAliveDuration(final HttpResponse myResponse, final HttpContex client.execute(get2); } - // 5 + // 6 @Test // @Ignore - // 5.1 + // 6.1 public final void givenBasicHttpClientConnManager_whenConnectionReuse_thenNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { basicConnManager = new BasicHttpClientConnectionManager(); context = HttpClientContext.create(); - final HttpGet get = new HttpGet("http://localhost"); - HttpResponse thisResponse = null; + final ConnectionRequest connRequest = basicConnManager.requestConnection(route, null); - client = HttpClients.custom().setConnectionManager(basicConnManager).build(); - boolean respAvail = false; conn = connRequest.get(10, TimeUnit.SECONDS); - if (!conn.isOpen()) { - basicConnManager.connect(conn, route, 1000, context); - basicConnManager.routeComplete(conn, route, context); - final HttpRequestExecutor exeRequest = new HttpRequestExecutor(); - context.setTargetHost((new HttpHost("localhost", 80))); - thisResponse = exeRequest.execute(get, conn, context); - respAvail = conn.isResponseAvailable(1000); - } + + basicConnManager.connect(conn, route, 1000, context); + basicConnManager.routeComplete(conn, route, context); + final HttpRequestExecutor exeRequest = new HttpRequestExecutor(); + context.setTargetHost((new HttpHost("www.baeldung.com", 80))); + + final HttpGet get = new HttpGet("http://www.baeldung.com"); + exeRequest.execute(get, conn, context); + conn.isResponseAvailable(1000); basicConnManager.releaseConnection(conn, null, 1, TimeUnit.SECONDS); - if (respAvail) { - client.execute(get); - } + + // + client = HttpClients.custom().setConnectionManager(basicConnManager).build(); + client.execute(get); } @Test // @Ignore - // 5.2 TESTER VERSION + // 6.2 TESTER VERSION /*tester*/public final void whenConnectionsNeededGreaterThanMaxTotal_thenReuseConnections() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setDefaultMaxPerRoute(5); @@ -282,7 +288,7 @@ public final void givenBasicHttpClientConnManager_whenConnectionReuse_thenNoExce } @Test - // 5.2 ARTICLE VERSION + // 7.2 ARTICLE VERSION // @Ignore public final void whenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuse() throws InterruptedException { final HttpGet get = new HttpGet("http://echo.200please.com"); @@ -304,7 +310,7 @@ public final void whenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandR @Test // @Ignore - // 6.2.1 + // 7.2.1 public final void whenConfiguringTimeOut_thenNoExceptions() { route = new HttpRoute(new HttpHost("localhost", 80)); poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -312,17 +318,19 @@ public final void whenConfiguringTimeOut_thenNoExceptions() { assertTrue(poolingConnManager.getSocketConfig(route.getTargetHost()).getSoTimeout() == 5000); } + // 8 + @Test // @Ignore - // 7.1 + // 8.1 public final void whenHttpClientChecksStaleConns_thenNoExceptions() { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().setStaleConnectionCheckEnabled(true).build()).setConnectionManager(poolingConnManager).build(); } @Test - // @Ignore - // 7.2 TESTER VERSION + @Ignore("Very Long Running") + // 8.2 TESTER VERSION /*tester*/public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConns() throws InterruptedException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -345,7 +353,7 @@ public final void whenHttpClientChecksStaleConns_thenNoExceptions() { @Test // @Ignore - // 7.2 ARTICLE VERSION + // 8.2 ARTICLE VERSION public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException { final HttpGet get = new HttpGet("http://google.com"); poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -355,9 +363,11 @@ public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws Interr staleMonitor.join(1000); } + // 9 + @Test(expected = IllegalStateException.class) // @Ignore - // 8.1 + // 9.1 public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { route = new HttpRoute(new HttpHost("google.com", 80)); final HttpGet get = new HttpGet("http://google.com"); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java index e29aa11a2bab..071b964710ad 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java @@ -18,14 +18,13 @@ public class MultiHttpClientConnThread extends Thread { private final HttpGet get; private PoolingHttpClientConnectionManager connManager; - private static HttpResponse response; public int leasedConn; public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; this.connManager = connManager; - this.leasedConn = 0; + leasedConn = 0; } public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get) { @@ -44,14 +43,23 @@ public final int getLeasedConn() { @Override public final void run() { try { - logger.info("Thread Running: " + getName()); + logger.debug("Thread Running: " + getName()); + + logger.debug("Thread Running: " + getName()); + + if (connManager != null) { + logger.info("Before - Leased Connections = " + connManager.getTotalStats().getLeased()); + logger.info("Before - Available Connections = " + connManager.getTotalStats().getAvailable()); + } + + final HttpResponse response = client.execute(get); - response = client.execute(get); if (connManager != null) { - logger.info("Leased Connections " + connManager.getTotalStats().getLeased()); leasedConn = connManager.getTotalStats().getLeased(); - logger.info("Available Connections " + connManager.getTotalStats().getAvailable()); + logger.info("After - Leased Connections = " + connManager.getTotalStats().getLeased()); + logger.info("After - Available Connections = " + connManager.getTotalStats().getAvailable()); } + EntityUtils.consume(response.getEntity()); } catch (final ClientProtocolException ex) { logger.error("", ex); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java index 99619d3023b8..62cd466596ec 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java @@ -9,37 +9,35 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Preconditions; + public class TesterVersion_MultiHttpClientConnThread extends Thread { private final Logger logger = LoggerFactory.getLogger(getClass()); private final CloseableHttpClient client; private final HttpGet get; private PoolingHttpClientConnectionManager connManager; - public int leasedConn; public TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; - this.connManager = connManager; - leasedConn = 0; + this.connManager = Preconditions.checkNotNull(connManager); } // - public final int getLeasedConn() { - return leasedConn; - } - @Override public final void run() { try { - logger.info("Thread Running: " + getName()); + logger.debug("Thread Running: " + getName()); + + logger.info("Before - Leased Connections = " + connManager.getTotalStats().getLeased()); + logger.info("Before - Available Connections = " + connManager.getTotalStats().getAvailable()); + client.execute(get); - if (connManager != null) { - logger.info("Leased Connections " + connManager.getTotalStats().getLeased()); - leasedConn = connManager.getTotalStats().getLeased(); - logger.info("Available Connections " + connManager.getTotalStats().getAvailable()); - } + + logger.info("After - Leased Connections = " + connManager.getTotalStats().getLeased()); + logger.info("After - Available Connections = " + connManager.getTotalStats().getAvailable()); } catch (final ClientProtocolException ex) { logger.error("", ex); } catch (final IOException ex) { From c3f0555b20fd0142d48a1970e79f9a1710cb1065 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 6 Jul 2014 20:19:06 +0300 Subject: [PATCH 566/796] work on connection management --- .../HttpClientConnectionManagementTest.java | 25 ++++++++----------- .../conn/IdleConnectionMonitorThread.java | 8 +++--- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java index 619e2539cf4b..c5c960f527b8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java @@ -288,7 +288,7 @@ public final void givenBasicHttpClientConnManager_whenConnectionReuse_thenNoExce } @Test - // 7.2 ARTICLE VERSION + // 6.2 ARTICLE VERSION // @Ignore public final void whenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandReuse() throws InterruptedException { final HttpGet get = new HttpGet("http://echo.200please.com"); @@ -308,9 +308,10 @@ public final void whenConnectionsNeededGreaterThanMaxTotal_thenLeaseMasTotalandR } } + // 7 + @Test - // @Ignore - // 7.2.1 + // 7.1 public final void whenConfiguringTimeOut_thenNoExceptions() { route = new HttpRoute(new HttpHost("localhost", 80)); poolingConnManager = new PoolingHttpClientConnectionManager(); @@ -368,26 +369,20 @@ public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws Interr @Test(expected = IllegalStateException.class) // @Ignore // 9.1 - public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions() throws InterruptedException, ExecutionException, IOException, HttpException { - route = new HttpRoute(new HttpHost("google.com", 80)); - final HttpGet get = new HttpGet("http://google.com"); + public final void whenClosingConnectionsandManager_thenCloseWithNoExceptions1() throws InterruptedException, ExecutionException, IOException, HttpException { poolingConnManager = new PoolingHttpClientConnectionManager(); - final ConnectionRequest connRequest = poolingConnManager.requestConnection(route, null); - context = HttpClientContext.create(); - conn = connRequest.get(10, TimeUnit.SECONDS); - poolingConnManager.connect(conn, route, 10000, context); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); + final HttpGet get = new HttpGet("http://google.com"); response = client.execute(get); + EntityUtils.consume(response.getEntity()); - client.close(); - conn.close(); response.close(); + client.close(); poolingConnManager.close(); poolingConnManager.shutdown(); + client.execute(get); - conn.sendRequestHeader(get); - assertTrue(!conn.isOpen()); - assertTrue(conn.isOpen()); + assertTrue(response.getEntity() == null); } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java index cd0acef09bfd..2a1c419e4182 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java @@ -14,8 +14,10 @@ public IdleConnectionMonitorThread(final PoolingHttpClientConnectionManager conn this.connMgr = connMgr; } + // API + @Override - public void run() { + public final void run() { try { while (!shutdown) { synchronized (this) { @@ -26,14 +28,14 @@ public void run() { } } catch (final InterruptedException ex) { shutdown(); - } } - public void shutdown() { + public final void shutdown() { shutdown = true; synchronized (this) { notifyAll(); } } + } From 8438a27f6f688f2abaf3c481f0ea4b854f0aecfb Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 9 Jul 2014 13:08:16 +0300 Subject: [PATCH 567/796] minor testing work --- .../java/io/JavaReaderToXUnitTest.java | 20 +++++----- .../java/io/JavaXToReaderUnitTest.java | 40 +++++++++++++++++++ 2 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index 4e8b97f381ca..b5f846e8859d 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -19,15 +19,15 @@ public class JavaReaderToXUnitTest { // tests - Reader to String - @Test - public void givenUsingPlainJava_whenConvertingReaderIntoString_thenCorrect() throws IOException { - final Reader initialReader = new StringReader("text"); - - final char[] mediationArray = new char["text".length()]; - initialReader.read(mediationArray); - initialReader.close(); - final String targetString = new String(mediationArray); - } + // @Test + // public void givenUsingPlainJava_whenConvertingReaderIntoString_thenCorrect() throws IOException { + // final Reader initialReader = new StringReader("text"); + // // int bufferSize = initialReader.toString().length(); + // // char[] buffer = new char[bufferSize]; + // initialReader.read(buffer); + // initialReader.close(); + // final String targetString = new String(buffer); + // } @Test public void givenUsingGuava_whenConvertingReaderIntoString_thenCorrect() throws IOException { @@ -37,7 +37,7 @@ public void givenUsingGuava_whenConvertingReaderIntoString_thenCorrect() throws } @Test - public void givenUsingCommonsIo_whenConvertingReaderIntoString_thenCorrect() throws IOException { + public void givenUsingCommonsIO_whenConvertingReaderIntoString_thenCorrect() throws IOException { final Reader initialReader = new StringReader("Apache Commons IO 2.4"); final String targetString = IOUtils.toString(initialReader); initialReader.close(); diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java new file mode 100644 index 000000000000..f181fbd1538c --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java @@ -0,0 +1,40 @@ +package org.baeldung.java.io; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import org.apache.commons.io.input.CharSequenceReader; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSource; + +public class JavaXToReaderUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - String to Reader + + @Test + public void givenUsingPlainJava_whenConvertingStringIntoReader_thenCorrect() throws IOException { + final String initialString = "With Plain Java"; + final Reader targetReader = new StringReader(initialString); + targetReader.close(); + } + + @Test + public void givenUsingGuava_whenConvertingStringIntoReader_thenCorrect() throws IOException { + final String initialString = "With Google Guava"; + final Reader targetReader = CharSource.wrap(initialString).openStream(); + targetReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingStringIntoReader_thenCorrect() throws IOException { + final String initialString = "With Apache Commons IO"; + final Reader targetReader = new CharSequenceReader(initialString); + targetReader.close(); + } + +} From 8b17941edb1149d3ec28a5ddc17a631367600934 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 9 Jul 2014 17:29:52 +0300 Subject: [PATCH 568/796] java testing work --- .../java/io/JavaXToReaderUnitTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java index f181fbd1538c..0d9f6d1f06b1 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java @@ -1,9 +1,13 @@ package org.baeldung.java.io; +import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.nio.charset.Charset; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.input.CharSequenceReader; import org.junit.Test; import org.slf4j.Logger; @@ -37,4 +41,57 @@ public void givenUsingCommonsIO_whenConvertingStringIntoReader_thenCorrect() thr targetReader.close(); } + // tests - byte array to Reader + + @Test + public void givenUsingPlainJava_whenConvertingByteArrayIntoReader_thenCorrect() throws IOException { + final byte[] initialArray = "Hello world!".getBytes(); + final Reader targetReader = new StringReader(new String(initialArray)); + targetReader.close(); + } + + @Test + public void givenUsingGuava_whenConvertingByteArrayIntoReader_thenCorrect() throws IOException { + final byte[] initialArray = "With Guava".getBytes(); + final String bufferString = new String(initialArray); + final Reader targetReader = CharSource.wrap(bufferString).openStream(); + + targetReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingByteArrayIntoReader_thenCorrect() throws IOException { + final byte[] initialArray = "With Commons IO".getBytes(); + final Reader targetReader = new CharSequenceReader(new String(initialArray)); + targetReader.close(); + } + + // tests - File to Reader + + @Test + public void givenUsingPlainJava_whenConvertingFileIntoReader_thenCorrect() throws IOException { + final File initialFile = new File("src/test/resources/initialFile.txt"); + initialFile.createNewFile(); + final Reader targetReader = new FileReader(initialFile); + targetReader.close(); + } + + @Test + public void givenUsingGuava_whenConvertingFileIntoReader_thenCorrect() throws IOException { + final File initialFile = new File("src/test/resources/initialFile.txt"); + com.google.common.io.Files.touch(initialFile); + final Reader targetReader = com.google.common.io.Files.newReader(initialFile, Charset.defaultCharset()); + targetReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingFileIntoReader_thenCorrect() throws IOException { + final File initialFile = new File("src/test/resources/initialFile.txt"); + FileUtils.touch(initialFile); + FileUtils.write(initialFile, "With Commons IO"); + final byte[] buffer = FileUtils.readFileToByteArray(initialFile); + final Reader targetReader = new CharSequenceReader(new String(buffer)); + targetReader.close(); + } + } From bc29b044dceb4ed7984a899710e828da46439d89 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 9 Jul 2014 23:41:36 +0300 Subject: [PATCH 569/796] java testing work --- .../java/io/JavaXToByteArrayUnitTest.java | 11 ++++ .../java/io/JavaXToWriterUnitTest.java | 53 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java create mode 100644 core-java/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java new file mode 100644 index 000000000000..e45e3e73f422 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java @@ -0,0 +1,11 @@ +package org.baeldung.java.io; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JavaXToByteArrayUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - X to Byte Array + +} diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java new file mode 100644 index 000000000000..35ec15df1667 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java @@ -0,0 +1,53 @@ +package org.baeldung.java.io; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.apache.commons.io.output.StringBuilderWriter; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSink; + +public class JavaXToWriterUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - byte[] to Writer + + @Test + public void givenPlainJava_whenConvertingByteArrayIntoWriter_thenCorrect() throws IOException { + final byte[] initialArray = "With Java".getBytes(); + + final Writer targetWriter = new StringWriter().append(new String(initialArray)); + + targetWriter.close(); + } + + @Test + public void givenUsingGuava_whenConvertingByteArrayIntoWriter_thenCorrect() throws IOException { + final byte[] initialArray = "With Guava".getBytes(); + + final String buffer = new String(initialArray); + final StringWriter stringWriter = new StringWriter(); + final CharSink charSink = new CharSink() { + @Override + public final Writer openStream() throws IOException { + return stringWriter; + } + }; + charSink.write(buffer); + + stringWriter.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingByteArrayIntoWriter_thenCorrect() throws IOException { + final byte[] initialArray = "With Commons IO".getBytes(); + final Writer targetWriter = new StringBuilderWriter(new StringBuilder(new String(initialArray))); + + targetWriter.close(); + } + +} From 8228e34dc013ca2f891f45a01f530b3ca39e9100 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 9 Jul 2014 23:42:47 +0300 Subject: [PATCH 570/796] minor doc change --- .../java/io/JavaReaderToXUnitTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index b5f846e8859d..ce40c1209932 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -1,16 +1,25 @@ package org.baeldung.java.io; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.io.Writer; +import java.nio.charset.Charset; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.CharSequenceReader; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.io.CharSink; import com.google.common.io.CharSource; import com.google.common.io.CharStreams; +import com.google.common.io.FileWriteMode; @SuppressWarnings("unused") public class JavaReaderToXUnitTest { @@ -43,4 +52,44 @@ public void givenUsingCommonsIO_whenConvertingReaderIntoString_thenCorrect() thr initialReader.close(); } + // tests - Reader WRITE TO File + + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + final File sourceFile = new File("src/test/resources/sourceFile.txt"); + sourceFile.createNewFile(); + + final Reader initialReader = new FileReader(sourceFile); + final char[] buffer = new char[(int) sourceFile.length()]; + initialReader.read(buffer); + initialReader.close(); + + final File targetFile = new File("src/test/resources/targetFile.txt"); + targetFile.createNewFile(); + + final Writer targetFileWriter = new FileWriter(targetFile); + targetFileWriter.write(buffer); + targetFileWriter.close(); + } + + @Test + public void givenUsingGuava_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + final Reader initialReader = CharSource.wrap("IDDQD").openStream(); + final File targetFile = new File("src/test/resources/targetFile.txt"); + com.google.common.io.Files.touch(targetFile); + final CharSink charSink = com.google.common.io.Files.asCharSink(targetFile, Charset.defaultCharset(), FileWriteMode.APPEND); + charSink.writeFrom(initialReader); + initialReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + final Reader initialReader = new CharSequenceReader("CharSequenceReader extends Reader"); + final File targetFile = new File("src/test/resources/targetFile.txt"); + FileUtils.touch(targetFile); + final byte[] buffer = IOUtils.toByteArray(initialReader); + FileUtils.writeByteArrayToFile(targetFile, buffer); + initialReader.close(); + } + } From d597252bf16a6578900d0c64d3360054029d260f Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Fri, 11 Jul 2014 11:12:15 -0400 Subject: [PATCH 571/796] Serializable field in Jackson --- .../org/baeldung/jackson/field/MyDto.java | 47 ++++++ .../jackson/field/MyDtoAccessLevel.java | 21 +++ .../field/MyDtoCustomizedPropertyName.java | 50 ++++++ .../baeldung/jackson/field/MyDtoGetter.java | 27 ++++ .../MyDtoGetterImplicitDeserialization.java | 31 ++++ .../baeldung/jackson/field/MyDtoSetter.java | 35 +++++ .../java/org/baeldung/jackson/field/User.java | 50 ++++++ .../jackson/test/JacksonFieldUnitTest.java | 147 ++++++++++++++++++ .../baeldung/jackson/test/UnitTestSuite.java | 1 + 9 files changed, 409 insertions(+) create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDto.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoAccessLevel.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/field/User.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDto.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDto.java new file mode 100644 index 000000000000..edfc9d2f91c0 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDto.java @@ -0,0 +1,47 @@ +package org.baeldung.jackson.field; + +public class MyDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDto() { + super(); + } + + public MyDto(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean getBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoAccessLevel.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoAccessLevel.java new file mode 100644 index 000000000000..d1761b30edfa --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoAccessLevel.java @@ -0,0 +1,21 @@ +package org.baeldung.jackson.field; + +public class MyDtoAccessLevel { + + private String stringValue; + int intValue; + public boolean booleanValue; + + public MyDtoAccessLevel() { + super(); + } + + public MyDtoAccessLevel(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java new file mode 100644 index 000000000000..8fbfb41cd81c --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson.field; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class MyDtoCustomizedPropertyName { + + private String stringValue; + private int intValue; + @JsonProperty("BOOLEANVALUE") + private boolean booleanValue; + + public MyDtoCustomizedPropertyName() { + super(); + } + + public MyDtoCustomizedPropertyName(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean getBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java new file mode 100644 index 000000000000..12feb9862883 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java @@ -0,0 +1,27 @@ +package org.baeldung.jackson.field; + +public class MyDtoGetter { + + private String stringValue; + int intValue; + public boolean booleanValue; + + public MyDtoGetter() { + super(); + } + + public MyDtoGetter(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java new file mode 100644 index 000000000000..ee9d346a0ac6 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java @@ -0,0 +1,31 @@ +package org.baeldung.jackson.field; + +public class MyDtoGetterImplicitDeserialization { + + private String stringValue; + int intValue; + public boolean booleanValue; + + public MyDtoGetterImplicitDeserialization() { + super(); + } + + public MyDtoGetterImplicitDeserialization(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public int getIntValue() { + return intValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java new file mode 100644 index 000000000000..391b1959aecf --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -0,0 +1,35 @@ +package org.baeldung.jackson.field; + +public class MyDtoSetter { + + private String stringValue; + int intValue; + public boolean booleanValue; + + public MyDtoSetter() { + super(); + } + + public MyDtoSetter(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public int anotherGetIntValue() { + return intValue; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/User.java b/jackson/src/test/java/org/baeldung/jackson/field/User.java new file mode 100644 index 000000000000..1210fd992e6c --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/field/User.java @@ -0,0 +1,50 @@ +package org.baeldung.jackson.field; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class User { + + private int id; + private String name; + @JsonIgnore + private String password; + + public User() { + super(); + } + + public User(final int id, final String name, final String password) { + this.id = id; + this.name = name; + this.password = password; + } + + // API + public int getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @JsonIgnore + public String getPassword() { + return password; + } + + @JsonProperty + public void setPassword(final String password) { + this.password = password; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java new file mode 100644 index 000000000000..7cb14c415187 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -0,0 +1,147 @@ +package org.baeldung.jackson.test; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +import java.io.IOException; + +import org.baeldung.jackson.field.MyDtoAccessLevel; +import org.baeldung.jackson.field.MyDtoCustomizedPropertyName; +import org.baeldung.jackson.field.MyDtoGetter; +import org.baeldung.jackson.field.MyDtoGetterImplicitDeserialization; +import org.baeldung.jackson.field.MyDtoSetter; +import org.baeldung.jackson.field.User; +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JacksonFieldUnitTest { + + @Test + public final void givenDifferentAccessLevels_whenPrivateOrPackage_thenNotSerializable_whenPublic_thenSerializable() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + assertThat(dtoAsString, not(containsString("stringValue"))); + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenDifferentAccessLevels_whenGetterAdded_thenSerializable() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoGetter dtoObject = new MyDtoGetter(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + assertThat(dtoAsString, containsString("stringValue")); + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoGetterImplicitDeserialization dtoObject = mapper.readValue(jsonAsString, MyDtoGetterImplicitDeserialization.class); + + assertNotNull(dtoObject); + assertThat(dtoObject.getStringValue(), equalTo("dtoString")); + assertThat(dtoObject.getIntValue(), equalTo(1)); + assertThat(dtoObject.booleanValue, equalTo(true)); + } + + @Test + public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); + + assertNotNull(dtoObject); + assertThat(dtoObject.getStringValue(), equalTo("dtoString")); + assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); + assertThat(dtoObject.booleanValue, equalTo(true)); + } + + @Test + public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoSetter dtoObject = new MyDtoSetter(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + assertThat(dtoAsString, containsString("stringValue")); + assertThat(dtoAsString, not(containsString("intValue"))); + assertThat(dtoAsString, containsString("booleanValue")); + System.out.println(dtoAsString); + } + + @Test + public final void givenCustomizedPropertyName_whenFieldAnnotated_thenPropertyNameCustomizedOnSerialization() throws JsonProcessingException, JsonMappingException, IOException { + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoCustomizedPropertyName dtoObject = new MyDtoCustomizedPropertyName(); + + final String dtoAsString = mapper.writeValueAsString(dtoObject); + assertThat(dtoAsString, containsString("stringValue")); + assertThat(dtoAsString, containsString("intValue")); + assertThat(dtoAsString, containsString("BOOLEANVALUE")); + assertThat(dtoAsString, not(containsString("booleanValue"))); + System.out.println(dtoAsString); + } + + @Test + public final void givenCustomizedPropertyName_whenFieldAnnotated_thenPropertyNameCustomizedOnDeserialization() throws JsonProcessingException, JsonMappingException, IOException { + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"BOOLEANVALUE\":\"true\"}"; + final ObjectMapper mapper = new ObjectMapper(); + + final MyDtoCustomizedPropertyName dtoObject = mapper.readValue(jsonAsString, MyDtoCustomizedPropertyName.class); + + assertNotNull(dtoObject); + assertThat(dtoObject.getStringValue(), equalTo("dtoString")); + assertThat(dtoObject.getIntValue(), equalTo(1)); + assertThat(dtoObject.getBooleanValue(), equalTo(true)); + } + + @Test + public final void givenFieldIsIgnoredOnlyAtSerialization_whenUserIsSerialized_thenIgnored() throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + + final User userObject = new User(); + userObject.setId(1); + userObject.setName("theUser"); + userObject.setPassword("thePassword"); + + final String userAsString = mapper.writeValueAsString(userObject); + assertThat(userAsString, containsString("id")); + assertThat(userAsString, containsString("name")); + assertThat(userAsString, not(containsString("password"))); + System.out.println(userAsString); + } + + @Test + public final void givenFieldIsIgnoredOnlyAtSerialization_whenUserIsDeserialized_thenCorrect() throws JsonParseException, JsonMappingException, IOException { + final String jsonAsString = "{\"id\":1,\"name\":\"theUser\",\"password\":\"thePassword\"}"; + final ObjectMapper mapper = new ObjectMapper(); + + final User userObject = mapper.readValue(jsonAsString, User.class); + + assertNotNull(userObject); + assertThat(userObject.getId(), equalTo(1)); + assertThat(userObject.getName(), equalTo("theUser")); + assertThat(userObject.getPassword(), equalTo("thePassword")); + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java b/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java index 2eb24928d6fe..886b43d05dd8 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/UnitTestSuite.java @@ -15,6 +15,7 @@ ,JacksonSerializationIgnoreUnitTest.class ,JacksonSerializationUnitTest.class ,SandboxTest.class + ,JacksonFieldUnitTest.class }) // @formatter:on public class UnitTestSuite { } \ No newline at end of file From 092b3213ea830aa5889fab78b5840a800eb59aa6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 12 Jul 2014 11:55:08 +0300 Subject: [PATCH 572/796] cleanup work in tests --- .../java/io/JavaReaderToXUnitTest.java | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index ce40c1209932..8923c5c79757 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -26,17 +26,39 @@ public class JavaReaderToXUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); private static final int DEFAULT_SIZE = 1500000; + // tests - sandbox + // tests - Reader to String - // @Test - // public void givenUsingPlainJava_whenConvertingReaderIntoString_thenCorrect() throws IOException { - // final Reader initialReader = new StringReader("text"); - // // int bufferSize = initialReader.toString().length(); - // // char[] buffer = new char[bufferSize]; - // initialReader.read(buffer); - // initialReader.close(); - // final String targetString = new String(buffer); - // } + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoString1_thenCorrect() throws IOException { + final Reader reader = new StringReader("text"); + int intValueOfChar; + String targetString = ""; + while ((intValueOfChar = reader.read()) != -1) { + targetString += (char) intValueOfChar; + } + reader.close(); + + // test + System.out.println("targetString: " + targetString); + } + + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoString2_thenCorrect() throws IOException { + final Reader reader = new StringReader("text"); + final char[] arr = new char[8 * 1024]; // 8K at a time + final StringBuffer buf = new StringBuffer(); + int numChars; + while ((numChars = reader.read(arr, 0, arr.length)) > 0) { + buf.append(arr, 0, numChars); + } + + reader.close(); + + // test + System.out.println("targetString: " + buf.toString()); + } @Test public void givenUsingGuava_whenConvertingReaderIntoString_thenCorrect() throws IOException { From 120da93492ee79afa065a6d2f512a0fd6aad526f Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 12 Jul 2014 12:47:24 +0300 Subject: [PATCH 573/796] persistence cleanup work --- ...tenceServiceData.java => FooFixtures.java} | 32 +++------- ...oPaginationPersistenceIntegrationTest.java | 7 ++- .../FooSortingPersistenceServiceTest.java | 58 ++++++++----------- ...rentServicePersistenceIntegrationTest.java | 6 -- 4 files changed, 34 insertions(+), 69 deletions(-) rename spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/{FooSortingPersistenceServiceData.java => FooFixtures.java} (65%) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooFixtures.java similarity index 65% rename from spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java rename to spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooFixtures.java index 5b8696821dca..8b16f9b605cd 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceData.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooFixtures.java @@ -8,26 +8,21 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistry; import com.google.common.collect.Lists; -public class FooSortingPersistenceServiceData { - private static ServiceRegistry serviceRegistry; - private static SessionFactory sessionFactory; - private static Configuration configuration; - private static StandardServiceRegistryBuilder builder; +public class FooFixtures { + private SessionFactory sessionFactory; - public FooSortingPersistenceServiceData() { + public FooFixtures(final SessionFactory sessionFactory) { super(); + + this.sessionFactory = sessionFactory; } - public void createBars() { + // API - configWork(); + public void createBars() { Session session = null; Transaction tx = null; session = sessionFactory.openSession(); @@ -66,8 +61,6 @@ public void createBars() { } public void createFoos() { - - configWork(); Session session = null; Transaction tx = null; session = sessionFactory.openSession(); @@ -105,15 +98,4 @@ public void createFoos() { } } - public void configWork() { - configuration = new Configuration(); - configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); - configuration.setProperty("dialect", "org.hibernate.dialect.MySQLDialect"); - configuration.setProperty(AvailableSettings.DRIVER, "com.mysql.jdbc.Driver"); - configuration.setProperty(AvailableSettings.URL, "jdbc:mysql://localhost:3306/HIBERTEST2_TEST"); - configuration.setProperty(AvailableSettings.USER, "root"); - configuration.setProperty(AvailableSettings.PASS, ""); - builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); - sessionFactory = configuration.addPackage("com.cc.example.hibernate").addAnnotatedClass(Foo.class).addAnnotatedClass(Bar.class).configure().buildSessionFactory(builder.build()); - } } diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java index ec90c3779c8e..3d5c14231e6e 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java @@ -34,10 +34,10 @@ public class FooPaginationPersistenceIntegrationTest { @Autowired - private SessionFactory sessionFactory; + private IFooService fooService; @Autowired - private IFooService fooService; + private SessionFactory sessionFactory; private Session session; @@ -140,8 +140,9 @@ public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCor int i = 0; while (pageSize > i++) { fooPage.add((Foo) resultScroll.get(0)); - if (!resultScroll.next()) + if (!resultScroll.next()) { break; + } } assertThat(fooPage, hasSize(lessThan(10 + 1))); diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java index 6b1f4318dead..3e600816f5fe 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooSortingPersistenceServiceTest.java @@ -5,8 +5,6 @@ import java.util.List; import java.util.Set; -import javax.imageio.spi.ServiceRegistry; - import org.baeldung.persistence.model.Bar; import org.baeldung.persistence.model.Foo; import org.baeldung.spring.PersistenceConfig; @@ -15,14 +13,12 @@ import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -31,40 +27,32 @@ @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) @SuppressWarnings("unchecked") public class FooSortingPersistenceServiceTest { - private SessionFactory sf; - private Session sess; - private static ServiceRegistry serviceRegistry; - private static Configuration configuration; - private static StandardServiceRegistryBuilder builder; + + @Autowired + private SessionFactory sessionFactory; + + private Session session; @Before public void before() { + session = sessionFactory.openSession(); + + session.beginTransaction(); - final FooSortingPersistenceServiceData fooData = new FooSortingPersistenceServiceData(); + final FooFixtures fooData = new FooFixtures(sessionFactory); fooData.createBars(); - configuration = new Configuration(); - configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); - configuration.setProperty("dialect", "org.hibernate.dialect.MySQLDialect"); - configuration.setProperty(AvailableSettings.DRIVER, "com.mysql.jdbc.Driver"); - configuration.setProperty(AvailableSettings.URL, "jdbc:mysql://localhost:3306/HIBERTEST2_TEST"); - configuration.setProperty(AvailableSettings.USER, "root"); - configuration.setProperty(AvailableSettings.PASS, ""); - configuration.setProperty("hibernate.show_sql", "true"); - builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()); - sf = configuration.addPackage("org.baeldung.persistence.model").addAnnotatedClass(Foo.class).addAnnotatedClass(Bar.class).configure().buildSessionFactory(builder.build()); - sess = sf.openSession(); - sess.beginTransaction(); } @After public void after() { - sess.getTransaction().commit(); + session.getTransaction().commit(); + session.close(); } @Test public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { final String hql = "FROM Foo f ORDER BY f.name"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); @@ -74,7 +62,7 @@ public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { @Test public final void whenHQlSortingByStringNullLast_thenLastNull() { final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); assertNull(fooList.get(fooList.toArray().length - 1).getName()); @@ -86,7 +74,7 @@ public final void whenHQlSortingByStringNullLast_thenLastNull() { @Test public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); assertNull(fooList.get(0).getName()); for (final Foo foo : fooList) { @@ -98,7 +86,7 @@ public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { @Test public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { final String hql = "FROM Foo f ORDER BY f.name ASC"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); @@ -108,7 +96,7 @@ public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSorted @Test public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { final String hql = "FROM Foo f ORDER BY f.name, f.id"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); @@ -118,7 +106,7 @@ public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { @Test public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); @@ -127,7 +115,7 @@ public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrint @Test public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("id")); final List fooList = criteria.list(); for (final Foo foo : fooList) { @@ -137,7 +125,7 @@ public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { @Test public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("name")); criteria.addOrder(Order.asc("id")); final List fooList = criteria.list(); @@ -148,7 +136,7 @@ public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { @Test public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); final List fooList = criteria.list(); assertNull(fooList.get(fooList.toArray().length - 1).getName()); @@ -159,7 +147,7 @@ public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { @Test public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - final Criteria criteria = sess.createCriteria(Foo.class, "FOO"); + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); final List fooList = criteria.list(); assertNull(fooList.get(0).getName()); @@ -171,7 +159,7 @@ public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { @Test public final void whenSortingBars_thenBarsWithSortedFoos() { final String hql = "FROM Bar b ORDER BY b.id"; - final Query query = sess.createQuery(hql); + final Query query = session.createQuery(hql); final List barList = query.list(); for (final Bar bar : barList) { final Set fooSet = bar.getFooSet(); diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java index aeeb810258ea..3960aa79eaa8 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -2,10 +2,7 @@ import org.baeldung.persistence.model.Child; import org.baeldung.persistence.model.Parent; -import org.baeldung.persistence.service.IChildService; -import org.baeldung.persistence.service.IParentService; import org.baeldung.spring.PersistenceConfig; -import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,9 +21,6 @@ public class ParentServicePersistenceIntegrationTest { @Autowired private IChildService childService; - @Autowired - private SessionFactory sessionFactory; - // tests @Test From 6c52dfacbd2f0fe03d3528c07a597cb1734c4744 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 12 Jul 2014 21:43:03 +0300 Subject: [PATCH 574/796] io testign work --- .../java/io/JavaReaderToXUnitTest.java | 67 +++++++++++++------ core-java/src/test/resources/sourceFile.txt | 0 core-java/src/test/resources/targetFile.txt | 1 + 3 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 core-java/src/test/resources/sourceFile.txt create mode 100644 core-java/src/test/resources/targetFile.txt diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index 8923c5c79757..3d9cdd8a2e4b 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -31,45 +31,39 @@ public class JavaReaderToXUnitTest { // tests - Reader to String @Test - public void givenUsingPlainJava_whenConvertingReaderIntoString1_thenCorrect() throws IOException { - final Reader reader = new StringReader("text"); + public void givenUsingPlainJava_whenConvertingReaderIntoStringV1_thenCorrect() throws IOException { + final StringReader reader = new StringReader("With Java 1"); int intValueOfChar; String targetString = ""; while ((intValueOfChar = reader.read()) != -1) { targetString += (char) intValueOfChar; } reader.close(); - - // test - System.out.println("targetString: " + targetString); } @Test - public void givenUsingPlainJava_whenConvertingReaderIntoString2_thenCorrect() throws IOException { - final Reader reader = new StringReader("text"); - final char[] arr = new char[8 * 1024]; // 8K at a time - final StringBuffer buf = new StringBuffer(); - int numChars; - while ((numChars = reader.read(arr, 0, arr.length)) > 0) { - buf.append(arr, 0, numChars); + public void givenUsingPlainJava_whenConvertingReaderIntoStringV2_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("With Java 1"); + final char[] arr = new char[8 * 1024]; + final StringBuilder buffer = new StringBuilder(); + int numCharsRead; + while ((numCharsRead = initialReader.read(arr, 0, arr.length)) != -1) { + buffer.append(arr, 0, numCharsRead); } - - reader.close(); - - // test - System.out.println("targetString: " + buf.toString()); + initialReader.close(); + final String targetString = buffer.toString(); } @Test public void givenUsingGuava_whenConvertingReaderIntoString_thenCorrect() throws IOException { - final Reader initialReader = CharSource.wrap("Google Guava v.17.0").openStream(); + final Reader initialReader = CharSource.wrap("With Google Guava").openStream(); final String targetString = CharStreams.toString(initialReader); initialReader.close(); } @Test public void givenUsingCommonsIO_whenConvertingReaderIntoString_thenCorrect() throws IOException { - final Reader initialReader = new StringReader("Apache Commons IO 2.4"); + final Reader initialReader = new StringReader("With Apache Commons"); final String targetString = IOUtils.toString(initialReader); initialReader.close(); } @@ -114,4 +108,39 @@ public void givenUsingCommonsIO_whenConvertingReaderIntoFile_thenCorrect() throw initialReader.close(); } + // tests - Reader to byte[] + + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoByteArray_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("With Java"); + + final char[] charArray = new char[8 * 1024]; + final StringBuilder builder = new StringBuilder(); + int numCharsRead; + while ((numCharsRead = initialReader.read(charArray, 0, charArray.length)) != -1) { + builder.append(charArray, 0, numCharsRead); + } + final byte[] targetArray = builder.toString().getBytes(); + + initialReader.close(); + } + + @Test + public void givenUsingGuava_whenConvertingReaderIntoByteArray_thenCorrect() throws IOException { + final Reader initialReader = CharSource.wrap("With Google Guava").openStream(); + + final byte[] targetArray = CharStreams.toString(initialReader).getBytes(); + + initialReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingReaderIntoByteArray_thenCorrect() throws IOException { + final StringReader initialReader = new StringReader("With Commons IO"); + + final byte[] targetArray = IOUtils.toByteArray(initialReader); + + initialReader.close(); + } + } diff --git a/core-java/src/test/resources/sourceFile.txt b/core-java/src/test/resources/sourceFile.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/core-java/src/test/resources/targetFile.txt b/core-java/src/test/resources/targetFile.txt new file mode 100644 index 000000000000..f04ec3d9a9bc --- /dev/null +++ b/core-java/src/test/resources/targetFile.txt @@ -0,0 +1 @@ +CharSequenceReader extends Reader \ No newline at end of file From 979cd6e3a46f9a580e670e664c15f95d6379d081 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 13 Jul 2014 21:29:13 +0300 Subject: [PATCH 575/796] IO testing work --- .../java/io/JavaReaderToXUnitTest.java | 40 +++++++++++++++++++ .../java/io/JavaXToReaderUnitTest.java | 37 +++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index 3d9cdd8a2e4b..7cb92762838a 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -1,9 +1,11 @@ package org.baeldung.java.io; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; import java.io.StringReader; import java.io.Writer; @@ -143,4 +145,42 @@ public void givenUsingCommonsIO_whenConvertingReaderIntoByteArray_thenCorrect() initialReader.close(); } + // tests - Reader to InputStream + + @Test + public void givenUsingPlainJava_whenConvertingReaderIntoInputStream_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("With Java"); + + final char[] charBuffer = new char[8 * 1024]; + final StringBuilder builder = new StringBuilder(); + int numCharsRead; + while ((numCharsRead = initialReader.read(charBuffer, 0, charBuffer.length)) != -1) { + builder.append(charBuffer, 0, numCharsRead); + } + final InputStream targetStream = new ByteArrayInputStream(builder.toString().getBytes()); + + initialReader.close(); + targetStream.close(); + } + + @Test + public void givenUsingGuava_whenConvertingReaderIntoInputStream_thenCorrect() throws IOException { + final Reader initialReader = new StringReader("With Guava"); + + final InputStream targetStream = new ByteArrayInputStream(CharStreams.toString(initialReader).getBytes()); + + initialReader.close(); + targetStream.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingReaderIntoInputStream() throws IOException { + final Reader initialReader = new StringReader("With Commons IO"); + + final InputStream targetStream = IOUtils.toInputStream(initialReader.toString()); + + initialReader.close(); + targetStream.close(); + } + } diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java index 0d9f6d1f06b1..42ecef408692 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java @@ -1,18 +1,24 @@ package org.baeldung.java.io; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.nio.charset.Charset; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CharSequenceReader; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.io.ByteSource; +import com.google.common.io.ByteStreams; import com.google.common.io.CharSource; public class JavaXToReaderUnitTest { @@ -94,4 +100,35 @@ public void givenUsingCommonsIO_whenConvertingFileIntoReader_thenCorrect() throw targetReader.close(); } + // tests - InputStream to Reader + + @Test + public void givenUsingPlainJava_whenConvertingInputStreamIntoReader_thenCorrect() throws IOException { + final InputStream initialStream = new ByteArrayInputStream("With Java".getBytes()); + final Reader targetReader = new InputStreamReader(initialStream); + + initialStream.close(); + targetReader.close(); + } + + @Test + public void givenUsingGuava_whenConvertingInputStreamIntoReader_thenCorrect() throws IOException { + final InputStream initialStream = ByteSource.wrap("With Guava".getBytes()).openStream(); + final byte[] buffer = ByteStreams.toByteArray(initialStream); + final Reader targetReader = CharSource.wrap(new String(buffer)).openStream(); + + initialStream.close(); + targetReader.close(); + } + + @Test + public void givenUsingCommonsIO_whenConvertingInputStreamIntoReader_thenCorrect() throws IOException { + final InputStream initialStream = IOUtils.toInputStream("With Commons IO"); + final byte[] buffer = IOUtils.toByteArray(initialStream); + final Reader targetReader = new CharSequenceReader(new String(buffer)); + + initialStream.close(); + targetReader.close(); + } + } From 15123d8d5aec74d296ce51b52310b817f1b16bec Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Wed, 16 Jul 2014 11:28:51 -0400 Subject: [PATCH 576/796] Updated the tutorial examples: remove change name example, and setVisibility example --- .../field/MyDtoCustomizedPropertyName.java | 50 ----------------- .../java/org/baeldung/jackson/field/User.java | 50 ----------------- .../jackson/test/JacksonFieldUnitTest.java | 56 +++---------------- 3 files changed, 7 insertions(+), 149 deletions(-) delete mode 100644 jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java delete mode 100644 jackson/src/test/java/org/baeldung/jackson/field/User.java diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java deleted file mode 100644 index 8fbfb41cd81c..000000000000 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoCustomizedPropertyName.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.baeldung.jackson.field; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MyDtoCustomizedPropertyName { - - private String stringValue; - private int intValue; - @JsonProperty("BOOLEANVALUE") - private boolean booleanValue; - - public MyDtoCustomizedPropertyName() { - super(); - } - - public MyDtoCustomizedPropertyName(final String stringValue, final int intValue, final boolean booleanValue) { - super(); - - this.stringValue = stringValue; - this.intValue = intValue; - this.booleanValue = booleanValue; - } - - // API - - public String getStringValue() { - return stringValue; - } - - public void setStringValue(final String stringValue) { - this.stringValue = stringValue; - } - - public int getIntValue() { - return intValue; - } - - public void setIntValue(final int intValue) { - this.intValue = intValue; - } - - public boolean getBooleanValue() { - return booleanValue; - } - - public void setBooleanValue(final boolean booleanValue) { - this.booleanValue = booleanValue; - } - -} diff --git a/jackson/src/test/java/org/baeldung/jackson/field/User.java b/jackson/src/test/java/org/baeldung/jackson/field/User.java deleted file mode 100644 index 1210fd992e6c..000000000000 --- a/jackson/src/test/java/org/baeldung/jackson/field/User.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.baeldung.jackson.field; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class User { - - private int id; - private String name; - @JsonIgnore - private String password; - - public User() { - super(); - } - - public User(final int id, final String name, final String password) { - this.id = id; - this.name = name; - this.password = password; - } - - // API - public int getId() { - return id; - } - - public void setId(final int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - @JsonIgnore - public String getPassword() { - return password; - } - - @JsonProperty - public void setPassword(final String password) { - this.password = password; - } - -} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index 7cb14c415187..a7394d912932 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -9,14 +9,13 @@ import java.io.IOException; import org.baeldung.jackson.field.MyDtoAccessLevel; -import org.baeldung.jackson.field.MyDtoCustomizedPropertyName; import org.baeldung.jackson.field.MyDtoGetter; import org.baeldung.jackson.field.MyDtoGetterImplicitDeserialization; import org.baeldung.jackson.field.MyDtoSetter; -import org.baeldung.jackson.field.User; import org.junit.Test; -import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -89,59 +88,18 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSeriali } @Test - public final void givenCustomizedPropertyName_whenFieldAnnotated_thenPropertyNameCustomizedOnSerialization() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException, JsonMappingException, IOException { final ObjectMapper mapper = new ObjectMapper(); + mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); + mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); - final MyDtoCustomizedPropertyName dtoObject = new MyDtoCustomizedPropertyName(); + final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); final String dtoAsString = mapper.writeValueAsString(dtoObject); assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, containsString("intValue")); - assertThat(dtoAsString, containsString("BOOLEANVALUE")); - assertThat(dtoAsString, not(containsString("booleanValue"))); + assertThat(dtoAsString, containsString("booleanValue")); System.out.println(dtoAsString); } - @Test - public final void givenCustomizedPropertyName_whenFieldAnnotated_thenPropertyNameCustomizedOnDeserialization() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"BOOLEANVALUE\":\"true\"}"; - final ObjectMapper mapper = new ObjectMapper(); - - final MyDtoCustomizedPropertyName dtoObject = mapper.readValue(jsonAsString, MyDtoCustomizedPropertyName.class); - - assertNotNull(dtoObject); - assertThat(dtoObject.getStringValue(), equalTo("dtoString")); - assertThat(dtoObject.getIntValue(), equalTo(1)); - assertThat(dtoObject.getBooleanValue(), equalTo(true)); - } - - @Test - public final void givenFieldIsIgnoredOnlyAtSerialization_whenUserIsSerialized_thenIgnored() throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - - final User userObject = new User(); - userObject.setId(1); - userObject.setName("theUser"); - userObject.setPassword("thePassword"); - - final String userAsString = mapper.writeValueAsString(userObject); - assertThat(userAsString, containsString("id")); - assertThat(userAsString, containsString("name")); - assertThat(userAsString, not(containsString("password"))); - System.out.println(userAsString); - } - - @Test - public final void givenFieldIsIgnoredOnlyAtSerialization_whenUserIsDeserialized_thenCorrect() throws JsonParseException, JsonMappingException, IOException { - final String jsonAsString = "{\"id\":1,\"name\":\"theUser\",\"password\":\"thePassword\"}"; - final ObjectMapper mapper = new ObjectMapper(); - - final User userObject = mapper.readValue(jsonAsString, User.class); - - assertNotNull(userObject); - assertThat(userObject.getId(), equalTo(1)); - assertThat(userObject.getName(), equalTo("theUser")); - assertThat(userObject.getPassword(), equalTo("thePassword")); - } - } From 1ee5b0580097a781d9d87b387d7aaa99a5b1bf9f Mon Sep 17 00:00:00 2001 From: Dheeraj-Baluja Date: Thu, 17 Jul 2014 01:36:40 +0530 Subject: [PATCH 577/796] adding spring form changes --- .../spring/controller/EmployeeController.java | 33 ++++++++++++++++ .../org/baeldung/spring/form/Employee.java | 33 ++++++++++++++++ .../src/main/resources/webMvcConfig.xml | 21 ++++++---- .../webapp/WEB-INF/view/employeeAdded.jsp | 24 ++++++++++++ .../main/webapp/WEB-INF/view/employeeHome.jsp | 38 +++++++++++++++++++ .../src/main/webapp/WEB-INF/view/error.jsp | 20 ++++++++++ .../src/main/webapp/WEB-INF/web.xml | 2 +- spring-mvc-xml/src/main/webapp/index.jsp | 18 +++++++++ 8 files changed, 181 insertions(+), 8 deletions(-) create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp create mode 100644 spring-mvc-xml/src/main/webapp/index.jsp diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java new file mode 100644 index 000000000000..0057f68df9bb --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java @@ -0,0 +1,33 @@ +package org.baeldung.spring.controller; + +import javax.validation.Valid; + +import org.baeldung.spring.form.Employee; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + + +@Controller +public class EmployeeController { + + @RequestMapping(value = "/employee", method = RequestMethod.GET) + public ModelAndView showForm() { + return new ModelAndView("employeeHome", "employee", new Employee()); + } + + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) + public String submit(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { + if (result.hasErrors()) { + return "error"; + } + model.addAttribute("name", employee.getName()); + model.addAttribute("contactNumber", employee.getContactNumber()); + model.addAttribute("id", employee.getId()); + return "employeeAdded"; + } +} diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java new file mode 100644 index 000000000000..7a9f7a419631 --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java @@ -0,0 +1,33 @@ +package org.baeldung.spring.form; + +public class Employee { + + private String name; + private long id; + private String contactNumber; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + +} diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-mvc-xml/src/main/resources/webMvcConfig.xml index 5f6e26643b25..278f6c553322 100644 --- a/spring-mvc-xml/src/main/resources/webMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/webMvcConfig.xml @@ -1,16 +1,23 @@ - - - - - + + + + + + - + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp new file mode 100644 index 000000000000..1457bc5fc8d3 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp @@ -0,0 +1,24 @@ +<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> + + +Spring MVC Form Handling + + + +

Submitted Employee Information

+
+ + + + + + + + + + + + +
Name :${name}
ID :${id}
Contact Number :${contactNumber}
+ + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp new file mode 100644 index 000000000000..2f434fb7bd52 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp @@ -0,0 +1,38 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + + + +SpringMVCExample + + + +

Welcome, Enter The Employee Details

+ + + + + + + + + + + + + + + + + + +
Name
Id
Contact Number
+
+ + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp new file mode 100644 index 000000000000..8f3d83af1767 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp @@ -0,0 +1,20 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +SpringMVCExample + + + +

Pleas enter the correct details

+ + + + +
Retry
+ + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index 671813ac90c6..1a4128fb500f 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -39,7 +39,7 @@ 10 - index.html + index.jsp \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/index.jsp b/spring-mvc-xml/src/main/webapp/index.jsp new file mode 100644 index 000000000000..1ecfcec9d755 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/index.jsp @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Spring MVC Examples + + + +

Spring MVC Examples

+ + + + \ No newline at end of file From 0d5c627ebc94d5ccada9b2e19219e0e75e076bff Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 19 Jul 2014 21:33:42 +0300 Subject: [PATCH 578/796] testing work in core java --- core-java/pom.xml | 355 +++++++++--------- .../baeldung/java/CoreJavaRandomUnitTest.java | 126 +++++++ 2 files changed, 307 insertions(+), 174 deletions(-) create mode 100644 core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java diff --git a/core-java/pom.xml b/core-java/pom.xml index 1986f3e981e5..5cfd60f74658 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -1,176 +1,183 @@ - - 4.0.0 - org.baeldung - core-java - 0.1-SNAPSHOT - - core-java - - - - - - - com.google.guava - guava - ${guava.version} - - - - org.apache.commons - commons-collections4 - 4.0 - - - - commons-io - commons-io - 2.4 - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - core-java - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - 4.0.5.RELEASE - 3.2.4.RELEASE - - - 4.3.5.Final - 5.1.30 - - - 2.3.3 - - - 1.7.6 - 1.1.1 - - - 5.1.1.Final - - - 17.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.3 - - 2.3.1 - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.8 - - + + 4.0.0 + org.baeldung + core-java + 0.1-SNAPSHOT + + core-java + + + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-collections4 + 4.0 + + + + commons-io + commons-io + 2.4 + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.apache.commons + commons-math3 + 3.3 + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + junit + junit-dep + ${junit.version} + test + + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + core-java + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + 4.0.5.RELEASE + 3.2.4.RELEASE + + + 4.3.5.Final + 5.1.30 + + + 2.3.3 + + + 1.7.6 + 1.1.1 + + + 5.1.1.Final + + + 17.0 + 3.3.2 + + + 1.3 + 4.11 + 1.9.5 + + 4.3.2 + 4.3.3 + + 2.3.1 + + + 3.1 + 2.4 + 2.17 + 2.6 + 1.4.8 + + \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java new file mode 100644 index 000000000000..5ba312e08d48 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java @@ -0,0 +1,126 @@ +package org.baeldung.java; + +import java.util.Random; + +import org.apache.commons.math3.random.RandomDataGenerator; +import org.junit.Test; + +public class CoreJavaRandomUnitTest { + + // tests - random long + + @Test + public void givenUsingPlainJava_whenGeneratingRandomLongUnbounded_thenCorrect() { + final long generatedLong = new Random().nextLong(); + + System.out.println(generatedLong); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomLongBounded_thenCorrect() { + final long leftLimit = 1L; + final long rightLimit = 10L; + final long generatedLong = leftLimit + (long) (Math.random() * (rightLimit - leftLimit)); + + System.out.println(generatedLong); + } + + @Test + public void givenUsingApacheCommons_whenGeneratingRandomLongBounded_thenCorrect() { + final long leftLimit = 10L; + final long rightLimit = 100L; + final long generatedLong = new RandomDataGenerator().nextLong(leftLimit, rightLimit); + + System.out.println(generatedLong); + } + + // tests - random int + + @Test + public void givenUsingPlainJava_whenGeneratingRandomIntegerUnbounded_thenCorrect() { + final int generatedInteger = new Random().nextInt(); + + System.out.println(generatedInteger); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomIntegerBounded_thenCorrect() { + final int leftLimit = 1; + final int rightLimit = 10; + final int generatedInteger = leftLimit + (int) (new Random().nextFloat() * (rightLimit - leftLimit)); + + System.out.println(generatedInteger); + } + + @Test + public void givenUsingApache_whenGeneratingRandomIntegerBounded_thenCorrect() { + final int leftLimit = 1; + final int rightLimit = 10; + final int generatedInteger = new RandomDataGenerator().nextInt(leftLimit, rightLimit); + + System.out.println(generatedInteger); + } + + // tests - random float + + @Test + public void givenUsingPlainJava_whenGeneratingRandomFloatUnbouned_thenCorrect() { + final float generatedFloat = new Random().nextFloat(); + + System.out.println(generatedFloat); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomFloatBouned_thenCorrect() { + final float leftLimit = 1F; + final float rightLimit = 10F; + final float generatedFloat = leftLimit + new Random().nextFloat() * (rightLimit - leftLimit); + + System.out.println(generatedFloat); + } + + @Test + public void givenUsingApache_whenGeneratingRandomFloatBounded_thenCorrect() { + final float leftLimit = 1F; + final float rightLimit = 10F; + final float randomFloat = new RandomDataGenerator().getRandomGenerator().nextFloat(); + final float generatedFloat = leftLimit + randomFloat * (rightLimit - leftLimit); + + System.out.println(generatedFloat); + } + + // tests - random double + + @Test + public void givenUsingPlainJava_whenGeneratingRandomDoubleUnbounded_thenCorrect() { + final double generatedDouble = Math.random(); + + System.out.println(generatedDouble); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomDoubleBounded_thenCorrect() { + final double leftLimit = 1D; + final double rightLimit = 10D; + final double generatedDouble = leftLimit + new Random().nextDouble() * (rightLimit - leftLimit); + + System.out.println(generatedDouble); + } + + @Test + public void givenUsingApache_whenGeneratingRandomDoubleUnbounded_thenCorrect() { + final double generatedDouble = new RandomDataGenerator().getRandomGenerator().nextDouble(); + + System.out.println(generatedDouble); + } + + @Test + public void givenUsingApache_whenGeneratingRandomDoubleBounded_thenCorrect() { + final double leftLimit = 1D; + final double rightLimit = 100D; + final double generatedDouble = new RandomDataGenerator().nextUniform(leftLimit, rightLimit); + + System.out.println(generatedDouble); + } + +} From bda2923a84dba85dced310b418b212d73309afe7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 20 Jul 2014 00:49:02 +0300 Subject: [PATCH 579/796] removing spring forms project --- .../WebContent/META-INF/MANIFEST.MF | 3 -- .../WebContent/WEB-INF/dispatcher-servlet.xml | 27 ------------- .../WEB-INF/views/employeeAdded.jsp | 24 ------------ .../WebContent/WEB-INF/views/employeeHome.jsp | 38 ------------------- .../WebContent/WEB-INF/views/error.jsp | 20 ---------- spring-mvc-forms/WebContent/WEB-INF/web.xml | 19 ---------- spring-mvc-forms/WebContent/index.jsp | 18 --------- .../demo/controllers/EmployeeController.java | 33 ---------------- .../src/com/demo/form/Employee.java | 33 ---------------- 9 files changed, 215 deletions(-) delete mode 100644 spring-mvc-forms/WebContent/META-INF/MANIFEST.MF delete mode 100644 spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml delete mode 100644 spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp delete mode 100644 spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp delete mode 100644 spring-mvc-forms/WebContent/WEB-INF/views/error.jsp delete mode 100644 spring-mvc-forms/WebContent/WEB-INF/web.xml delete mode 100644 spring-mvc-forms/WebContent/index.jsp delete mode 100644 spring-mvc-forms/src/com/demo/controllers/EmployeeController.java delete mode 100644 spring-mvc-forms/src/com/demo/form/Employee.java diff --git a/spring-mvc-forms/WebContent/META-INF/MANIFEST.MF b/spring-mvc-forms/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c074..000000000000 --- a/spring-mvc-forms/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml b/spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml deleted file mode 100644 index 1fc94effba9a..000000000000 --- a/spring-mvc-forms/WebContent/WEB-INF/dispatcher-servlet.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - /WEB-INF/views/ - - - .jsp - - - - \ No newline at end of file diff --git a/spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp deleted file mode 100644 index 1457bc5fc8d3..000000000000 --- a/spring-mvc-forms/WebContent/WEB-INF/views/employeeAdded.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> - - -Spring MVC Form Handling - - - -

Submitted Employee Information

- - - - - - - - - - - - - -
Name :${name}
ID :${id}
Contact Number :${contactNumber}
- - \ No newline at end of file diff --git a/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp deleted file mode 100644 index 497eade8c717..000000000000 --- a/spring-mvc-forms/WebContent/WEB-INF/views/employeeHome.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> - - - - - -SpringMVCExample - - - -

Welcome, Enter The Employee Details

- - - - - - - - - - - - - - - - - - -
Name
Id
Contact Number
-
- - - - \ No newline at end of file diff --git a/spring-mvc-forms/WebContent/WEB-INF/views/error.jsp b/spring-mvc-forms/WebContent/WEB-INF/views/error.jsp deleted file mode 100644 index 8f3d83af1767..000000000000 --- a/spring-mvc-forms/WebContent/WEB-INF/views/error.jsp +++ /dev/null @@ -1,20 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -SpringMVCExample - - - -

Pleas enter the correct details

- - - - -
Retry
- - - - \ No newline at end of file diff --git a/spring-mvc-forms/WebContent/WEB-INF/web.xml b/spring-mvc-forms/WebContent/WEB-INF/web.xml deleted file mode 100644 index 4c122670e511..000000000000 --- a/spring-mvc-forms/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - SpringMVCFormExample - - dispatcher - org.springframework.web.servlet.DispatcherServlet - - 1 - - - dispatcher - / - - - index.jsp - - \ No newline at end of file diff --git a/spring-mvc-forms/WebContent/index.jsp b/spring-mvc-forms/WebContent/index.jsp deleted file mode 100644 index 1ecfcec9d755..000000000000 --- a/spring-mvc-forms/WebContent/index.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -Spring MVC Examples - - - -

Spring MVC Examples

- - - - \ No newline at end of file diff --git a/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java b/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java deleted file mode 100644 index 1dd76ae23f7f..000000000000 --- a/spring-mvc-forms/src/com/demo/controllers/EmployeeController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.demo.controllers; - -import javax.validation.Valid; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.demo.form.Employee; - -@Controller -public class EmployeeController { - - @RequestMapping(value = "/employee", method = RequestMethod.GET) - public ModelAndView showForm() { - return new ModelAndView("employeeHome", "employee", new Employee()); - } - - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) - public String submit(@Valid @ModelAttribute("employee") Employee employee, BindingResult result, ModelMap model) { - if (result.hasErrors()) { - return "error"; - } - model.addAttribute("name", employee.getName()); - model.addAttribute("contactNumber", employee.getContactNumber()); - model.addAttribute("id", employee.getId()); - return "employeeAdded"; - } -} diff --git a/spring-mvc-forms/src/com/demo/form/Employee.java b/spring-mvc-forms/src/com/demo/form/Employee.java deleted file mode 100644 index 569347b62862..000000000000 --- a/spring-mvc-forms/src/com/demo/form/Employee.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.demo.form; - -public class Employee { - - private String name; - private long id; - private String contactNumber; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getContactNumber() { - return contactNumber; - } - - public void setContactNumber(String contactNumber) { - this.contactNumber = contactNumber; - } - -} From a32f9673741780a246ed4069cd1bfc8db6105f38 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 20 Jul 2014 00:52:26 +0300 Subject: [PATCH 580/796] further cleanup work in mvc --- spring-mvc-xml/pom.xml | 8 +++++++- .../baeldung/spring/controller/EmployeeController.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 7238c7ec6051..581de439c600 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -39,6 +39,12 @@ runtime + + org.hibernate + hibernate-validator + 5.1.1.Final + + @@ -120,7 +126,7 @@ maven-war-plugin ${maven-war-plugin.version} - + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java index 0057f68df9bb..007788a843ab 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java @@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; - @Controller public class EmployeeController { @@ -30,4 +29,5 @@ public String submit(@Valid @ModelAttribute("employee") final Employee employee, model.addAttribute("id", employee.getId()); return "employeeAdded"; } + } From e42eab8dfe0c0ec46d4dbf88ba903c081a6cc4d8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 20 Jul 2014 01:29:35 +0300 Subject: [PATCH 581/796] minor cleanup work on form project --- .../main/java/org/baeldung/spring/form/Employee.java | 12 +++++++++--- .../src/main/webapp/WEB-INF/view/employeeHome.jsp | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java index 7a9f7a419631..5de3d3c89923 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java @@ -6,11 +6,17 @@ public class Employee { private long id; private String contactNumber; + public Employee() { + super(); + } + + // + public String getName() { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -18,7 +24,7 @@ public long getId() { return id; } - public void setId(long id) { + public void setId(final long id) { this.id = id; } @@ -26,7 +32,7 @@ public String getContactNumber() { return contactNumber; } - public void setContactNumber(String contactNumber) { + public void setContactNumber(final String contactNumber) { this.contactNumber = contactNumber; } diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp index 2f434fb7bd52..97b81b76932f 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp @@ -1,19 +1,14 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> - - SpringMVCExample -

Welcome, Enter The Employee Details

- + From c96bdead45c4106ef780dc219e1727c89f2eaac3 Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Mon, 21 Jul 2014 08:05:53 -0400 Subject: [PATCH 582/796] Changes to reduce fields not necessary. --- .../test/java/org/baeldung/jackson/field/MyDtoGetter.java | 4 +--- .../jackson/field/MyDtoGetterImplicitDeserialization.java | 6 ------ .../test/java/org/baeldung/jackson/field/MyDtoSetter.java | 2 -- .../org/baeldung/jackson/test/JacksonFieldUnitTest.java | 8 ++------ 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java index 12feb9862883..ea4ae529fe6d 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java @@ -3,8 +3,7 @@ public class MyDtoGetter { private String stringValue; - int intValue; - public boolean booleanValue; + private int intValue; public MyDtoGetter() { super(); @@ -15,7 +14,6 @@ public MyDtoGetter(final String stringValue, final int intValue, final boolean b this.stringValue = stringValue; this.intValue = intValue; - this.booleanValue = booleanValue; } // API diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java index ee9d346a0ac6..da4e5ebe42e5 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java @@ -3,7 +3,6 @@ public class MyDtoGetterImplicitDeserialization { private String stringValue; - int intValue; public boolean booleanValue; public MyDtoGetterImplicitDeserialization() { @@ -14,7 +13,6 @@ public MyDtoGetterImplicitDeserialization(final String stringValue, final int in super(); this.stringValue = stringValue; - this.intValue = intValue; this.booleanValue = booleanValue; } @@ -24,8 +22,4 @@ public String getStringValue() { return stringValue; } - public int getIntValue() { - return intValue; - } - } diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java index 391b1959aecf..11e4bee6eba6 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -4,7 +4,6 @@ public class MyDtoSetter { private String stringValue; int intValue; - public boolean booleanValue; public MyDtoSetter() { super(); @@ -15,7 +14,6 @@ public MyDtoSetter(final String stringValue, final int intValue, final boolean b this.stringValue = stringValue; this.intValue = intValue; - this.booleanValue = booleanValue; } // API diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index a7394d912932..fc8c7ff17637 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -44,26 +44,24 @@ public final void givenDifferentAccessLevels_whenGetterAdded_thenSerializable() final String dtoAsString = mapper.writeValueAsString(dtoObject); assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); System.out.println(dtoAsString); } @Test public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"booleanValue\":\"true\"}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoGetterImplicitDeserialization dtoObject = mapper.readValue(jsonAsString, MyDtoGetterImplicitDeserialization.class); assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); - assertThat(dtoObject.getIntValue(), equalTo(1)); assertThat(dtoObject.booleanValue, equalTo(true)); } @Test public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); @@ -71,7 +69,6 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable( assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); - assertThat(dtoObject.booleanValue, equalTo(true)); } @Test @@ -83,7 +80,6 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSeriali final String dtoAsString = mapper.writeValueAsString(dtoObject); assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); System.out.println(dtoAsString); } From 04f7919eb3b0ea3af72cacb0e0c11557a1a15cd8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Jul 2014 22:08:24 +0300 Subject: [PATCH 583/796] java random examples --- .../baeldung/java/CoreJavaRandomUnitTest.java | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java index 5ba312e08d48..17a78651ffdc 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java @@ -2,6 +2,7 @@ import java.util.Random; +import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.math3.random.RandomDataGenerator; import org.junit.Test; @@ -99,17 +100,17 @@ public void givenUsingPlainJava_whenGeneratingRandomDoubleUnbounded_thenCorrect( } @Test - public void givenUsingPlainJava_whenGeneratingRandomDoubleBounded_thenCorrect() { - final double leftLimit = 1D; - final double rightLimit = 10D; - final double generatedDouble = leftLimit + new Random().nextDouble() * (rightLimit - leftLimit); + public void givenUsingApache_whenGeneratingRandomDoubleUnbounded_thenCorrect() { + final double generatedDouble = new RandomDataGenerator().getRandomGenerator().nextDouble(); System.out.println(generatedDouble); } @Test - public void givenUsingApache_whenGeneratingRandomDoubleUnbounded_thenCorrect() { - final double generatedDouble = new RandomDataGenerator().getRandomGenerator().nextDouble(); + public void givenUsingPlainJava_whenGeneratingRandomDoubleBounded_thenCorrect() { + final double leftLimit = 1D; + final double rightLimit = 10D; + final double generatedDouble = leftLimit + new Random().nextDouble() * (rightLimit - leftLimit); System.out.println(generatedDouble); } @@ -123,4 +124,47 @@ public void givenUsingApache_whenGeneratingRandomDoubleBounded_thenCorrect() { System.out.println(generatedDouble); } + // tests - random String + + @Test + public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() { + final byte[] array = new byte[7]; // length is bounded by 7 + new Random().nextBytes(array); + final String generatedString = new String(array); + + System.out.println(generatedString); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() { + final int leftLimit = 97; // letter 'a' + final int rightLimit = 122; // letter 'z' + final int targetStringLength = 10; + final StringBuilder buffer = new StringBuilder(targetStringLength); + for (int i = 0; i < targetStringLength; i++) { + final int randomLimitedInt = leftLimit + (int) (new Random().nextFloat() * (rightLimit - leftLimit)); + buffer.append((char) randomLimitedInt); + } + final String generatedString = new String(buffer); + + System.out.println(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomStringUnbounded_thenCorrect() { + final String generatedString = RandomStringUtils.random(10); + + System.out.println(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() { + final int length = 10; + final boolean useLetters = true; + final boolean useNumbers = false; + final String generatedString = RandomStringUtils.random(length, useLetters, useNumbers); + + System.out.println(generatedString); + } + } From 3074920322845cc09ad44b22be51bf27c546b82e Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Jul 2014 22:48:18 +0300 Subject: [PATCH 584/796] minor jackson testing work --- .../baeldung/jackson/test/JacksonFieldUnitTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index fc8c7ff17637..5acc3a92af05 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -17,13 +17,12 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; public class JacksonFieldUnitTest { @Test - public final void givenDifferentAccessLevels_whenPrivateOrPackage_thenNotSerializable_whenPublic_thenSerializable() throws JsonProcessingException { + public final void givenDifferentAccessLevels_whenSerializing_thenPublicFieldsAreSerialized() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); @@ -48,7 +47,7 @@ public final void givenDifferentAccessLevels_whenGetterAdded_thenSerializable() } @Test - public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws IOException { final String jsonAsString = "{\"stringValue\":\"dtoString\",\"booleanValue\":\"true\"}"; final ObjectMapper mapper = new ObjectMapper(); @@ -60,7 +59,7 @@ public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable( } @Test - public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws IOException { final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1}"; final ObjectMapper mapper = new ObjectMapper(); @@ -72,7 +71,7 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable( } @Test - public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws IOException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = new MyDtoSetter(); @@ -84,7 +83,7 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSeriali } @Test - public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws IOException { final ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); From fc35344f89e0de4307459ff6e4aa08b7006a7c54 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Mon, 21 Jul 2014 16:39:43 -0500 Subject: [PATCH 585/796] Spring MVC Security Error Handling Code Samples --- .../.springBeans | 15 ++ spring-security-login-error-handling/pom.xml | 226 ++++++++++++++++++ ...SimpleUrlAuthenticationSuccessHandler.java | 81 +++++++ .../java/org/baeldung/spring/MvcConfig.java | 77 ++++++ .../baeldung/spring/SecSecurityConfig.java | 13 + .../src/main/resources/logback.xml | 20 ++ .../src/main/resources/messages_en.properties | 9 + .../main/resources/messages_es_ES.properties | 9 + .../src/main/resources/webSecurityConfig.xml | 38 +++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 10 + .../src/main/webapp/WEB-INF/view/admin.jsp | 23 ++ .../src/main/webapp/WEB-INF/view/console.jsp | 23 ++ .../src/main/webapp/WEB-INF/view/home.jsp | 13 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 28 +++ .../webapp/WEB-INF/view/invalidSession.jsp | 12 + .../src/main/webapp/WEB-INF/view/login.jsp | 77 ++++++ .../src/main/webapp/WEB-INF/view/logout.jsp | 24 ++ .../main/webapp/WEB-INF/view/registration.jsp | 12 + .../src/main/webapp/WEB-INF/web.xml | 41 ++++ .../src/test/java/.springBeans | 15 ++ .../src/test/java/pom.xml | 225 +++++++++++++++++ 21 files changed, 991 insertions(+) create mode 100644 spring-security-login-error-handling/.springBeans create mode 100644 spring-security-login-error-handling/pom.xml create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 spring-security-login-error-handling/src/main/resources/logback.xml create mode 100644 spring-security-login-error-handling/src/main/resources/messages_en.properties create mode 100644 spring-security-login-error-handling/src/main/resources/messages_es_ES.properties create mode 100644 spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-login-error-handling/src/test/java/.springBeans create mode 100644 spring-security-login-error-handling/src/test/java/pom.xml diff --git a/spring-security-login-error-handling/.springBeans b/spring-security-login-error-handling/.springBeans new file mode 100644 index 000000000000..8096aa036b39 --- /dev/null +++ b/spring-security-login-error-handling/.springBeans @@ -0,0 +1,15 @@ + + + 1 + + + + + + + + + + + + diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml new file mode 100644 index 000000000000..f806df03914f --- /dev/null +++ b/spring-security-login-error-handling/pom.xml @@ -0,0 +1,226 @@ + + + 4.0.0 + org.baeldung + spring-security-login-error-handling + spring-security-login-error-handling + war + 1.0.0-BUILD-SNAPSHOT + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + 1.6.6 + + + org.springframework.boot + spring-boot-starter-parent + 1.1.1.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context + + + + commons-logging + commons-logging + + + + + org.springframework + spring-core + + + + org.springframework + spring-webmvc + + + + org.springframework + spring-jdbc + + + + org.springframework + spring-beans + + + + org.springframework + spring-aop + + + org.springframework + spring-tx + + + org.springframework + spring-expression + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.springframework.security + spring-security-config + runtime + + + + org.aspectj + aspectjrt + + + + javax.validation + validation-api + 1.1.0.Final + + + org.hibernate + hibernate-validator + + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + runtime + + + org.slf4j + slf4j-log4j12 + runtime + + + log4j + log4j + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + runtime + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + + + + + org.springframework.security + spring-security-taglibs + + + + junit + junit + test + + + + + SpringSecurityLogin + + + src/main/resources + true + + + + + maven-eclipse-plugin + + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + + 1.7 + 1.7 + -Xlint:all + true + true + + + + org.apache.maven.plugins + maven-war-plugin + + + + org.codehaus.mojo + exec-maven-plugin + + + org.test.int1.Main + + + + + diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..88862d603ebe --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,81 @@ +package org.baeldung.security; + +import java.io.IOException; +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + protected Log logger = LogFactory.getLog(this.getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + handle(request, response, authentication); + HttpSession session = request.getSession(false); + if (session != null) { + session.setMaxInactiveInterval(30); + } + clearAuthenticationAttributes(request); + } + + protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + String targetUrl = determineTargetUrl(authentication); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + protected String determineTargetUrl(Authentication authentication) { + boolean isUser = false; + boolean isAdmin = false; + Collection authorities = authentication.getAuthorities(); + for (GrantedAuthority grantedAuthority : authorities) { + if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + isUser = true; + break; + } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + isAdmin = true; + break; + } + } + if (isUser) { + return "/homepage.html"; + } else if (isAdmin) { + return "/console.html"; + } else { + throw new IllegalStateException(); + } + } + + protected void clearAuthenticationAttributes(HttpServletRequest request) { + HttpSession session = request.getSession(false); + if (session == null) { + return; + } + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + + public void setRedirectStrategy(RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } +} \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..3cecdd958822 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,77 @@ +package org.baeldung.spring; + +import java.util.Locale; + +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ReloadableResourceBundleMessageSource; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.i18n.CookieLocaleResolver; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/login.html"); + registry.addViewController("/logout.html"); + registry.addViewController("/homepage.html"); + registry.addViewController("/home.html"); + registry.addViewController("/invalidSession.html"); + registry.addViewController("/console.html"); + registry.addViewController("/admin.html"); + registry.addViewController("/registration.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); + localeChangeInterceptor.setParamName("lang"); + registry.addInterceptor(localeChangeInterceptor); + } + + @Bean + public LocaleResolver localeResolver() { + CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver(); + cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH); + return cookieLocaleResolver; + } + + @Bean + public MessageSource messageSource() { + ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); + messageSource.setBasename("classpath:messages"); + messageSource.setUseCodeAsDefaultMessage(true); + messageSource.setDefaultEncoding("UTF-8"); + messageSource.setCacheSeconds(0); + return messageSource; + } +} \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..99efdf42371e --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,13 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } +} diff --git a/spring-security-login-error-handling/src/main/resources/logback.xml b/spring-security-login-error-handling/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-login-error-handling/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-error-handling/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..3e05a6b76a3b --- /dev/null +++ b/spring-security-login-error-handling/src/main/resources/messages_en.properties @@ -0,0 +1,9 @@ +message.username=Username required +message.password=Password required +message.unauth=Unauthorized Access !! +message.badCredentials=Invalid Username or Password +message.sessionExpired=Session Timed Out +message.logoutError=Sorry, error logging out +message.logoutSucc=You logged out successfully +message.regSucc=You registrated correctly, please log in +message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties new file mode 100644 index 000000000000..842a899e4316 --- /dev/null +++ b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties @@ -0,0 +1,9 @@ +message.username=Por favor ingrese el nombre de usuario +message.password=Por favor ingrese una clave +message.unauth=Acceso denegado !! +message.badCredentials=Usuario o clave invalida +message.sessionExpired=La sesion expiro +message.logoutError=Lo sentimos, hubo problemas en logout +message.logoutSucc=Logout con exito +message.regSucc=Se registro correctamente, por favor ingrese +message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..809fdd164df7 --- /dev/null +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..b885d2c10aef --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp new file mode 100644 index 000000000000..12f9f7aba986 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + + + + + + + + + +

Hello Admin

+
+ + ">Logout + ">Home + + + + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..05a930731be4 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Administrator Page + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp new file mode 100644 index 000000000000..fe6e572b99f9 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp @@ -0,0 +1,13 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ page session="true" %> + + + Home + + +

+ Welcome back home! +

+ + + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..fab96383df5d --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,28 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@ page session="true" %> + + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Home + ">Administrator Page + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp new file mode 100644 index 000000000000..175c49811730 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -0,0 +1,12 @@ +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + Home + + +

+ +

+ + + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..95559b045511 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,77 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="false"%> + +
+ +
+
+ +
+ +
+
+ + +
+ +
+ Register +
+ + + + + + + + + +

Login

+ English | + Spanish +
+ +
Name
+ + + + + + + + + + + +
User:
Password:
+ + +
Current Locale : ${pageContext.response.locale} + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp new file mode 100644 index 000000000000..e8618b74e3aa --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp @@ -0,0 +1,24 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + +
+ +
+
+ +
+ +
+
+ + + +Logged Out + + + + Login + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp new file mode 100644 index 000000000000..474a1817b52a --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=US-ASCII" + pageEncoding="US-ASCII"%> + + + + +Registration + + +

This is the registration page

+ + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..463b3093771c --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/test/java/.springBeans b/spring-security-login-error-handling/src/test/java/.springBeans new file mode 100644 index 000000000000..8096aa036b39 --- /dev/null +++ b/spring-security-login-error-handling/src/test/java/.springBeans @@ -0,0 +1,15 @@ + + + 1 + + + + + + + + + + + + diff --git a/spring-security-login-error-handling/src/test/java/pom.xml b/spring-security-login-error-handling/src/test/java/pom.xml new file mode 100644 index 000000000000..5ff5926f60da --- /dev/null +++ b/spring-security-login-error-handling/src/test/java/pom.xml @@ -0,0 +1,225 @@ + + + 4.0.0 + com.egm + SpringSecurityLogin + SpringSecurityLogin + war + 1.0.0-BUILD-SNAPSHOT + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + 1.6.6 + + + org.springframework.boot + spring-boot-starter-parent + 1.1.1.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context + + + + commons-logging + commons-logging + + + + + org.springframework + spring-core + + + + org.springframework + spring-webmvc + + + + org.springframework + spring-jdbc + + + + org.springframework + spring-beans + + + + org.springframework + spring-aop + + + org.springframework + spring-tx + + + org.springframework + spring-expression + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.springframework.security + spring-security-config + runtime + + + + org.aspectj + aspectjrt + + + + javax.validation + validation-api + 1.1.0.Final + + + org.hibernate + hibernate-validator + + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + runtime + + + org.slf4j + slf4j-log4j12 + runtime + + + log4j + log4j + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + runtime + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + + + + org.springframework.security + spring-security-taglibs + + + + junit + junit + test + + + + + SpringSecurityLogin + + + src/main/resources + true + + + + + maven-eclipse-plugin + + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + + 1.7 + 1.7 + -Xlint:all + true + true + + + + org.apache.maven.plugins + maven-war-plugin + + + + org.codehaus.mojo + exec-maven-plugin + + + org.test.int1.Main + + + + + From 1461358381cf1debe8eb76004367986dbd5a69da Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 22 Jul 2014 01:10:21 +0300 Subject: [PATCH 586/796] minor cleanup work --- spring-security-login-error-handling/pom.xml | 41 ++-- ...SimpleUrlAuthenticationSuccessHandler.java | 6 +- .../java/org/baeldung/spring/MvcConfig.java | 1 + .../baeldung/spring/SecSecurityConfig.java | 1 + .../src/test/java/.springBeans | 15 -- .../src/test/java/pom.xml | 225 ------------------ 6 files changed, 29 insertions(+), 260 deletions(-) delete mode 100644 spring-security-login-error-handling/src/test/java/.springBeans delete mode 100644 spring-security-login-error-handling/src/test/java/pom.xml diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index f806df03914f..81c3c4f78520 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -7,19 +7,15 @@ spring-security-login-error-handling war 1.0.0-BUILD-SNAPSHOT - - 1.7 - 3.1.1.RELEASE - 3.2.4.RELEASE - 1.6.10 - 1.6.6 - + org.springframework.boot spring-boot-starter-parent 1.1.1.RELEASE + + org.springframework.boot @@ -39,22 +35,18 @@ org.springframework spring-core - org.springframework spring-webmvc - org.springframework spring-jdbc - org.springframework spring-beans - org.springframework @@ -81,21 +73,24 @@ spring-security-config runtime + org.aspectj aspectjrt + javax.validation - validation-api - 1.1.0.Final + validation-api + 1.1.0.Final org.hibernate hibernate-validator + org.slf4j @@ -160,11 +155,13 @@ jstl + org.springframework.security spring-security-taglibs + junit @@ -173,6 +170,7 @@ + SpringSecurityLogin @@ -181,10 +179,10 @@ true + maven-eclipse-plugin - org.springframework.ide.eclipse.core.springnature @@ -196,10 +194,10 @@ true + org.apache.maven.plugins maven-compiler-plugin - 1.7 1.7 @@ -208,19 +206,28 @@ true + org.apache.maven.plugins maven-war-plugin - + org.codehaus.mojo exec-maven-plugin - org.test.int1.Main + + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + 1.6.6 + +
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java index 88862d603ebe..825eaba71eda 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -7,8 +7,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.web.DefaultRedirectStrategy; @@ -17,7 +17,7 @@ import org.springframework.security.web.authentication.AuthenticationSuccessHandler; public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { - protected Log logger = LogFactory.getLog(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index 3cecdd958822..2d83d6a5d98a 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -74,4 +74,5 @@ public MessageSource messageSource() { messageSource.setCacheSeconds(0); return messageSource; } + } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 99efdf42371e..3e793a33f660 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -10,4 +10,5 @@ public class SecSecurityConfig { public SecSecurityConfig() { super(); } + } diff --git a/spring-security-login-error-handling/src/test/java/.springBeans b/spring-security-login-error-handling/src/test/java/.springBeans deleted file mode 100644 index 8096aa036b39..000000000000 --- a/spring-security-login-error-handling/src/test/java/.springBeans +++ /dev/null @@ -1,15 +0,0 @@ - - - 1 - - - - - - - - - - - - diff --git a/spring-security-login-error-handling/src/test/java/pom.xml b/spring-security-login-error-handling/src/test/java/pom.xml deleted file mode 100644 index 5ff5926f60da..000000000000 --- a/spring-security-login-error-handling/src/test/java/pom.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - 4.0.0 - com.egm - SpringSecurityLogin - SpringSecurityLogin - war - 1.0.0-BUILD-SNAPSHOT - - 1.7 - 3.1.1.RELEASE - 3.2.4.RELEASE - 1.6.10 - 1.6.6 - - - org.springframework.boot - spring-boot-starter-parent - 1.1.1.RELEASE - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context - - - - commons-logging - commons-logging - - - - - org.springframework - spring-core - - - - org.springframework - spring-webmvc - - - - org.springframework - spring-jdbc - - - - org.springframework - spring-beans - - - - org.springframework - spring-aop - - - org.springframework - spring-tx - - - org.springframework - spring-expression - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.springframework.security - spring-security-config - runtime - - - - org.aspectj - aspectjrt - - - - javax.validation - validation-api - 1.1.0.Final - - - org.hibernate - hibernate-validator - - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - runtime - - - org.slf4j - slf4j-log4j12 - runtime - - - log4j - log4j - - - javax.mail - mail - - - javax.jms - jms - - - com.sun.jdmk - jmxtools - - - com.sun.jmx - jmxri - - - runtime - - - - - javax.inject - javax.inject - 1 - - - - - javax.servlet - servlet-api - 2.5 - provided - - - javax.servlet.jsp - jsp-api - 2.1 - provided - - - javax.servlet - jstl - - - - org.springframework.security - spring-security-taglibs - - - - junit - junit - test - - - - - SpringSecurityLogin - - - src/main/resources - true - - - - - maven-eclipse-plugin - - - - org.springframework.ide.eclipse.core.springnature - - - org.springframework.ide.eclipse.core.springbuilder - - true - true - - - - org.apache.maven.plugins - maven-compiler-plugin - - - 1.7 - 1.7 - -Xlint:all - true - true - - - - org.apache.maven.plugins - maven-war-plugin - - - - org.codehaus.mojo - exec-maven-plugin - - - org.test.int1.Main - - - - - From 5db4ad448c7eeb557de51933dc0c596a45c6b924 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 22 Jul 2014 01:14:07 +0300 Subject: [PATCH 587/796] maven work --- spring-security-login-error-handling/pom.xml | 46 +++++++------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index 81c3c4f78520..aef8b966dde8 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.1.1.RELEASE + 1.1.4.RELEASE @@ -91,43 +91,25 @@ hibernate-validator - + + org.slf4j slf4j-api - org.slf4j - jcl-over-slf4j - runtime + ch.qos.logback + logback-classic + org.slf4j - slf4j-log4j12 - runtime + jcl-over-slf4j + - - log4j - log4j - - - javax.mail - mail - - - javax.jms - jms - - - com.sun.jdmk - jmxtools - - - com.sun.jmx - jmxri - - - runtime + + org.slf4j + log4j-over-slf4j @@ -227,7 +209,11 @@ 3.1.1.RELEASE 3.2.4.RELEASE 1.6.10 - 1.6.6 + + + 1.7.6 + 1.1.1 + From f5bcc39c75bba494ee1025dc4d1dc33486868375 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 22 Jul 2014 01:34:34 +0300 Subject: [PATCH 588/796] minor maven cleanup and formatting work --- spring-security-login-error-handling/pom.xml | 7 ---- .../src/main/resources/webSecurityConfig.xml | 34 +++++++++---------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index aef8b966dde8..d26e2d0d4437 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -81,18 +81,12 @@ - - javax.validation - validation-api - 1.1.0.Final - org.hibernate hibernate-validator - org.slf4j slf4j-api @@ -135,7 +129,6 @@ javax.servlet jstl - diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index 809fdd164df7..46550f03da76 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -17,22 +17,20 @@ - - - - - - - - - - - - + default-target-url="/homepage.html" /> + + + + + + + + + + + + \ No newline at end of file From 52a134d5c0699b2ae504088189c25195140f925a Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 22 Jul 2014 01:52:15 +0300 Subject: [PATCH 589/796] small spring upgrade --- spring-security-rest-full/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index cb5d3c45610f..173f3bed6ff4 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -371,13 +371,13 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE 4.3.5.Final - 5.1.30 - 1.6.0.RELEASE + 5.1.31 + 1.6.1.RELEASE From 09b4633741d022a8f74d6ad7c5ca430fe8fb0a80 Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Tue, 22 Jul 2014 09:09:34 -0400 Subject: [PATCH 590/796] Reduce fields not necessary. --- .../org/baeldung/jackson/field/MyDtoGetter.java | 2 +- .../field/MyDtoGetterImplicitDeserialization.java | 4 +--- .../org/baeldung/jackson/field/MyDtoSetter.java | 12 ++++-------- .../baeldung/jackson/test/JacksonFieldUnitTest.java | 13 +++++-------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java index ea4ae529fe6d..b0725b9d6579 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java @@ -9,7 +9,7 @@ public MyDtoGetter() { super(); } - public MyDtoGetter(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoGetter(final String stringValue, final int intValue) { super(); this.stringValue = stringValue; diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java index da4e5ebe42e5..0c5027ac243a 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java @@ -3,17 +3,15 @@ public class MyDtoGetterImplicitDeserialization { private String stringValue; - public boolean booleanValue; public MyDtoGetterImplicitDeserialization() { super(); } - public MyDtoGetterImplicitDeserialization(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoGetterImplicitDeserialization(final String stringValue) { super(); this.stringValue = stringValue; - this.booleanValue = booleanValue; } // API diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java index 11e4bee6eba6..47c793874381 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -2,26 +2,22 @@ public class MyDtoSetter { - private String stringValue; - int intValue; + private int intValue; + public boolean booleanValue; public MyDtoSetter() { super(); } - public MyDtoSetter(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoSetter(final int intValue, final boolean booleanValue) { super(); - this.stringValue = stringValue; this.intValue = intValue; + this.booleanValue = booleanValue; } // API - public String getStringValue() { - return stringValue; - } - public void setIntValue(final int intValue) { this.intValue = intValue; } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index fc8c7ff17637..a06e7267b629 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -23,7 +23,7 @@ public class JacksonFieldUnitTest { @Test - public final void givenDifferentAccessLevels_whenPrivateOrPackage_thenNotSerializable_whenPublic_thenSerializable() throws JsonProcessingException { + public final void givenDifferentAccessLevels_whenPublic_thenSerializable() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); @@ -49,42 +49,39 @@ public final void givenDifferentAccessLevels_whenGetterAdded_thenSerializable() @Test public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\"}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoGetterImplicitDeserialization dtoObject = mapper.readValue(jsonAsString, MyDtoGetterImplicitDeserialization.class); assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); - assertThat(dtoObject.booleanValue, equalTo(true)); } @Test public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1}"; + final String jsonAsString = "{\"intValue\":1}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); assertNotNull(dtoObject); - assertThat(dtoObject.getStringValue(), equalTo("dtoString")); assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); } @Test - public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = new MyDtoSetter(); final String dtoAsString = mapper.writeValueAsString(dtoObject); - assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); System.out.println(dtoAsString); } @Test - public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException, JsonMappingException, IOException { + public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); From 0bda9085984e74292065c147d5bf98f740f98e61 Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Tue, 22 Jul 2014 13:37:34 -0400 Subject: [PATCH 591/796] Change one test case title. --- .../java/org/baeldung/jackson/test/JacksonFieldUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index 2f0fb6eb4a2f..e1194a082935 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -22,7 +22,7 @@ public class JacksonFieldUnitTest { @Test - public final void givenDifferentAccessLevels_whenSerializing_thenPublicFieldsAreSerialized() throws JsonProcessingException { + public final void givenDifferentAccessLevels_whenPublic_thenSerializable() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); From a9c3c08670b4888ed3b0176fc24c17f76457f980 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 23 Jul 2014 01:02:08 +0300 Subject: [PATCH 592/796] jackson work --- .../src/test/java/org/baeldung/jackson/field/MyDtoSetter.java | 2 +- .../java/org/baeldung/jackson/test/JacksonFieldUnitTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java index 47c793874381..4680824857e9 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -22,7 +22,7 @@ public void setIntValue(final int intValue) { this.intValue = intValue; } - public int anotherGetIntValue() { + public int alternativeGetIntValue() { return intValue; } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index e1194a082935..44c2ba534d32 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -65,7 +65,7 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable( final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); assertNotNull(dtoObject); - assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); + assertThat(dtoObject.alternativeGetIntValue(), equalTo(1)); } @Test @@ -82,7 +82,6 @@ public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSeriali @Test public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws IOException { final ObjectMapper mapper = new ObjectMapper(); - mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); From b27187d120795750080718be04fab167f8dd1c26 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 22 Jul 2014 17:44:45 -0500 Subject: [PATCH 593/796] Login and Registration Error Handling pom changes POM Changes --- .../bin/.springBeans | 15 ++++ .../{ => bin}/pom.xml | 0 .../bin/src/main/resources/logback.xml | 20 +++++ .../src/main/resources/messages_en.properties | 9 +++ .../main/resources/messages_es_ES.properties | 9 +++ .../src/main/resources/webSecurityConfig.xml | 36 +++++++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 10 +++ .../src/main/webapp/WEB-INF/view/admin.jsp | 23 ++++++ .../src/main/webapp/WEB-INF/view/console.jsp | 23 ++++++ .../bin/src/main/webapp/WEB-INF/view/home.jsp | 13 ++++ .../src/main/webapp/WEB-INF/view/homepage.jsp | 28 +++++++ .../webapp/WEB-INF/view/invalidSession.jsp | 12 +++ .../src/main/webapp/WEB-INF/view/login.jsp | 77 +++++++++++++++++++ .../src/main/webapp/WEB-INF/view/logout.jsp | 24 ++++++ .../main/webapp/WEB-INF/view/registration.jsp | 12 +++ .../bin/src/main/webapp/WEB-INF/web.xml | 41 ++++++++++ 16 files changed, 352 insertions(+) create mode 100644 spring-security-login-error-handling/bin/.springBeans rename spring-security-login-error-handling/{ => bin}/pom.xml (100%) create mode 100644 spring-security-login-error-handling/bin/src/main/resources/logback.xml create mode 100644 spring-security-login-error-handling/bin/src/main/resources/messages_en.properties create mode 100644 spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties create mode 100644 spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp create mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-login-error-handling/bin/.springBeans b/spring-security-login-error-handling/bin/.springBeans new file mode 100644 index 000000000000..8096aa036b39 --- /dev/null +++ b/spring-security-login-error-handling/bin/.springBeans @@ -0,0 +1,15 @@ + + + 1 + + + + + + + + + + + + diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/bin/pom.xml similarity index 100% rename from spring-security-login-error-handling/pom.xml rename to spring-security-login-error-handling/bin/pom.xml diff --git a/spring-security-login-error-handling/bin/src/main/resources/logback.xml b/spring-security-login-error-handling/bin/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties b/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..3e05a6b76a3b --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties @@ -0,0 +1,9 @@ +message.username=Username required +message.password=Password required +message.unauth=Unauthorized Access !! +message.badCredentials=Invalid Username or Password +message.sessionExpired=Session Timed Out +message.logoutError=Sorry, error logging out +message.logoutSucc=You logged out successfully +message.regSucc=You registrated correctly, please log in +message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties new file mode 100644 index 000000000000..842a899e4316 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties @@ -0,0 +1,9 @@ +message.username=Por favor ingrese el nombre de usuario +message.password=Por favor ingrese una clave +message.unauth=Acceso denegado !! +message.badCredentials=Usuario o clave invalida +message.sessionExpired=La sesion expiro +message.logoutError=Lo sentimos, hubo problemas en logout +message.logoutSucc=Logout con exito +message.regSucc=Se registro correctamente, por favor ingrese +message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..46550f03da76 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..b885d2c10aef --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp new file mode 100644 index 000000000000..12f9f7aba986 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + + + + + + + + + +

Hello Admin

+
+ + ">Logout + ">Home + + + + diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..05a930731be4 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Administrator Page + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp new file mode 100644 index 000000000000..fe6e572b99f9 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp @@ -0,0 +1,13 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ page session="true" %> + + + Home + + +

+ Welcome back home! +

+ + + diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..fab96383df5d --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,28 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@ page session="true" %> + + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Home + ">Administrator Page + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp new file mode 100644 index 000000000000..175c49811730 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -0,0 +1,12 @@ +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + Home + + +

+ +

+ + + diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..95559b045511 --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,77 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="false"%> + +
+ +
+
+ +
+ +
+
+ + +
+ +
+ Register +
+ + + + + + + + + +

Login

+ English | + Spanish +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+
Current Locale : ${pageContext.response.locale} + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp new file mode 100644 index 000000000000..e8618b74e3aa --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp @@ -0,0 +1,24 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + +
+ +
+
+ +
+ +
+
+ + + +Logged Out + + + + Login + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp new file mode 100644 index 000000000000..474a1817b52a --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=US-ASCII" + pageEncoding="US-ASCII"%> + + + + +Registration + + +

This is the registration page

+ + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..463b3093771c --- /dev/null +++ b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + \ No newline at end of file From 7cda135e70f99b77230e229ff4dd6c175a014d01 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Tue, 22 Jul 2014 18:02:11 -0500 Subject: [PATCH 594/796] Spring Login Error Handling Additional changes - Properties files and jsps --- bin/.springBeans | 15 ++ bin/pom.xml | 179 ++++++++++++++++++ bin/src/main/resources/logback.xml | 20 ++ bin/src/main/resources/messages_en.properties | 9 + .../main/resources/messages_es_ES.properties | 9 + bin/src/main/resources/webSecurityConfig.xml | 36 ++++ bin/src/main/webapp/WEB-INF/mvc-servlet.xml | 10 + bin/src/main/webapp/WEB-INF/view/admin.jsp | 23 +++ bin/src/main/webapp/WEB-INF/view/console.jsp | 23 +++ bin/src/main/webapp/WEB-INF/view/home.jsp | 13 ++ bin/src/main/webapp/WEB-INF/view/homepage.jsp | 28 +++ .../webapp/WEB-INF/view/invalidSession.jsp | 12 ++ bin/src/main/webapp/WEB-INF/view/login.jsp | 77 ++++++++ bin/src/main/webapp/WEB-INF/view/logout.jsp | 24 +++ .../main/webapp/WEB-INF/view/registration.jsp | 12 ++ bin/src/main/webapp/WEB-INF/web.xml | 41 ++++ pom.xml | 155 +++++++++++---- spring-security-login-error-handling/pom.xml | 116 ++++++++++++ ...SimpleUrlAuthenticationSuccessHandler.java | 81 ++++++++ .../java/org/baeldung/spring/MvcConfig.java | 78 ++++++++ .../baeldung/spring/SecSecurityConfig.java | 14 ++ src/main/resources/logback.xml | 20 ++ src/main/resources/messages_en.properties | 9 + src/main/resources/messages_es_ES.properties | 9 + src/main/resources/webSecurityConfig.xml | 36 ++++ src/main/webapp/WEB-INF/mvc-servlet.xml | 10 + src/main/webapp/WEB-INF/view/admin.jsp | 23 +++ src/main/webapp/WEB-INF/view/console.jsp | 23 +++ src/main/webapp/WEB-INF/view/home.jsp | 13 ++ src/main/webapp/WEB-INF/view/homepage.jsp | 28 +++ .../webapp/WEB-INF/view/invalidSession.jsp | 12 ++ src/main/webapp/WEB-INF/view/login.jsp | 77 ++++++++ src/main/webapp/WEB-INF/view/logout.jsp | 24 +++ src/main/webapp/WEB-INF/view/registration.jsp | 12 ++ src/main/webapp/WEB-INF/web.xml | 41 ++++ 35 files changed, 1273 insertions(+), 39 deletions(-) create mode 100644 bin/.springBeans create mode 100644 bin/pom.xml create mode 100644 bin/src/main/resources/logback.xml create mode 100644 bin/src/main/resources/messages_en.properties create mode 100644 bin/src/main/resources/messages_es_ES.properties create mode 100644 bin/src/main/resources/webSecurityConfig.xml create mode 100644 bin/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 bin/src/main/webapp/WEB-INF/view/admin.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/console.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/home.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/invalidSession.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/logout.jsp create mode 100644 bin/src/main/webapp/WEB-INF/view/registration.jsp create mode 100644 bin/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-login-error-handling/pom.xml create mode 100644 src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java create mode 100644 src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 src/main/resources/logback.xml create mode 100644 src/main/resources/messages_en.properties create mode 100644 src/main/resources/messages_es_ES.properties create mode 100644 src/main/resources/webSecurityConfig.xml create mode 100644 src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 src/main/webapp/WEB-INF/view/admin.jsp create mode 100644 src/main/webapp/WEB-INF/view/console.jsp create mode 100644 src/main/webapp/WEB-INF/view/home.jsp create mode 100644 src/main/webapp/WEB-INF/view/homepage.jsp create mode 100644 src/main/webapp/WEB-INF/view/invalidSession.jsp create mode 100644 src/main/webapp/WEB-INF/view/login.jsp create mode 100644 src/main/webapp/WEB-INF/view/logout.jsp create mode 100644 src/main/webapp/WEB-INF/view/registration.jsp create mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/bin/.springBeans b/bin/.springBeans new file mode 100644 index 000000000000..8096aa036b39 --- /dev/null +++ b/bin/.springBeans @@ -0,0 +1,15 @@ + + + 1 + + + + + + + + + + + + diff --git a/bin/pom.xml b/bin/pom.xml new file mode 100644 index 000000000000..413dbd2c972b --- /dev/null +++ b/bin/pom.xml @@ -0,0 +1,179 @@ + + + 4.0.0 + org.baeldung + spring-security-login-error-handling + spring-security-login-error-handling + war + 1.0.0-BUILD-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 1.1.4.RELEASE + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context + + + + commons-logging + commons-logging + + + + + org.springframework + spring-core + + + org.springframework + spring-webmvc + + + org.springframework + spring-jdbc + + + org.springframework + spring-beans + + + org.springframework + spring-aop + + + org.springframework + spring-tx + + + org.springframework + spring-expression + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.springframework.security + spring-security-config + runtime + + + + + org.aspectj + aspectjrt + + + + + org.hibernate + hibernate-validator + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + + org.slf4j + jcl-over-slf4j + + + + org.slf4j + log4j-over-slf4j + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + javax.servlet-api + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + + + + + org.springframework.security + spring-security-taglibs + + + + + junit + junit + test + + + + + + spring-security-login-and-registration + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-war-plugin + + + + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + + + 1.7.6 + 1.1.1 + + + + diff --git a/bin/src/main/resources/logback.xml b/bin/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/bin/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/src/main/resources/messages_en.properties b/bin/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..3e05a6b76a3b --- /dev/null +++ b/bin/src/main/resources/messages_en.properties @@ -0,0 +1,9 @@ +message.username=Username required +message.password=Password required +message.unauth=Unauthorized Access !! +message.badCredentials=Invalid Username or Password +message.sessionExpired=Session Timed Out +message.logoutError=Sorry, error logging out +message.logoutSucc=You logged out successfully +message.regSucc=You registrated correctly, please log in +message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/bin/src/main/resources/messages_es_ES.properties b/bin/src/main/resources/messages_es_ES.properties new file mode 100644 index 000000000000..842a899e4316 --- /dev/null +++ b/bin/src/main/resources/messages_es_ES.properties @@ -0,0 +1,9 @@ +message.username=Por favor ingrese el nombre de usuario +message.password=Por favor ingrese una clave +message.unauth=Acceso denegado !! +message.badCredentials=Usuario o clave invalida +message.sessionExpired=La sesion expiro +message.logoutError=Lo sentimos, hubo problemas en logout +message.logoutSucc=Logout con exito +message.regSucc=Se registro correctamente, por favor ingrese +message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/bin/src/main/resources/webSecurityConfig.xml b/bin/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..46550f03da76 --- /dev/null +++ b/bin/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/mvc-servlet.xml b/bin/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..b885d2c10aef --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/admin.jsp b/bin/src/main/webapp/WEB-INF/view/admin.jsp new file mode 100644 index 000000000000..12f9f7aba986 --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/admin.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + + + + + + + + + +

Hello Admin

+
+ + ">Logout + ">Home + + + + diff --git a/bin/src/main/webapp/WEB-INF/view/console.jsp b/bin/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..05a930731be4 --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Administrator Page + + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/home.jsp b/bin/src/main/webapp/WEB-INF/view/home.jsp new file mode 100644 index 000000000000..fe6e572b99f9 --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/home.jsp @@ -0,0 +1,13 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ page session="true" %> + + + Home + + +

+ Welcome back home! +

+ + + diff --git a/bin/src/main/webapp/WEB-INF/view/homepage.jsp b/bin/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..fab96383df5d --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,28 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@ page session="true" %> + + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Home + ">Administrator Page + + + + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp b/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp new file mode 100644 index 000000000000..175c49811730 --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -0,0 +1,12 @@ +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + Home + + +

+ +

+ + + diff --git a/bin/src/main/webapp/WEB-INF/view/login.jsp b/bin/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..95559b045511 --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,77 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="false"%> + +
+ +
+
+ +
+ +
+
+ + +
+ +
+ Register +
+ + + + + + + + + +

Login

+ English | + Spanish +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+
Current Locale : ${pageContext.response.locale} + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/logout.jsp b/bin/src/main/webapp/WEB-INF/view/logout.jsp new file mode 100644 index 000000000000..e8618b74e3aa --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/logout.jsp @@ -0,0 +1,24 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + +
+ +
+
+ +
+ +
+
+ + + +Logged Out + + + + Login + + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/registration.jsp b/bin/src/main/webapp/WEB-INF/view/registration.jsp new file mode 100644 index 000000000000..474a1817b52a --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/view/registration.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=US-ASCII" + pageEncoding="US-ASCII"%> + + + + +Registration + + +

This is the registration page

+ + \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/web.xml b/bin/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..463b3093771c --- /dev/null +++ b/bin/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index aa8bc53c5f02..5dad868501e8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,39 +1,116 @@ - - 4.0.0 - org.baeldung - parent - 0.1-SNAPSHOT - parent - pom - - - core-java - experiments - guava - httpclient - jackson - mockito - rest-testing - sandbox - spring-all - spring-exceptions - spring-hibernate3 - spring-hibernate4 - spring-jpa - spring-mvc-java - spring-mvc-no-xml - spring-mvc-xml - spring-rest - spring-security-basic-auth - spring-security-mvc-custom - spring-security-mvc-digest-auth - spring-security-mvc-login - spring-security-mvc-session - spring-security-rest - spring-security-rest-basic-auth - spring-security-rest-custom - spring-security-rest-digest-auth - spring-security-rest-full - - - \ No newline at end of file + + + 4.0.0 + org.baeldung + spring-security-login-and-registration + spring-security-login-and-registration + war + 1.0.0-BUILD-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 1.1.4.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.security + spring-security-config + runtime + + + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + + + org.slf4j + jcl-over-slf4j + + + + + org.slf4j + log4j-over-slf4j + + + + + javax.inject + javax.inject + ${javax.inject.version} + + + + + javax.servlet + javax.servlet-api + + + + javax.servlet.jsp + javax.servlet.jsp-api + ${javax.servlet.jsp-api.version} + + + + javax.servlet + jstl + + + + + org.springframework.security + spring-security-taglibs + + + + + junit + junit + test + + + + spring-security-login-and-registration + + + src/main/resources + true + + + + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + + + 1.7.6 + 1.1.1 + + + 2.3.2-b01 + + + 1 + + + diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml new file mode 100644 index 000000000000..5dad868501e8 --- /dev/null +++ b/spring-security-login-error-handling/pom.xml @@ -0,0 +1,116 @@ + + + 4.0.0 + org.baeldung + spring-security-login-and-registration + spring-security-login-and-registration + war + 1.0.0-BUILD-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 1.1.4.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.security + spring-security-config + runtime + + + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + + + org.slf4j + jcl-over-slf4j + + + + + org.slf4j + log4j-over-slf4j + + + + + javax.inject + javax.inject + ${javax.inject.version} + + + + + javax.servlet + javax.servlet-api + + + + javax.servlet.jsp + javax.servlet.jsp-api + ${javax.servlet.jsp-api.version} + + + + javax.servlet + jstl + + + + + org.springframework.security + spring-security-taglibs + + + + + junit + junit + test + + + + spring-security-login-and-registration + + + src/main/resources + true + + + + + 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 + + + 1.7.6 + 1.1.1 + + + 2.3.2-b01 + + + 1 + + + diff --git a/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..825eaba71eda --- /dev/null +++ b/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,81 @@ +package org.baeldung.security; + +import java.io.IOException; +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + handle(request, response, authentication); + HttpSession session = request.getSession(false); + if (session != null) { + session.setMaxInactiveInterval(30); + } + clearAuthenticationAttributes(request); + } + + protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + String targetUrl = determineTargetUrl(authentication); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + protected String determineTargetUrl(Authentication authentication) { + boolean isUser = false; + boolean isAdmin = false; + Collection authorities = authentication.getAuthorities(); + for (GrantedAuthority grantedAuthority : authorities) { + if (grantedAuthority.getAuthority().equals("ROLE_USER")) { + isUser = true; + break; + } else if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) { + isAdmin = true; + break; + } + } + if (isUser) { + return "/homepage.html"; + } else if (isAdmin) { + return "/console.html"; + } else { + throw new IllegalStateException(); + } + } + + protected void clearAuthenticationAttributes(HttpServletRequest request) { + HttpSession session = request.getSession(false); + if (session == null) { + return; + } + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + + public void setRedirectStrategy(RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } +} \ No newline at end of file diff --git a/src/main/java/org/baeldung/spring/MvcConfig.java b/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..2d83d6a5d98a --- /dev/null +++ b/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,78 @@ +package org.baeldung.spring; + +import java.util.Locale; + +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ReloadableResourceBundleMessageSource; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.i18n.CookieLocaleResolver; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/login.html"); + registry.addViewController("/logout.html"); + registry.addViewController("/homepage.html"); + registry.addViewController("/home.html"); + registry.addViewController("/invalidSession.html"); + registry.addViewController("/console.html"); + registry.addViewController("/admin.html"); + registry.addViewController("/registration.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); + localeChangeInterceptor.setParamName("lang"); + registry.addInterceptor(localeChangeInterceptor); + } + + @Bean + public LocaleResolver localeResolver() { + CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver(); + cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH); + return cookieLocaleResolver; + } + + @Bean + public MessageSource messageSource() { + ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); + messageSource.setBasename("classpath:messages"); + messageSource.setUseCodeAsDefaultMessage(true); + messageSource.setDefaultEncoding("UTF-8"); + messageSource.setCacheSeconds(0); + return messageSource; + } + +} \ No newline at end of file diff --git a/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..3e793a33f660 --- /dev/null +++ b/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..3e05a6b76a3b --- /dev/null +++ b/src/main/resources/messages_en.properties @@ -0,0 +1,9 @@ +message.username=Username required +message.password=Password required +message.unauth=Unauthorized Access !! +message.badCredentials=Invalid Username or Password +message.sessionExpired=Session Timed Out +message.logoutError=Sorry, error logging out +message.logoutSucc=You logged out successfully +message.regSucc=You registrated correctly, please log in +message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/src/main/resources/messages_es_ES.properties b/src/main/resources/messages_es_ES.properties new file mode 100644 index 000000000000..842a899e4316 --- /dev/null +++ b/src/main/resources/messages_es_ES.properties @@ -0,0 +1,9 @@ +message.username=Por favor ingrese el nombre de usuario +message.password=Por favor ingrese una clave +message.unauth=Acceso denegado !! +message.badCredentials=Usuario o clave invalida +message.sessionExpired=La sesion expiro +message.logoutError=Lo sentimos, hubo problemas en logout +message.logoutSucc=Logout con exito +message.regSucc=Se registro correctamente, por favor ingrese +message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/src/main/resources/webSecurityConfig.xml b/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..46550f03da76 --- /dev/null +++ b/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/mvc-servlet.xml b/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..b885d2c10aef --- /dev/null +++ b/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/admin.jsp b/src/main/webapp/WEB-INF/view/admin.jsp new file mode 100644 index 000000000000..12f9f7aba986 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/admin.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + + + + + + + + + +

Hello Admin

+
+ + ">Logout + ">Home + + + + diff --git a/src/main/webapp/WEB-INF/view/console.jsp b/src/main/webapp/WEB-INF/view/console.jsp new file mode 100644 index 000000000000..05a930731be4 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/console.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> + + + + +

This is the landing page for the admin

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Administrator Page + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/home.jsp b/src/main/webapp/WEB-INF/view/home.jsp new file mode 100644 index 000000000000..fe6e572b99f9 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/home.jsp @@ -0,0 +1,13 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ page session="true" %> + + + Home + + +

+ Welcome back home! +

+ + + diff --git a/src/main/webapp/WEB-INF/view/homepage.jsp b/src/main/webapp/WEB-INF/view/homepage.jsp new file mode 100644 index 000000000000..fab96383df5d --- /dev/null +++ b/src/main/webapp/WEB-INF/view/homepage.jsp @@ -0,0 +1,28 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> +<%@ page session="true" %> + + + + + +

This is the homepage for the user

+ + + This text is only visible to a user +
+
+ + + This text is only visible to an admin +
+
+ + ">Logout + ">Home + ">Administrator Page + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/invalidSession.jsp b/src/main/webapp/WEB-INF/view/invalidSession.jsp new file mode 100644 index 000000000000..175c49811730 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -0,0 +1,12 @@ +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + + + Home + + +

+ +

+ + + diff --git a/src/main/webapp/WEB-INF/view/login.jsp b/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..95559b045511 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,77 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="false"%> + +
+ +
+
+ +
+ +
+
+ + +
+ +
+ Register +
+ + + + + + + + + +

Login

+ English | + Spanish +
+ + + + + + + + + + + + + +
User:
Password:
+ +
+
Current Locale : ${pageContext.response.locale} + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/logout.jsp b/src/main/webapp/WEB-INF/view/logout.jsp new file mode 100644 index 000000000000..e8618b74e3aa --- /dev/null +++ b/src/main/webapp/WEB-INF/view/logout.jsp @@ -0,0 +1,24 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> + +
+ +
+
+ +
+ +
+
+ + + +Logged Out + + + + Login + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/registration.jsp b/src/main/webapp/WEB-INF/view/registration.jsp new file mode 100644 index 000000000000..474a1817b52a --- /dev/null +++ b/src/main/webapp/WEB-INF/view/registration.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=US-ASCII" + pageEncoding="US-ASCII"%> + + + + +Registration + + +

This is the registration page

+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..463b3093771c --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + org.springframework.web.context.ContextLoaderListener + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + \ No newline at end of file From 5aa9389a19050a49e1b73de9cad6deae8df3353b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 5 Aug 2014 09:50:16 +0300 Subject: [PATCH 595/796] minor testing work --- .../baeldung/java/CoreJavaRandomUnitTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java index 17a78651ffdc..36eb8d471442 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java @@ -17,6 +17,13 @@ public void givenUsingPlainJava_whenGeneratingRandomLongUnbounded_thenCorrect() System.out.println(generatedLong); } + @Test + public void givenUsingApacheCommons_whenGeneratingRandomLongUnbounded_thenCorrect() { + final long generatedLong = new RandomDataGenerator().getRandomGenerator().nextLong(); + + System.out.println(generatedLong); + } + @Test public void givenUsingPlainJava_whenGeneratingRandomLongBounded_thenCorrect() { final long leftLimit = 1L; @@ -53,6 +60,13 @@ public void givenUsingPlainJava_whenGeneratingRandomIntegerBounded_thenCorrect() System.out.println(generatedInteger); } + @Test + public void givenUsingApache_whenGeneratingRandomIntegerUnbounded_thenCorrect() { + final Integer generatedInteger = new RandomDataGenerator().getRandomGenerator().nextInt(); + + System.out.println(generatedInteger); + } + @Test public void givenUsingApache_whenGeneratingRandomIntegerBounded_thenCorrect() { final int leftLimit = 1; @@ -71,6 +85,13 @@ public void givenUsingPlainJava_whenGeneratingRandomFloatUnbouned_thenCorrect() System.out.println(generatedFloat); } + @Test + public void givenUsingApache_whenGeneratingRandomFloatUnbounded_thenCorrect() { + final float generatedFloat = new RandomDataGenerator().getRandomGenerator().nextFloat(); + + System.out.println(generatedFloat); + } + @Test public void givenUsingPlainJava_whenGeneratingRandomFloatBouned_thenCorrect() { final float leftLimit = 1F; From 2f20d855deac502414b6ffa5571ef24da2c9fd8b Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 5 Aug 2014 11:39:58 +0300 Subject: [PATCH 596/796] maven work --- core-java/.gitignore | 5 ++++- core-java/pom.xml | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core-java/.gitignore b/core-java/.gitignore index 83c05e60c802..6ecc6405c21b 100644 --- a/core-java/.gitignore +++ b/core-java/.gitignore @@ -10,4 +10,7 @@ # Packaged files # *.jar *.war -*.ear \ No newline at end of file +*.ear + +# Files generated by integration tests +*.txt \ No newline at end of file diff --git a/core-java/pom.xml b/core-java/pom.xml index 5cfd60f74658..b10570ad56e1 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -132,6 +132,11 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + + From c1e7dc0d33f90062de1ef1b3ac81006316c2edeb Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 5 Aug 2014 11:43:48 +0300 Subject: [PATCH 597/796] java testing work --- .../baeldung/java/CoreJavaRandomUnitTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java index 36eb8d471442..95cd1b7c5044 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java @@ -172,12 +172,26 @@ public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() } @Test - public void givenUsingApache_whenGeneratingRandomStringUnbounded_thenCorrect() { + public void givenUsingApache_whenGeneratingRandomString_thenCorrect() { final String generatedString = RandomStringUtils.random(10); System.out.println(generatedString); } + @Test + public void givenUsingApache_whenGeneratingRandomAlphabeticString_thenCorrect() { + final String generatedString = RandomStringUtils.randomAlphabetic(10); + + System.out.println(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomAlphanumericString_thenCorrect() { + final String generatedString = RandomStringUtils.randomAlphanumeric(10); + + System.out.println(generatedString); + } + @Test public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() { final int length = 10; From cbd92a85b6aba162d83c35c39bdce851e5c60cee Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 5 Aug 2014 14:29:37 +0300 Subject: [PATCH 598/796] cleanup IO work --- .../org/baeldung/java/io/JavaReaderToXUnitTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index 7cb92762838a..ce69871d19e1 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -34,7 +34,7 @@ public class JavaReaderToXUnitTest { @Test public void givenUsingPlainJava_whenConvertingReaderIntoStringV1_thenCorrect() throws IOException { - final StringReader reader = new StringReader("With Java 1"); + final Reader reader = new StringReader("With Java 1"); int intValueOfChar; String targetString = ""; while ((intValueOfChar = reader.read()) != -1) { @@ -73,10 +73,9 @@ public void givenUsingCommonsIO_whenConvertingReaderIntoString_thenCorrect() thr // tests - Reader WRITE TO File @Test - public void givenUsingPlainJava_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + public void givenUsingPlainJava_whenWritingReaderContentsToFile_thenCorrect() throws IOException { final File sourceFile = new File("src/test/resources/sourceFile.txt"); sourceFile.createNewFile(); - final Reader initialReader = new FileReader(sourceFile); final char[] buffer = new char[(int) sourceFile.length()]; initialReader.read(buffer); @@ -91,8 +90,9 @@ public void givenUsingPlainJava_whenConvertingReaderIntoFile_thenCorrect() throw } @Test - public void givenUsingGuava_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + public void givenUsingGuava_whenWritingReaderContentsToFile_thenCorrect() throws IOException { final Reader initialReader = CharSource.wrap("IDDQD").openStream(); + final File targetFile = new File("src/test/resources/targetFile.txt"); com.google.common.io.Files.touch(targetFile); final CharSink charSink = com.google.common.io.Files.asCharSink(targetFile, Charset.defaultCharset(), FileWriteMode.APPEND); @@ -101,7 +101,7 @@ public void givenUsingGuava_whenConvertingReaderIntoFile_thenCorrect() throws IO } @Test - public void givenUsingCommonsIO_whenConvertingReaderIntoFile_thenCorrect() throws IOException { + public void givenUsingCommonsIO_whenWritingReaderContentsToFile_thenCorrect() throws IOException { final Reader initialReader = new CharSequenceReader("CharSequenceReader extends Reader"); final File targetFile = new File("src/test/resources/targetFile.txt"); FileUtils.touch(targetFile); From add603644aa24c1731fefbe79d669d42dc7a1e7c Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 5 Aug 2014 22:52:31 +0300 Subject: [PATCH 599/796] java io testing work --- core-java/src/main/resources/targetFile.tmp | 2 -- .../java/io/JavaReaderToXUnitTest.java | 18 ++++++++++-------- core-java/src/test/resources/targetFile.txt | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 core-java/src/main/resources/targetFile.tmp delete mode 100644 core-java/src/test/resources/targetFile.txt diff --git a/core-java/src/main/resources/targetFile.tmp b/core-java/src/main/resources/targetFile.tmp deleted file mode 100644 index 20f137b41622..000000000000 --- a/core-java/src/main/resources/targetFile.tmp +++ /dev/null @@ -1,2 +0,0 @@ -line 1 -a second line \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java index ce69871d19e1..13e800d4b78a 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java @@ -2,7 +2,6 @@ import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; @@ -74,24 +73,26 @@ public void givenUsingCommonsIO_whenConvertingReaderIntoString_thenCorrect() thr @Test public void givenUsingPlainJava_whenWritingReaderContentsToFile_thenCorrect() throws IOException { - final File sourceFile = new File("src/test/resources/sourceFile.txt"); - sourceFile.createNewFile(); - final Reader initialReader = new FileReader(sourceFile); - final char[] buffer = new char[(int) sourceFile.length()]; - initialReader.read(buffer); + final Reader initialReader = new StringReader("Some text"); + + int intValueOfChar; + final StringBuilder buffer = new StringBuilder(); + while ((intValueOfChar = initialReader.read()) != -1) { + buffer.append((char) intValueOfChar); + } initialReader.close(); final File targetFile = new File("src/test/resources/targetFile.txt"); targetFile.createNewFile(); final Writer targetFileWriter = new FileWriter(targetFile); - targetFileWriter.write(buffer); + targetFileWriter.write(buffer.toString()); targetFileWriter.close(); } @Test public void givenUsingGuava_whenWritingReaderContentsToFile_thenCorrect() throws IOException { - final Reader initialReader = CharSource.wrap("IDDQD").openStream(); + final Reader initialReader = new StringReader("Some text"); final File targetFile = new File("src/test/resources/targetFile.txt"); com.google.common.io.Files.touch(targetFile); @@ -103,6 +104,7 @@ public void givenUsingGuava_whenWritingReaderContentsToFile_thenCorrect() throws @Test public void givenUsingCommonsIO_whenWritingReaderContentsToFile_thenCorrect() throws IOException { final Reader initialReader = new CharSequenceReader("CharSequenceReader extends Reader"); + final File targetFile = new File("src/test/resources/targetFile.txt"); FileUtils.touch(targetFile); final byte[] buffer = IOUtils.toByteArray(initialReader); diff --git a/core-java/src/test/resources/targetFile.txt b/core-java/src/test/resources/targetFile.txt deleted file mode 100644 index f04ec3d9a9bc..000000000000 --- a/core-java/src/test/resources/targetFile.txt +++ /dev/null @@ -1 +0,0 @@ -CharSequenceReader extends Reader \ No newline at end of file From c1de3ea8a3e7852d0cc5b8306f3106774a5902cb Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 6 Aug 2014 20:48:05 +0300 Subject: [PATCH 600/796] making non-deployable projects jar type --- spring-hibernate3/.classpath | 1 - spring-hibernate3/pom.xml | 26 +++++-------------- spring-hibernate4/.classpath | 1 - spring-hibernate4/pom.xml | 16 +----------- .../src/main/webapp/WEB-INF/web.xml | 18 ------------- spring-jpa/.classpath | 1 - spring-jpa/.springBeans | 5 ++-- spring-jpa/pom.xml | 15 +---------- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 ----- .../src/main/webapp/WEB-INF/view/sample.jsp | 7 ----- spring-jpa/src/main/webapp/WEB-INF/web.xml | 21 --------------- 11 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 spring-hibernate4/src/main/webapp/WEB-INF/web.xml delete mode 100644 spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp delete mode 100644 spring-jpa/src/main/webapp/WEB-INF/web.xml diff --git a/spring-hibernate3/.classpath b/spring-hibernate3/.classpath index eed10d8a8b04..efc51b414b0b 100644 --- a/spring-hibernate3/.classpath +++ b/spring-hibernate3/.classpath @@ -30,7 +30,6 @@ - diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index e426ee48170d..fcb39ceee73e 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -6,7 +6,6 @@ 0.1-SNAPSHOT spring-hibernate3 - war @@ -14,22 +13,18 @@ org.springframework - spring-web + spring-context ${org.springframework.version} + + + org.springframework spring-orm ${org.springframework.version} - - org.springframework - spring-context - ${org.springframework.version} - - - - + org.hibernate hibernate-core @@ -46,13 +41,13 @@ ${mysql-connector-java.version} runtime - + org.apache.tomcat tomcat-dbcp ${tomcat-dbcp.version} - + @@ -127,12 +122,6 @@ - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - org.apache.maven.plugins maven-surefire-plugin @@ -206,7 +195,6 @@ 3.1 - 2.4 2.17 2.6 1.4.8 diff --git a/spring-hibernate4/.classpath b/spring-hibernate4/.classpath index ca257cf1f962..15b58ba46e03 100644 --- a/spring-hibernate4/.classpath +++ b/spring-hibernate4/.classpath @@ -30,7 +30,6 @@ - diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 847b0b5b7904..94632e2225c0 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -4,19 +4,13 @@ org.baeldung spring-hibernate4 0.1-SNAPSHOT - + spring-hibernate4 - war - - org.springframework - spring-web - ${org.springframework.version} - org.springframework spring-context @@ -135,12 +129,6 @@ - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - org.apache.maven.plugins maven-surefire-plugin @@ -212,10 +200,8 @@ 2.3.1 - 3.1 - 2.4 2.17 2.6 1.4.8 diff --git a/spring-hibernate4/src/main/webapp/WEB-INF/web.xml b/spring-hibernate4/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 64b5f6826d96..000000000000 --- a/spring-hibernate4/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - Spring Hibernate 4 Application - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - \ No newline at end of file diff --git a/spring-jpa/.classpath b/spring-jpa/.classpath index 6cb510b80c3f..1210cf3d114d 100644 --- a/spring-jpa/.classpath +++ b/spring-jpa/.classpath @@ -25,7 +25,6 @@ - diff --git a/spring-jpa/.springBeans b/spring-jpa/.springBeans index 7623a7e88836..fc808d21d4a6 100644 --- a/spring-jpa/.springBeans +++ b/spring-jpa/.springBeans @@ -1,14 +1,15 @@ 1 - + - src/main/webapp/WEB-INF/mvc-servlet.xml + + diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 6eb0155a58af..71887c0eee4d 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -6,18 +6,12 @@ spring-jpa 0.1-SNAPSHOT - war spring-jpa - - org.springframework - spring-web - ${org.springframework.version} - org.springframework spring-orm @@ -130,12 +124,6 @@ - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - org.apache.maven.plugins maven-surefire-plugin @@ -205,13 +193,12 @@ 2.3.1 - 3.1 - 2.4 2.17 2.6 1.4.8 +
diff --git a/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index a675fc6d954f..000000000000 --- a/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp b/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-jpa/src/main/webapp/WEB-INF/web.xml b/spring-jpa/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 881018134e2e..000000000000 --- a/spring-jpa/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - Spring JPA Application - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.config - - - org.springframework.web.context.ContextLoaderListener - - - From f7df607efa2d44928e76163311449d10db5fc241 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 8 Aug 2014 20:42:29 +0300 Subject: [PATCH 601/796] minor maven upgrades --- core-java/pom.xml | 18 +++++++++--------- experiments/pom.xml | 16 ++++++++-------- guava/pom.xml | 16 ++++++++-------- httpclient/pom.xml | 8 ++++---- jackson/pom.xml | 18 +++++++++--------- mockito/pom.xml | 16 ++++++++-------- rest-testing/pom.xml | 12 ++++++------ sandbox/pom.xml | 14 +++++++------- spring-all/pom.xml | 16 ++++++++-------- spring-exceptions/pom.xml | 16 ++++++++-------- spring-hibernate3/pom.xml | 14 +++++++------- spring-hibernate4/pom.xml | 16 ++++++++-------- spring-jpa/pom.xml | 16 ++++++++-------- spring-mvc-java/pom.xml | 16 ++++++++-------- spring-mvc-no-xml/pom.xml | 10 +++++----- spring-mvc-xml/pom.xml | 10 +++++----- spring-rest/pom.xml | 18 +++++++++--------- spring-security-basic-auth/pom.xml | 16 ++++++++-------- spring-security-mvc-custom/pom.xml | 16 ++++++++-------- spring-security-mvc-digest-auth/pom.xml | 16 ++++++++-------- spring-security-mvc-login/pom.xml | 16 ++++++++-------- .../pom.xml | 16 ++++++++-------- spring-security-mvc-session/pom.xml | 16 ++++++++-------- spring-security-rest-basic-auth/pom.xml | 16 ++++++++-------- spring-security-rest-custom/pom.xml | 16 ++++++++-------- spring-security-rest-digest-auth/pom.xml | 16 ++++++++-------- spring-security-rest-full/pom.xml | 16 ++++++++-------- spring-security-rest/pom.xml | 16 ++++++++-------- 28 files changed, 213 insertions(+), 213 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index b10570ad56e1..27daf5f0f861 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -145,22 +145,22 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 2.3.3 + 2.4.1 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -172,9 +172,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/experiments/pom.xml b/experiments/pom.xml index a65a9280492d..f814928f4acd 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,19 +255,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -279,9 +279,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/guava/pom.xml b/guava/pom.xml index 32831b15853b..18142c12f275 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,19 +94,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -118,9 +118,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index a4ec3efaa0a0..6aa5f96344dd 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -149,19 +149,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 1.7.7 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 diff --git a/jackson/pom.xml b/jackson/pom.xml index ba9504bed993..d017c7b65ca9 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -107,22 +107,22 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 2.3.3 + 2.4.1 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -134,9 +134,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/mockito/pom.xml b/mockito/pom.xml index e33de774dd48..8829e2e2d1fe 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,19 +89,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -113,9 +113,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 73e71c2912eb..d55d16302a5c 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -141,14 +141,14 @@ 4.0.3.RELEASE - 2.3.3 + 2.4.1 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 16.0.1 @@ -160,9 +160,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 3df2cdf7227f..4f7fb39e2ffa 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -137,18 +137,18 @@ 3.2.4.RELEASE - 4.3.5.Final + 4.3.6.Final 5.1.29 - 2.3.3 + 2.4.1 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 16.0.1 @@ -160,9 +160,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 5f2a6904e850..9932b6827844 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,21 +192,21 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE 3.18.1-GA 1.2 - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -218,9 +218,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index f2e0ac85e98c..002546934085 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,22 +204,22 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE 3.18.1-GA 1.2 - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 7.0.42 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -231,9 +231,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 1.8.9 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index fcb39ceee73e..cdcc2277f9de 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -163,21 +163,21 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE 3.18.1-GA 3.6.10.Final - 5.1.30 + 5.1.31 7.0.47 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -189,9 +189,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 94632e2225c0..c16fff764a4b 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -170,21 +170,21 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE 3.18.1-GA - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 7.0.42 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -196,9 +196,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 71887c0eee4d..ddffa5101e16 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -165,19 +165,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -189,9 +189,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index f6e7b55d48df..7e966a699e47 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,19 +141,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -165,9 +165,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 20e9da919648..f2ab27e2515f 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,11 +145,11 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 1.3 @@ -157,9 +157,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 581de439c600..12d38710af45 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -147,11 +147,11 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 1.3 @@ -159,9 +159,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 1d67e3d77082..a5044a675b06 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,19 +202,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 2.3.3 + 2.4.1 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -226,13 +226,13 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 3.1 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 08d4fd1cd53e..fea2ae9ce5f6 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -226,19 +226,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -250,9 +250,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 664ee2fb2e2f..0dd81b1edc50 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -231,19 +231,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -254,10 +254,10 @@ 4.11 1.9.5 - 4.3.3 + 4.3.5 4.3.2 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 7afd2170df0d..8dc1748fb490 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -226,19 +226,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -250,9 +250,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 2f919da09036..65f14c04322c 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -223,19 +223,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -247,9 +247,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml index b131e3805abb..8e0491d78b9a 100644 --- a/spring-security-mvc-persisted-remember-me/pom.xml +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -260,19 +260,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -283,10 +283,10 @@ 4.11 1.9.5 - 4.3.3 + 4.3.5 4.3.2 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index d30b010f3393..9285a243c403 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -231,19 +231,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -254,10 +254,10 @@ 4.11 1.9.5 - 4.3.3 + 4.3.5 4.3.2 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 07146eb02b85..b44169f368d2 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,23 +287,23 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 4.3.2 - 4.3.3 + 4.3.5 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -314,7 +314,7 @@ 4.11 1.9.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index c1ff09482681..2189396535f8 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -251,19 +251,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -275,9 +275,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 9c0728a9f6de..c9c6617645c8 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,23 +275,23 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 4.3.2 - 4.3.3 + 4.3.5 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -302,7 +302,7 @@ 4.11 1.9.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 173f3bed6ff4..1ffe7244a62d 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -375,20 +375,20 @@ 3.2.4.RELEASE - 4.3.5.Final + 4.3.6.Final 5.1.31 - 1.6.1.RELEASE + 1.6.2.RELEASE - 2.3.3 + 2.4.1 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -400,9 +400,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 27e629e363e4..c23901bda6dc 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -238,19 +238,19 @@ - 4.0.5.RELEASE + 4.0.6.RELEASE 3.2.4.RELEASE - 4.3.5.Final - 5.1.30 + 4.3.6.Final + 5.1.31 - 1.7.6 - 1.1.1 + 1.7.7 + 1.1.2 - 5.1.1.Final + 5.1.2.Final 17.0 @@ -262,9 +262,9 @@ 1.9.5 4.3.2 - 4.3.3 + 4.3.5 - 2.3.1 + 2.3.2 3.1 From a737303bfc62d9da4de367d30c3640f5bbf4cba9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Aug 2014 00:58:51 +0300 Subject: [PATCH 602/796] cleanup work --- .../bin/.springBeans | 15 -- .../bin/pom.xml | 212 ------------------ .../bin/src/main/resources/logback.xml | 20 -- .../src/main/resources/messages_en.properties | 9 - .../main/resources/messages_es_ES.properties | 9 - .../src/main/resources/webSecurityConfig.xml | 36 --- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 10 - .../src/main/webapp/WEB-INF/view/admin.jsp | 23 -- .../src/main/webapp/WEB-INF/view/console.jsp | 23 -- .../bin/src/main/webapp/WEB-INF/view/home.jsp | 13 -- .../src/main/webapp/WEB-INF/view/homepage.jsp | 28 --- .../webapp/WEB-INF/view/invalidSession.jsp | 12 - .../src/main/webapp/WEB-INF/view/login.jsp | 77 ------- .../src/main/webapp/WEB-INF/view/logout.jsp | 24 -- .../main/webapp/WEB-INF/view/registration.jsp | 12 - .../bin/src/main/webapp/WEB-INF/web.xml | 41 ---- 16 files changed, 564 deletions(-) delete mode 100644 spring-security-login-error-handling/bin/.springBeans delete mode 100644 spring-security-login-error-handling/bin/pom.xml delete mode 100644 spring-security-login-error-handling/bin/src/main/resources/logback.xml delete mode 100644 spring-security-login-error-handling/bin/src/main/resources/messages_en.properties delete mode 100644 spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties delete mode 100644 spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp delete mode 100644 spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-login-error-handling/bin/.springBeans b/spring-security-login-error-handling/bin/.springBeans deleted file mode 100644 index 8096aa036b39..000000000000 --- a/spring-security-login-error-handling/bin/.springBeans +++ /dev/null @@ -1,15 +0,0 @@ - - - 1 - - - - - - - - - - - - diff --git a/spring-security-login-error-handling/bin/pom.xml b/spring-security-login-error-handling/bin/pom.xml deleted file mode 100644 index d26e2d0d4437..000000000000 --- a/spring-security-login-error-handling/bin/pom.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - 4.0.0 - org.baeldung - spring-security-login-error-handling - spring-security-login-error-handling - war - 1.0.0-BUILD-SNAPSHOT - - - org.springframework.boot - spring-boot-starter-parent - 1.1.4.RELEASE - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context - - - - commons-logging - commons-logging - - - - - org.springframework - spring-core - - - org.springframework - spring-webmvc - - - org.springframework - spring-jdbc - - - org.springframework - spring-beans - - - org.springframework - spring-aop - - - org.springframework - spring-tx - - - org.springframework - spring-expression - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.springframework.security - spring-security-config - runtime - - - - - org.aspectj - aspectjrt - - - - - org.hibernate - hibernate-validator - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - org.slf4j - jcl-over-slf4j - - - - org.slf4j - log4j-over-slf4j - - - - - javax.inject - javax.inject - 1 - - - - - javax.servlet - servlet-api - 2.5 - provided - - - javax.servlet.jsp - jsp-api - 2.1 - provided - - - javax.servlet - jstl - - - - - org.springframework.security - spring-security-taglibs - - - - - junit - junit - test - - - - - - SpringSecurityLogin - - - src/main/resources - true - - - - - - maven-eclipse-plugin - - - org.springframework.ide.eclipse.core.springnature - - - org.springframework.ide.eclipse.core.springbuilder - - true - true - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - -Xlint:all - true - true - - - - - org.apache.maven.plugins - maven-war-plugin - - - - org.codehaus.mojo - exec-maven-plugin - - org.test.int1.Main - - - - - - - 1.7 - 3.1.1.RELEASE - 3.2.4.RELEASE - 1.6.10 - - - 1.7.6 - 1.1.1 - - - - diff --git a/spring-security-login-error-handling/bin/src/main/resources/logback.xml b/spring-security-login-error-handling/bin/src/main/resources/logback.xml deleted file mode 100644 index 1146dade632e..000000000000 --- a/spring-security-login-error-handling/bin/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties b/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties deleted file mode 100644 index 3e05a6b76a3b..000000000000 --- a/spring-security-login-error-handling/bin/src/main/resources/messages_en.properties +++ /dev/null @@ -1,9 +0,0 @@ -message.username=Username required -message.password=Password required -message.unauth=Unauthorized Access !! -message.badCredentials=Invalid Username or Password -message.sessionExpired=Session Timed Out -message.logoutError=Sorry, error logging out -message.logoutSucc=You logged out successfully -message.regSucc=You registrated correctly, please log in -message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties deleted file mode 100644 index 842a899e4316..000000000000 --- a/spring-security-login-error-handling/bin/src/main/resources/messages_es_ES.properties +++ /dev/null @@ -1,9 +0,0 @@ -message.username=Por favor ingrese el nombre de usuario -message.password=Por favor ingrese una clave -message.unauth=Acceso denegado !! -message.badCredentials=Usuario o clave invalida -message.sessionExpired=La sesion expiro -message.logoutError=Lo sentimos, hubo problemas en logout -message.logoutSucc=Logout con exito -message.regSucc=Se registro correctamente, por favor ingrese -message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 46550f03da76..000000000000 --- a/spring-security-login-error-handling/bin/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index b885d2c10aef..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp deleted file mode 100644 index 12f9f7aba986..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/admin.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - -

Hello Admin

-
- - ">Logout - ">Home - - - - diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp deleted file mode 100644 index 05a930731be4..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/console.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - -

This is the landing page for the admin

- - - This text is only visible to a user -
-
- - - This text is only visible to an admin -
-
- - ">Logout - ">Administrator Page - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp deleted file mode 100644 index fe6e572b99f9..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/home.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ page session="true" %> - - - Home - - -

- Welcome back home! -

- - - diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index fab96383df5d..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,28 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> -<%@ page session="true" %> - - - - - -

This is the homepage for the user

- - - This text is only visible to a user -
-
- - - This text is only visible to an admin -
-
- - ">Logout - ">Home - ">Administrator Page - - - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp deleted file mode 100644 index 175c49811730..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - Home - - -

- -

- - - diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 95559b045511..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,77 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="false"%> - -
- -
-
- -
- -
-
- - -
- -
- Register -
- - - - - - - - - -

Login

- English | - Spanish -
- - - - - - - - - - - - - -
User:
Password:
- -
-
Current Locale : ${pageContext.response.locale} - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp deleted file mode 100644 index e8618b74e3aa..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/logout.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - -
- -
-
- -
- -
-
- - - -Logged Out - - - - Login - - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp deleted file mode 100644 index 474a1817b52a..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/view/registration.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=US-ASCII" - pageEncoding="US-ASCII"%> - - - - -Registration - - -

This is the registration page

- - \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml b/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 463b3093771c..000000000000 --- a/spring-security-login-error-handling/bin/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - localizationFilter - org.springframework.web.filter.RequestContextFilter - - - localizationFilter - /* - - \ No newline at end of file From 3f3869d9759ae5b019a6b4249a2a4a28b9016935 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Aug 2014 01:00:34 +0300 Subject: [PATCH 603/796] eclipse files --- .gitignore | 2 - .../.classpath | 32 +++++++++++++ spring-security-login-error-handling/.project | 48 +++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 spring-security-login-error-handling/.classpath create mode 100644 spring-security-login-error-handling/.project diff --git a/.gitignore b/.gitignore index 72f3338a99c1..b5a4ddb863e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,6 @@ # Eclipse -.classpath -.project .settings/ .prefs *.prefs diff --git a/spring-security-login-error-handling/.classpath b/spring-security-login-error-handling/.classpath new file mode 100644 index 000000000000..0f4a4c27e0ce --- /dev/null +++ b/spring-security-login-error-handling/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-login-error-handling/.project b/spring-security-login-error-handling/.project new file mode 100644 index 000000000000..41c4e13e7cea --- /dev/null +++ b/spring-security-login-error-handling/.project @@ -0,0 +1,48 @@ + + + spring-security-login-and-registration + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + From 03710d4cdede57089264afc810227ce7e5493045 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Aug 2014 01:21:28 +0300 Subject: [PATCH 604/796] minor cleanup work --- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 11 +-- .../src/main/webapp/WEB-INF/web.xml | 82 ++++++++++--------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml index b885d2c10aef..94bd63e068a3 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,10 +1,7 @@ - - - - + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml index 463b3093771c..26ac5be1e0e8 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml @@ -1,41 +1,49 @@ - - - contextClass - + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - localizationFilter - org.springframework.web.filter.RequestContextFilter - - - localizationFilter - /* - + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + \ No newline at end of file From 45b865c93f164c4a312e2a9a498042dd71c8d766 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sun, 10 Aug 2014 18:45:31 -0500 Subject: [PATCH 605/796] Spring Security Login and Registration First Draft --- bin/src/main/webapp/WEB-INF/view/login.jsp | 2 + .../main/webapp/WEB-INF/view/registration.jsp | 19 ++- .../bin/.gitignore | 1 + spring-security-login-error-handling/pom.xml | 63 +++++++-- .../persistence/dao/UserRepository.java | 9 ++ .../org/baeldung/persistence/model/Role.java | 62 +++++++++ .../org/baeldung/persistence/model/User.java | 110 +++++++++++++++ .../service/EmailExistsException.java | 8 ++ .../RegistrationFormWithValidation.java | 75 +++++++++++ .../service/RepositoryService.java | 54 ++++++++ .../baeldung/persistence/service/UserDto.java | 57 ++++++++ .../persistence/service/UserService.java | 7 + .../persistence/service/UserValidator.java | 22 +++ .../security/MyUserDetailsService.java | 81 +++++++++++ .../java/org/baeldung/spring/AppConfig.java | 45 +++++++ .../java/org/baeldung/spring/MvcConfig.java | 17 ++- .../baeldung/spring/PersistenceJPAConfig.java | 81 +++++++++++ .../controller/RegistrationController.java | 127 ++++++++++++++++++ .../src/main/resources/application.properties | 17 +++ .../src/main/resources/messages_en.properties | 11 +- .../main/resources/messages_es_ES.properties | 11 +- .../src/main/resources/webSecurityConfig.xml | 24 +++- .../src/main/webapp/WEB-INF/view/admin.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 4 +- .../main/webapp/WEB-INF/view/registration.jsp | 12 -- .../webapp/WEB-INF/view/successRegister.jsp | 19 +++ spring-security-rest-full/.project | 6 + 27 files changed, 909 insertions(+), 37 deletions(-) create mode 100644 spring-security-login-error-handling/bin/.gitignore create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java create mode 100644 spring-security-login-error-handling/src/main/resources/application.properties delete mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp diff --git a/bin/src/main/webapp/WEB-INF/view/login.jsp b/bin/src/main/webapp/WEB-INF/view/login.jsp index 95559b045511..815c6ca891d5 100644 --- a/bin/src/main/webapp/WEB-INF/view/login.jsp +++ b/bin/src/main/webapp/WEB-INF/view/login.jsp @@ -73,5 +73,7 @@
Current Locale : ${pageContext.response.locale} + + ">Home \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/registration.jsp b/bin/src/main/webapp/WEB-INF/view/registration.jsp index 474a1817b52a..dc85ce8afa5a 100644 --- a/bin/src/main/webapp/WEB-INF/view/registration.jsp +++ b/bin/src/main/webapp/WEB-INF/view/registration.jsp @@ -1,6 +1,9 @@ -<%@ page language="java" contentType="text/html; charset=US-ASCII" - pageEncoding="US-ASCII"%> - + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> @@ -8,5 +11,15 @@

This is the registration page

+ + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/bin/.gitignore b/spring-security-login-error-handling/bin/.gitignore new file mode 100644 index 000000000000..a57582cc39fe --- /dev/null +++ b/spring-security-login-error-handling/bin/.gitignore @@ -0,0 +1 @@ +/src diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index 5dad868501e8..ea519a712b28 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -25,9 +25,13 @@ spring-security-config runtime
- + + org.springframework + spring-context-support + + - + org.slf4j @@ -66,9 +70,9 @@ javax.servlet.jsp javax.servlet.jsp-api - ${javax.servlet.jsp-api.version} + ${javax.servlet.jsp-api.version} - + javax.servlet jstl @@ -86,7 +90,42 @@ junit test + + + + org.springframework.data + spring-data-jpa + + + org.hibernate + hibernate-entitymanager + + + + + mysql + mysql-connector-java + + + commons-dbcp + commons-dbcp + + + com.fasterxml.jackson.core + jackson-databind + + + javax.mail + mail + 1.4.3 + + + com.google.guava + guava + ${guava.version} +
+ spring-security-login-and-registration @@ -105,12 +144,18 @@ 1.7.6 1.1.1 - + - 2.3.2-b01 - - - 1 + 2.3.2-b01 + + + 1 + + + 1.4.1.RELEASE + + + 17.0 diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java new file mode 100644 index 000000000000..d36cd1ba2fa7 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java @@ -0,0 +1,9 @@ +package org.baeldung.persistence.dao; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.baeldung.persistence.model.User; + + +public interface UserRepository extends JpaRepository{ + public User findByUsername(String username); +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java new file mode 100644 index 000000000000..f0a08885f518 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java @@ -0,0 +1,62 @@ +package org.baeldung.persistence.model; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; + + +@Entity(name="role") +@Table(name = "role") +public class Role { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + + @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @JoinColumn(name = "user_id") + private User user; + + @Column(name="role") + private Integer role; + + public Role(){ + super(); + + } + public Role(Integer role){ + super(); + this.role = role; + } + public Role(Integer role, User user){ + super(); + this.role = role; + this.user = user; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public User getUser() { + return user; + } + public void setUser(User user) { + this.user = user; + } + public Integer getRole() { + return role; + } + public void setRole(Integer role) { + this.role = role; + } +} \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java new file mode 100644 index 000000000000..4fe8c9986f99 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java @@ -0,0 +1,110 @@ +package org.baeldung.persistence.model; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +@Entity(name = "user") +@Table(name = "user") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + @Column(name="firstName") + private String firstName; + @Column(name="lastName") + private String lastName; + @Column(name="username") + private String username; + @Column(name="password") + private String password; + + + @OneToOne(mappedBy = "user",fetch = FetchType.EAGER, cascade = CascadeType.ALL) + private Role role; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final User user = (User) obj; + if (!username.equals(user.username)) + return false; + return true; + } + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("User [firstName=").append(firstName).append("]"). + append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + return builder.toString(); + } +} \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java new file mode 100644 index 000000000000..848eab02c2e6 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +public class EmailExistsException extends Throwable{ + + public EmailExistsException(String message) { + super(message); + } +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java new file mode 100644 index 000000000000..6735ca7ab3f6 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java @@ -0,0 +1,75 @@ +package org.baeldung.persistence.service; + +import javax.validation.constraints.Size; + +import org.hibernate.validator.constraints.Email; +import org.hibernate.validator.constraints.NotEmpty; + +public class RegistrationFormWithValidation { + + + + @Email + @NotEmpty + @Size(max = 100) + private String email; + + @NotEmpty + @Size(max = 100) + private String firstName; + + @NotEmpty + @Size(max = 100) + private String lastName; + + private String password; + + private String passwordVerification; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPasswordVerification() { + return passwordVerification; + } + + public void setPasswordVerification(String passwordVerification) { + this.passwordVerification = passwordVerification; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[email").append(email).append("]"); + return builder.toString(); + } +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java new file mode 100644 index 000000000000..c5f480e93cfa --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java @@ -0,0 +1,54 @@ +package org.baeldung.persistence.service; + +import javax.transaction.Transactional; + +import org.baeldung.persistence.dao.UserRepository; +import org.baeldung.persistence.model.Role; +import org.baeldung.persistence.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.data.repository.RepositoryDefinition; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +@Service +public class RepositoryService implements UserService { + @Autowired + private UserRepository repository; + private PasswordEncoder passwordEncoder; + + @Autowired + private Environment env; + + @Autowired + public RepositoryService(PasswordEncoder passwordEncoder, UserRepository repository) { + this.passwordEncoder = passwordEncoder; + this.repository = repository; + } + + @Transactional + @Override + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { + if (emailExist(userAccountData.getUsername())) { + + throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getUsername()); + } + + User user = new User(); + user.setFirstName(userAccountData.getFirstName()); + user.setLastName(userAccountData.getLastName()); + user.setPassword(userAccountData.getPassword()); + user.setUsername(userAccountData.getUsername()); + user.setRole(new Role(userAccountData.getRole(), user)); + return repository.save(user); + } + + private boolean emailExist(String email) { + User user = repository.findByUsername(email); + if (user != null) { + return true; + } + return false; + } +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java new file mode 100644 index 000000000000..0cf36dd5c1fa --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -0,0 +1,57 @@ +package org.baeldung.persistence.service; +//Renamed original RegistrationForm + +public class UserDto { + + private String firstName; + private String lastName; + private String password; + private String username; + private Integer role; + private String lastError; + + public String getLastError() { + return lastError; + } + + public void setLastError(String lastError) { + this.lastError = lastError; + } + public Integer getRole() { + return role; + } + public void setRole(Integer role) { + this.role = role; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("User [firstName=").append(firstName).append("]"). + append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + return builder.toString(); + } +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java new file mode 100644 index 000000000000..65c7516494c8 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -0,0 +1,7 @@ +package org.baeldung.persistence.service; +import org.baeldung.persistence.model.User; + +public interface UserService { + + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java new file mode 100644 index 000000000000..f93ba5825e0b --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java @@ -0,0 +1,22 @@ +package org.baeldung.persistence.service; + +import org.springframework.validation.Errors; +import org.springframework.validation.ValidationUtils; +import org.springframework.validation.Validator; + +public class UserValidator implements Validator { + + @Override + public boolean supports(Class clazz) { + return UserDto.class.isAssignableFrom(clazz); + } + + @Override + public void validate(Object obj, Errors errors) { + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "message.firstName", "Firstname is required."); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "message.lastName", "LastName is required."); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "message.password", "LastName is required."); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required."); + } + +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java new file mode 100644 index 000000000000..41c27e2a9c3b --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -0,0 +1,81 @@ +package org.baeldung.security; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.baeldung.persistence.dao.UserRepository; +import org.baeldung.persistence.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class MyUserDetailsService implements UserDetailsService { + + private static final Logger LOGGER = LoggerFactory.getLogger(UserDetailsService.class); + + private UserRepository userRepository; + + @Autowired + public MyUserDetailsService(UserRepository repository) { + this.userRepository = repository; + } + + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + try { + LOGGER.debug("Loading user by username: {}", username); + User user = userRepository.findByUsername(username); + LOGGER.debug("Found user: {}", user); + if (user == null) { + //throw new UsernameNotFoundException("No user found with username: " + username); + boolean enabled = false; + return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); + } + boolean enabled = true; + boolean accountNonExpired = true; + boolean credentialsNonExpired = true; + boolean accountNonLocked = true; + return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public Collection getAuthorities(Integer role) { + List authList = getGrantedAuthorities(getRoles(role)); + return authList; + } + + public List getRoles(Integer role) { + List roles = new ArrayList(); + + if (role.intValue() == 2) { + // roles.add("ROLE_USER"); + roles.add("ROLE_ADMIN"); + + } else if (role.intValue() == 1) { + roles.add("ROLE_USER"); + } + + return roles; + } + + public static List getGrantedAuthorities(List roles) { + List authorities = new ArrayList(); + for (String role : roles) { + authorities.add(new SimpleGrantedAuthority(role)); + } + return authorities; + } + +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java new file mode 100644 index 000000000000..861e68b9ede0 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java @@ -0,0 +1,45 @@ +package org.baeldung.spring; + +import java.util.Properties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.env.Environment; +import org.springframework.mail.javamail.JavaMailSenderImpl; + +@Configuration +@ComponentScan(basePackages = { "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) +@Import({ MvcConfig.class, PersistenceJPAConfig.class, SecSecurityConfig.class }) +@PropertySource("classpath:application.properties") +public class AppConfig { + @Autowired + private Environment env; + + @Bean + public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Bean + public JavaMailSenderImpl javaMailSenderImpl() { + JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl(); + mailSenderImpl.setHost(env.getProperty("smtp.host")); + mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class)); + mailSenderImpl.setProtocol(env.getProperty("smtp.protocol")); + mailSenderImpl.setUsername(env.getProperty("smtp.username")); + mailSenderImpl.setPassword(env.getProperty("smtp.password")); + + Properties javaMailProps = new Properties(); + javaMailProps.put("mail.smtp.auth", true); + javaMailProps.put("mail.smtp.starttls.enable", true); + + mailSenderImpl.setJavaMailProperties(javaMailProps); + + return mailSenderImpl; + } + +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index 2d83d6a5d98a..a51e253430c9 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -2,8 +2,10 @@ import java.util.Locale; +import org.baeldung.persistence.service.UserValidator; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.web.servlet.LocaleResolver; @@ -17,7 +19,11 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; + @Configuration +@ComponentScan(basePackages = { + "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" +}) @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @@ -39,8 +45,10 @@ public void addViewControllers(final ViewControllerRegistry registry) { registry.addViewController("/console.html"); registry.addViewController("/admin.html"); registry.addViewController("/registration.html"); + registry.addViewController("/successRegister.html"); + } - + @Bean public ViewResolver viewResolver() { final InternalResourceViewResolver bean = new InternalResourceViewResolver(); @@ -74,5 +82,10 @@ public MessageSource messageSource() { messageSource.setCacheSeconds(0); return messageSource; } - + @Bean + public UserValidator userValidator() { + UserValidator userValidator = new UserValidator(); + return userValidator; + } + } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java new file mode 100644 index 000000000000..172ebbb77d32 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -0,0 +1,81 @@ +package org.baeldung.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +//import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:application.properties" }) +@ComponentScan({ "org.baeldung.persistence.model" }) +@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") +public class PersistenceJPAConfig { + @Autowired + private Environment env; + + public PersistenceJPAConfig() { + super(); + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + // vendorAdapter.set + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + + return em; + } + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); + dataSource.setUrl(env.getProperty("jdbc.url")); + dataSource.setUsername(env.getProperty("jdbc.user")); + dataSource.setPassword(env.getProperty("jdbc.pass")); + + return dataSource; + } + + @Bean + public JpaTransactionManager transactionManager() { + JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties additionalProperties() { + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; + } + +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java new file mode 100644 index 000000000000..12537965253b --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -0,0 +1,127 @@ +package org.baeldung.web.controller; + +import java.util.Locale; + +import org.baeldung.persistence.model.User; +import org.baeldung.persistence.service.EmailExistsException; +import org.baeldung.persistence.service.UserDto; +import org.baeldung.persistence.service.UserService; +import org.baeldung.persistence.service.UserValidator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.MessageSource; +import org.springframework.core.env.Environment; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.validation.Errors; +import org.springframework.validation.ObjectError; +import org.springframework.validation.Validator; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.SessionAttributes; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.ModelAndView; + + +@Controller +@SessionAttributes("user") +public class RegistrationController { + + private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationController.class); + private UserService service; + @Autowired + private MessageSource messages; + @Autowired + private JavaMailSender mailSender; + @Autowired + private UserValidator validator; + + @InitBinder + protected void initBinder(WebDataBinder binder) { + binder.setValidator(this.validator); + } + @Autowired + public RegistrationController(UserService service) { + this.service = service; + } + + @RequestMapping(value = "/user/registration", method = RequestMethod.GET) + public String showRegistrationForm(WebRequest request, Model model) { + LOGGER.debug("Rendering registration page."); + UserDto userDto = new UserDto(); + model.addAttribute("user", userDto); + return "registration"; + } + /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST) + public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData, + BindingResult result, + WebRequest request, Errors errors) { + LOGGER.debug("Registering user account with information: {}", userAccountData); + if (result.hasErrors()) { + LOGGER.debug("Validation errors found. Rendering form view."); + return "registration"; + } + LOGGER.debug("No validation errors found. Continuing registration process."); + User registered = createUserAccount(userAccountData, result); + if (registered == null) { + errors.rejectValue("lastError", "message.regError"); + return "registration"; + } + LOGGER.debug("Registered user account with information: {}", registered); + + sendConfirmMail(userAccountData.getUsername(), request.getLocale()); + return "successRegister"; + //return "redirect:/"; + }*/ + @RequestMapping(value ="/user/registration", method = RequestMethod.POST) + public ModelAndView registerUserAccount( @ModelAttribute("user") UserDto userAccountData, + BindingResult result, + WebRequest request, Errors errors) { + LOGGER.debug("Registering user account with information: {}", userAccountData); + validator.validate(userAccountData, result); + User registered = createUserAccount(userAccountData, result); + if (registered == null) { + result.rejectValue("lastError", "message.regError"); + } + if (result.hasErrors()) { + // show errors + return new ModelAndView("registration", "user", userAccountData); + } else { + + // success + return new ModelAndView("successRegister", "user", userAccountData); + } + + } + + private User createUserAccount(UserDto userAccountData, BindingResult result) { + LOGGER.debug("Creating user account with information: {}", userAccountData); + User registered = null; + try { + registered = service.registerNewUserAccount(userAccountData); + } catch (EmailExistsException e) { + // TODO Auto-generated catch block + return null; + } + return registered; + } + + private void sendConfirmMail(String address, Locale locale){ + String recipientAddress = address; + String subject = "Registration Confirmation"; + String message = messages.getMessage("message.regSucc", null, locale); + SimpleMailMessage email = new SimpleMailMessage(); + email.setTo(recipientAddress); + email.setSubject(subject); + email.setText(message); + mailSender.send(email); + } +} diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties new file mode 100644 index 000000000000..7ddffa4e1f6b --- /dev/null +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -0,0 +1,17 @@ +################### DataSource Configuration ########################## +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA +jdbc.user=root +###jdbc.pass=admin### +init-db=false +################### Hibernate Configuration ########################## +hibernate.dialect=org.hibernate.dialect.MySQLDialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=validate +################### JavaMail Configuration ########################## +smtp.host=smtp.gmail.com +smtp.port=465 +smtp.protocol=smtps +smtp.username=egmp777@gmail.com +smtp.password=k117srvf +support.email=egmp777@gmail.com \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-error-handling/src/main/resources/messages_en.properties index 3e05a6b76a3b..66a58dfeabf5 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_en.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_en.properties @@ -5,5 +5,12 @@ message.badCredentials=Invalid Username or Password message.sessionExpired=Session Timed Out message.logoutError=Sorry, error logging out message.logoutSucc=You logged out successfully -message.regSucc=You registrated correctly, please log in -message.regError=There was a registration error please go back to registration \ No newline at end of file +message.regSucc=You registered successfully. We will send you a confirmation message to your email account. +message.regError=An account for that username/email already exists. Please enter a different username. +message.lastName=Last name is required +message.firstName=First name is required +label.user.email=Email +label.user.firstName=First name +label.user.lastName=Last name +label.user.password=Password +label.login=Login here \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties index 842a899e4316..0becc40dd413 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties @@ -5,5 +5,12 @@ message.badCredentials=Usuario o clave invalida message.sessionExpired=La sesion expiro message.logoutError=Lo sentimos, hubo problemas en logout message.logoutSucc=Logout con exito -message.regSucc=Se registro correctamente, por favor ingrese -message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file +message.regSucc=Se registro correctamente. Le enviaremos un mensaje de confirmacion a su direccion de email. +message.regError=Ya existe una cuenta con ese nombre de usuario. Ingrese un nombre de usuario diferente. +message.lastName=El campo Last Name es obligatorio +message.firstName=El campo First Name es obligatorio +label.user.email=Email +label.user.firstName=Nombre +label.user.lastName=Apellido +label.user.password=Clave +label.login=Loguee aqui \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index 46550f03da76..ef5ba495dad8 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -10,9 +10,13 @@ + + + + + + - - - - - + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp index 12f9f7aba986..5aefc9ab5590 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp @@ -2,7 +2,7 @@ <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp index 95559b045511..97bc749acc23 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -4,7 +4,7 @@ <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> -<%@ page session="false"%> +<%@ page session="true"%>
@@ -73,5 +73,7 @@
Current Locale : ${pageContext.response.locale} + ">Sign Up + \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp deleted file mode 100644 index 474a1817b52a..000000000000 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=US-ASCII" - pageEncoding="US-ASCII"%> - - - - -Registration - - -

This is the registration page

- - \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp new file mode 100644 index 000000000000..f824ceba9222 --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp @@ -0,0 +1,19 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="true"%> + + + + +Registration Success + + + + + "> + + \ No newline at end of file diff --git a/spring-security-rest-full/.project b/spring-security-rest-full/.project index 89da95b5283f..6df4d1d27bce 100644 --- a/spring-security-rest-full/.project +++ b/spring-security-rest-full/.project @@ -30,6 +30,11 @@ + + org.hibernate.eclipse.console.hibernateBuilder + + + org.springframework.ide.eclipse.core.springnature @@ -38,5 +43,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature + org.hibernate.eclipse.console.hibernateNature From 941bb06472eee2a78a72908c1c4d9203f6e0aaa4 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sun, 10 Aug 2014 19:04:57 -0500 Subject: [PATCH 606/796] Spring Security Login and Registration Code without clean-up --- .../main/webapp/WEB-INF/view/registration.jsp | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp new file mode 100644 index 000000000000..0e0f33a9cd0f --- /dev/null +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp @@ -0,0 +1,56 @@ + +<%@ page contentType="text/html;charset=UTF-8" language="java"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ page session="false"%> + +
+ +
+
+ + +
+ + "> +
+ + +
+ + + +Registration + + +

This is the registration page

+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + \ No newline at end of file From 983c339e75f93924436eccaaf110bd96c11228cb Mon Sep 17 00:00:00 2001 From: egmp777 Date: Sun, 10 Aug 2014 19:25:25 -0500 Subject: [PATCH 607/796] Spring Security Login and Registration Added Properties --- .../bin/.project | 53 +++++++++++++++++++ .../src/main/resources/application.properties | 6 +-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 spring-security-login-error-handling/bin/.project diff --git a/spring-security-login-error-handling/bin/.project b/spring-security-login-error-handling/bin/.project new file mode 100644 index 000000000000..41a69a9af5d6 --- /dev/null +++ b/spring-security-login-error-handling/bin/.project @@ -0,0 +1,53 @@ + + + spring-security-login-and-registration + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.hibernate.eclipse.console.hibernateBuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.jsdt.core.jsNature + org.hibernate.eclipse.console.hibernateNature + + diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index 7ddffa4e1f6b..a051636c6bd1 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -12,6 +12,6 @@ hibernate.hbm2ddl.auto=validate smtp.host=smtp.gmail.com smtp.port=465 smtp.protocol=smtps -smtp.username=egmp777@gmail.com -smtp.password=k117srvf -support.email=egmp777@gmail.com \ No newline at end of file +smtp.username=edson@gmail.com +smtp.password= +support.email=edson@gmail.com \ No newline at end of file From 8118f458bc90c7f87afea15bb27395d981d575a5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 11 Aug 2014 23:17:24 +0300 Subject: [PATCH 608/796] forms work and cleanup --- spring-mvc-xml/pom.xml | 2 +- .../baeldung/spring/controller/EmployeeController.java | 3 ++- .../main/java/org/baeldung/spring/form/Employee.java | 10 +++++++++- .../src/main/webapp/WEB-INF/view/employeeHome.jsp | 2 +- .../view/{employeeAdded.jsp => employeeView.jsp} | 0 5 files changed, 13 insertions(+), 4 deletions(-) rename spring-mvc-xml/src/main/webapp/WEB-INF/view/{employeeAdded.jsp => employeeView.jsp} (100%) diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 12d38710af45..c957869c12f7 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -28,7 +28,7 @@ javax.servlet javax.servlet-api - 3.0.1 + 3.1.0 provided diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java index 007788a843ab..1dbe230adcbc 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java @@ -24,10 +24,11 @@ public String submit(@Valid @ModelAttribute("employee") final Employee employee, if (result.hasErrors()) { return "error"; } + model.addAttribute("name", employee.getName()); model.addAttribute("contactNumber", employee.getContactNumber()); model.addAttribute("id", employee.getId()); - return "employeeAdded"; + return "employeeView"; } } diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java index 5de3d3c89923..70132b966509 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java @@ -1,9 +1,17 @@ package org.baeldung.spring.form; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + public class Employee { - private String name; private long id; + + @NotNull + @Size(min = 1) + private String name; + @NotNull + @Size(min = 1) private String contactNumber; public Employee() { diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp index 97b81b76932f..e0ae61dd7bcf 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp @@ -3,7 +3,7 @@ -SpringMVCExample +Form Example - Register an Employee

Welcome, Enter The Employee Details

diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeView.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp rename to spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeView.jsp From af81fa53ac638e36f622ef8f71c2896e1f94e3ae Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 13 Aug 2014 12:10:29 +0300 Subject: [PATCH 609/796] registration project work --- .../FooServicePersistenceIntegrationTest.java | 2 +- .../bin/.gitignore | 1 - spring-security-login-error-handling/pom.xml | 7 +- .../persistence/dao/UserRepository.java | 3 +- .../org/baeldung/persistence/model/Role.java | 96 ++++++++++--------- .../org/baeldung/persistence/model/User.java | 20 ++-- .../service/EmailExistsException.java | 4 +- .../RegistrationFormWithValidation.java | 2 - .../service/RepositoryService.java | 25 +++-- .../baeldung/persistence/service/UserDto.java | 21 +++- .../persistence/service/UserService.java | 3 +- .../security/MyUserDetailsService.java | 18 ++-- .../java/org/baeldung/spring/AppConfig.java | 36 ++++--- .../java/org/baeldung/spring/MvcConfig.java | 12 +-- .../baeldung/spring/PersistenceJPAConfig.java | 2 +- .../baeldung/spring/SecSecurityConfig.java | 2 +- .../controller/RegistrationController.java | 92 +++++++----------- .../src/main/resources/application.properties | 17 +--- spring-security-mvc-ldap/.classpath | 37 +++++++ .../bin => spring-security-mvc-ldap}/.project | 23 ++--- 20 files changed, 214 insertions(+), 209 deletions(-) delete mode 100644 spring-security-login-error-handling/bin/.gitignore create mode 100644 spring-security-mvc-ldap/.classpath rename {spring-security-login-error-handling/bin => spring-security-mvc-ldap}/.project (83%) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 5b45d65e579d..07c6ba338205 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -3,7 +3,6 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; import org.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; @@ -36,6 +35,7 @@ public final void whenEntityIsCreated_thenNoExceptions() { } @Test(expected = DataIntegrityViolationException.class) + @Ignore("work in progress") public final void whenInvalidEntityIsCreated_thenDataException() { service.create(new Foo()); } diff --git a/spring-security-login-error-handling/bin/.gitignore b/spring-security-login-error-handling/bin/.gitignore deleted file mode 100644 index a57582cc39fe..000000000000 --- a/spring-security-login-error-handling/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/src diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index ea519a712b28..d75067541192 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.1.4.RELEASE + 1.1.5.RELEASE @@ -137,9 +137,6 @@ 1.7 - 3.1.1.RELEASE - 3.2.4.RELEASE - 1.6.10 1.7.6 @@ -152,7 +149,7 @@ 1 - 1.4.1.RELEASE + 1.6.2.RELEASE 17.0 diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java index d36cd1ba2fa7..373a28b4761b 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java @@ -3,7 +3,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.baeldung.persistence.model.User; - -public interface UserRepository extends JpaRepository{ +public interface UserRepository extends JpaRepository { public User findByUsername(String username); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java index f0a08885f518..4be1696e6e2f 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java @@ -11,52 +11,58 @@ import javax.persistence.OneToOne; import javax.persistence.Table; - -@Entity(name="role") +@Entity(name = "role") @Table(name = "role") public class Role { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - - @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id") - private User user; - - @Column(name="role") - private Integer role; - - public Role(){ - super(); - - } - public Role(Integer role){ - super(); - this.role = role; - } - public Role(Integer role, User user){ - super(); - this.role = role; - this.user = user; - } - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - public User getUser() { - return user; - } - public void setUser(User user) { - this.user = user; - } - public Integer getRole() { - return role; - } - public void setRole(Integer role) { - this.role = role; - } + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @JoinColumn(name = "user_id") + private User user; + + @Column(name = "role") + private Integer role; + + public Role() { + super(); + + } + + public Role(Integer role) { + super(); + this.role = role; + } + + public Role(Integer role, User user) { + super(); + this.role = role; + this.user = user; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Integer getRole() { + return role; + } + + public void setRole(Integer role) { + this.role = role; + } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java index 4fe8c9986f99..33851c9fa5c6 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java @@ -17,17 +17,16 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; - @Column(name="firstName") + @Column(name = "firstName") private String firstName; - @Column(name="lastName") + @Column(name = "lastName") private String lastName; - @Column(name="username") + @Column(name = "username") private String username; - @Column(name="password") + @Column(name = "password") private String password; - - - @OneToOne(mappedBy = "user",fetch = FetchType.EAGER, cascade = CascadeType.ALL) + + @OneToOne(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.ALL) private Role role; public Long getId() { @@ -77,8 +76,7 @@ public Role getRole() { public void setRole(Role role) { this.role = role; } - - + @Override public int hashCode() { final int prime = 31; @@ -100,11 +98,11 @@ public boolean equals(final Object obj) { return false; return true; } + @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]"). - append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); return builder.toString(); } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java index 848eab02c2e6..eaf5c3640990 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java @@ -1,7 +1,7 @@ package org.baeldung.persistence.service; -public class EmailExistsException extends Throwable{ - +public class EmailExistsException extends Throwable { + public EmailExistsException(String message) { super(message); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java index 6735ca7ab3f6..6be64b841471 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java @@ -7,8 +7,6 @@ public class RegistrationFormWithValidation { - - @Email @NotEmpty @Size(max = 100) diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java index c5f480e93cfa..25630ad9d620 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java @@ -7,43 +7,42 @@ import org.baeldung.persistence.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.data.repository.RepositoryDefinition; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @Service public class RepositoryService implements UserService { - @Autowired + @Autowired private UserRepository repository; - private PasswordEncoder passwordEncoder; - + + private final PasswordEncoder passwordEncoder; + @Autowired private Environment env; - + @Autowired public RepositoryService(PasswordEncoder passwordEncoder, UserRepository repository) { this.passwordEncoder = passwordEncoder; this.repository = repository; - } - + } + @Transactional @Override public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { if (emailExist(userAccountData.getUsername())) { - + throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getUsername()); } - - User user = new User(); + + User user = new User(); user.setFirstName(userAccountData.getFirstName()); user.setLastName(userAccountData.getLastName()); user.setPassword(userAccountData.getPassword()); user.setUsername(userAccountData.getUsername()); user.setRole(new Role(userAccountData.getRole(), user)); - return repository.save(user); + return repository.save(user); } - + private boolean emailExist(String email) { User user = repository.findByUsername(email); if (user != null) { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java index 0cf36dd5c1fa..3d7dfd6642c1 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -1,4 +1,5 @@ package org.baeldung.persistence.service; + //Renamed original RegistrationForm public class UserDto { @@ -7,51 +8,61 @@ public class UserDto { private String lastName; private String password; private String username; - private Integer role; + private Integer role; private String lastError; - + public String getLastError() { return lastError; } - + public void setLastError(String lastError) { this.lastError = lastError; } + public Integer getRole() { return role; } + public void setRole(Integer role) { this.role = role; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getFirstName() { return firstName; } + public void setFirstName(String firstName) { this.firstName = firstName; } + public String getLastName() { return lastName; } + public void setLastName(String lastName) { this.lastName = lastName; } + public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } + @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]"). - append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); return builder.toString(); } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java index 65c7516494c8..1166503fba98 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -1,7 +1,8 @@ package org.baeldung.persistence.service; + import org.baeldung.persistence.model.User; public interface UserService { - + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java index 41c27e2a9c3b..464a747683ca 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -22,33 +22,33 @@ public class MyUserDetailsService implements UserDetailsService { private static final Logger LOGGER = LoggerFactory.getLogger(UserDetailsService.class); - + private UserRepository userRepository; @Autowired public MyUserDetailsService(UserRepository repository) { this.userRepository = repository; } - + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { try { LOGGER.debug("Loading user by username: {}", username); User user = userRepository.findByUsername(username); LOGGER.debug("Found user: {}", user); if (user == null) { - //throw new UsernameNotFoundException("No user found with username: " + username); - boolean enabled = false; - return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); + // throw new UsernameNotFoundException("No user found with username: " + username); + boolean enabled = false; + return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); } boolean enabled = true; boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; - return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); + return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); } catch (Exception e) { throw new RuntimeException(e); - } + } } public Collection getAuthorities(Integer role) { @@ -60,7 +60,7 @@ public List getRoles(Integer role) { List roles = new ArrayList(); if (role.intValue() == 2) { - // roles.add("ROLE_USER"); + // roles.add("ROLE_USER"); roles.add("ROLE_ADMIN"); } else if (role.intValue() == 1) { @@ -69,7 +69,7 @@ public List getRoles(Integer role) { return roles; } - + public static List getGrantedAuthorities(List roles) { List authorities = new ArrayList(); for (String role : roles) { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java index 861e68b9ede0..987ae89cc707 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java @@ -1,6 +1,5 @@ package org.baeldung.spring; -import java.util.Properties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -9,7 +8,6 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.env.Environment; -import org.springframework.mail.javamail.JavaMailSenderImpl; @Configuration @ComponentScan(basePackages = { "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) @@ -24,22 +22,22 @@ public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer return new PropertySourcesPlaceholderConfigurer(); } - @Bean - public JavaMailSenderImpl javaMailSenderImpl() { - JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl(); - mailSenderImpl.setHost(env.getProperty("smtp.host")); - mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class)); - mailSenderImpl.setProtocol(env.getProperty("smtp.protocol")); - mailSenderImpl.setUsername(env.getProperty("smtp.username")); - mailSenderImpl.setPassword(env.getProperty("smtp.password")); - - Properties javaMailProps = new Properties(); - javaMailProps.put("mail.smtp.auth", true); - javaMailProps.put("mail.smtp.starttls.enable", true); - - mailSenderImpl.setJavaMailProperties(javaMailProps); - - return mailSenderImpl; - } +// @Bean +// public JavaMailSenderImpl javaMailSenderImpl() { +// JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl(); +// mailSenderImpl.setHost(env.getProperty("smtp.host")); +// mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class)); +// mailSenderImpl.setProtocol(env.getProperty("smtp.protocol")); +// mailSenderImpl.setUsername(env.getProperty("smtp.username")); +// mailSenderImpl.setPassword(env.getProperty("smtp.password")); +// +// Properties javaMailProps = new Properties(); +// javaMailProps.put("mail.smtp.auth", true); +// javaMailProps.put("mail.smtp.starttls.enable", true); +// +// mailSenderImpl.setJavaMailProperties(javaMailProps); +// +// return mailSenderImpl; +// } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index a51e253430c9..a7a46a10283e 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -19,11 +19,8 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; - @Configuration -@ComponentScan(basePackages = { - "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" -}) +@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @@ -46,9 +43,9 @@ public void addViewControllers(final ViewControllerRegistry registry) { registry.addViewController("/admin.html"); registry.addViewController("/registration.html"); registry.addViewController("/successRegister.html"); - + } - + @Bean public ViewResolver viewResolver() { final InternalResourceViewResolver bean = new InternalResourceViewResolver(); @@ -82,10 +79,11 @@ public MessageSource messageSource() { messageSource.setCacheSeconds(0); return messageSource; } + @Bean public UserValidator userValidator() { UserValidator userValidator = new UserValidator(); return userValidator; } - + } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java index 172ebbb77d32..32cd80854cf4 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -77,5 +77,5 @@ final Properties additionalProperties() { // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); return hibernateProperties; } - + } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 3e793a33f660..4da114c78b62 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -10,5 +10,5 @@ public class SecSecurityConfig { public SecSecurityConfig() { super(); } - + } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java index 12537965253b..3d70f8b5a1ed 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -1,7 +1,5 @@ package org.baeldung.web.controller; -import java.util.Locale; - import org.baeldung.persistence.model.User; import org.baeldung.persistence.service.EmailExistsException; import org.baeldung.persistence.service.UserDto; @@ -10,17 +8,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.MessageSource; -import org.springframework.core.env.Environment; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; -import org.springframework.validation.ObjectError; -import org.springframework.validation.Validator; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; @@ -30,7 +21,6 @@ import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.ModelAndView; - @Controller @SessionAttributes("user") public class RegistrationController { @@ -38,21 +28,18 @@ public class RegistrationController { private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationController.class); private UserService service; @Autowired - private MessageSource messages; - @Autowired - private JavaMailSender mailSender; - @Autowired private UserValidator validator; - + @InitBinder protected void initBinder(WebDataBinder binder) { binder.setValidator(this.validator); } + @Autowired public RegistrationController(UserService service) { this.service = service; } - + @RequestMapping(value = "/user/registration", method = RequestMethod.GET) public String showRegistrationForm(WebRequest request, Model model) { LOGGER.debug("Rendering registration page."); @@ -60,48 +47,47 @@ public String showRegistrationForm(WebRequest request, Model model) { model.addAttribute("user", userDto); return "registration"; } - /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST) - public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData, - BindingResult result, - WebRequest request, Errors errors) { - LOGGER.debug("Registering user account with information: {}", userAccountData); - if (result.hasErrors()) { - LOGGER.debug("Validation errors found. Rendering form view."); - return "registration"; - } - LOGGER.debug("No validation errors found. Continuing registration process."); - User registered = createUserAccount(userAccountData, result); - if (registered == null) { - errors.rejectValue("lastError", "message.regError"); - return "registration"; - } - LOGGER.debug("Registered user account with information: {}", registered); - - sendConfirmMail(userAccountData.getUsername(), request.getLocale()); - return "successRegister"; - //return "redirect:/"; - }*/ - @RequestMapping(value ="/user/registration", method = RequestMethod.POST) - public ModelAndView registerUserAccount( @ModelAttribute("user") UserDto userAccountData, - BindingResult result, - WebRequest request, Errors errors) { + + /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST) + public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData, + BindingResult result, + WebRequest request, Errors errors) { + LOGGER.debug("Registering user account with information: {}", userAccountData); + if (result.hasErrors()) { + LOGGER.debug("Validation errors found. Rendering form view."); + return "registration"; + } + LOGGER.debug("No validation errors found. Continuing registration process."); + User registered = createUserAccount(userAccountData, result); + if (registered == null) { + errors.rejectValue("lastError", "message.regError"); + return "registration"; + } + LOGGER.debug("Registered user account with information: {}", registered); + + sendConfirmMail(userAccountData.getUsername(), request.getLocale()); + return "successRegister"; + //return "redirect:/"; + }*/ + @RequestMapping(value = "/user/registration", method = RequestMethod.POST) + public ModelAndView registerUserAccount(@ModelAttribute("user") UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { LOGGER.debug("Registering user account with information: {}", userAccountData); validator.validate(userAccountData, result); User registered = createUserAccount(userAccountData, result); - if (registered == null) { + if (registered == null) { result.rejectValue("lastError", "message.regError"); } if (result.hasErrors()) { // show errors return new ModelAndView("registration", "user", userAccountData); } else { - + // success return new ModelAndView("successRegister", "user", userAccountData); - } - + } + } - + private User createUserAccount(UserDto userAccountData, BindingResult result) { LOGGER.debug("Creating user account with information: {}", userAccountData); User registered = null; @@ -110,18 +96,8 @@ private User createUserAccount(UserDto userAccountData, BindingResult result) { } catch (EmailExistsException e) { // TODO Auto-generated catch block return null; - } + } return registered; - } - - private void sendConfirmMail(String address, Locale locale){ - String recipientAddress = address; - String subject = "Registration Confirmation"; - String message = messages.getMessage("message.regSucc", null, locale); - SimpleMailMessage email = new SimpleMailMessage(); - email.setTo(recipientAddress); - email.setSubject(subject); - email.setText(message); - mailSender.send(email); } + } diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index a051636c6bd1..1144b5f03f64 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,17 +1,10 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA -jdbc.user=root -###jdbc.pass=admin### +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql init-db=false ################### Hibernate Configuration ########################## hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=true -hibernate.hbm2ddl.auto=validate -################### JavaMail Configuration ########################## -smtp.host=smtp.gmail.com -smtp.port=465 -smtp.protocol=smtps -smtp.username=edson@gmail.com -smtp.password= -support.email=edson@gmail.com \ No newline at end of file +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-mvc-ldap/.classpath b/spring-security-mvc-ldap/.classpath new file mode 100644 index 000000000000..c99cf8646248 --- /dev/null +++ b/spring-security-mvc-ldap/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-login-error-handling/bin/.project b/spring-security-mvc-ldap/.project similarity index 83% rename from spring-security-login-error-handling/bin/.project rename to spring-security-mvc-ldap/.project index 41a69a9af5d6..d43c118d1cb8 100644 --- a/spring-security-login-error-handling/bin/.project +++ b/spring-security-mvc-ldap/.project @@ -1,53 +1,48 @@ - spring-security-login-and-registration + spring-security-mvc-ldap - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder + org.eclipse.wst.jsdt.core.javascriptValidator - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.jdt.core.javabuilder - org.eclipse.wst.jsdt.core.javascriptValidator + org.eclipse.wst.common.project.facet.core.builder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder - org.eclipse.m2e.core.maven2Builder + org.springframework.ide.eclipse.core.springbuilder - org.hibernate.eclipse.console.hibernateBuilder + org.eclipse.wst.validation.validationbuilder + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.springframework.ide.eclipse.core.springnature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.wst.jsdt.core.jsNature - org.hibernate.eclipse.console.hibernateNature From 464a60eaded48e8a1c1e82bcb105f4edacbdf7ff Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 13 Aug 2014 20:57:48 +0300 Subject: [PATCH 610/796] cleanup work --- .../hibernate/FooPaginationPersistenceIntegrationTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java index 3d5c14231e6e..37e77ef1394c 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java @@ -16,7 +16,6 @@ import org.hibernate.ScrollableResults; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; import org.junit.After; import org.junit.Before; @@ -154,7 +153,6 @@ public final void givenUsingTheCriteriaApi_whenRetrievingFirstPage_thenCorrect() final int pageSize = 10; final Criteria criteria = session.createCriteria(Foo.class); - criteria.addOrder(Order.asc("id")); criteria.setFirstResult(0); criteria.setMaxResults(pageSize); final List firstPage = criteria.list(); @@ -166,7 +164,6 @@ public final void givenUsingTheCriteriaApi_whenRetrievingFirstPage_thenCorrect() @Test public final void givenUsingTheCriteriaApi_whenRetrievingPaginatedData_thenCorrect() { final Criteria criteriaCount = session.createCriteria(Foo.class); - criteriaCount.addOrder(Order.asc("id")); criteriaCount.setProjection(Projections.rowCount()); final Long count = (Long) criteriaCount.uniqueResult(); @@ -175,7 +172,6 @@ public final void givenUsingTheCriteriaApi_whenRetrievingPaginatedData_thenCorre final List fooList = Lists.newArrayList(); final Criteria criteria = session.createCriteria(Foo.class); - criteria.addOrder(Order.asc("id")); int totalEntities = 0; while (totalEntities < count.intValue()) { criteria.setFirstResult((pageNumber - 1) * pageSize); From de8d81990ac4646057738987a5c599f4de4eabe9 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Thu, 14 Aug 2014 18:12:45 -0500 Subject: [PATCH 611/796] spring security and registration could not run it - see video /Users/Elena/Google Drive/SharedWithEugene/Spring-Security-Login-and_Registration/2014-08-14 _1805.swf --- .../.classpath | 8 +- spring-security-login-error-handling/.project | 6 + spring-security-login-error-handling/pom.xml | 11 +- .../persistence/dao/UserRepository.java | 3 +- .../org/baeldung/persistence/model/Role.java | 96 +- .../org/baeldung/persistence/model/User.java | 20 +- .../service/EmailExistsException.java | 5 +- .../RegistrationFormWithValidation.java | 73 - .../service/RepositoryService.java | 28 +- .../baeldung/persistence/service/UserDto.java | 28 +- .../persistence/service/UserService.java | 4 +- .../persistence/service/UserValidator.java | 17 +- .../security/MyUserDetailsService.java | 18 +- .../java/org/baeldung/spring/AppConfig.java | 25 +- .../java/org/baeldung/spring/MvcConfig.java | 24 +- .../baeldung/spring/PersistenceJPAConfig.java | 12 +- .../baeldung/spring/SecSecurityConfig.java | 2 +- .../controller/RegistrationController.java | 66 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/messages_en.properties | 3 +- .../main/resources/messages_es_ES.properties | 11 +- .../src/main/resources/webSecurityConfig.xml | 9 - .../src/main/webapp/WEB-INF/view/admin.jsp | 4 +- .../src/main/webapp/WEB-INF/view/console.jsp | 4 +- .../src/main/webapp/WEB-INF/view/home.jsp | 1 + .../src/main/webapp/WEB-INF/view/homepage.jsp | 4 +- .../webapp/WEB-INF/view/invalidSession.jsp | 4 +- .../src/main/webapp/WEB-INF/view/login.jsp | 24 +- .../src/main/webapp/WEB-INF/view/logout.jsp | 6 +- .../main/webapp/WEB-INF/view/registration.jsp | 28 +- .../webapp/WEB-INF/view/successRegister.jsp | 3 +- .../src/main/webapp/resources/bootstrap.css | 6167 +++++++++++++++++ 32 files changed, 6373 insertions(+), 343 deletions(-) delete mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java create mode 100644 spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css diff --git a/spring-security-login-error-handling/.classpath b/spring-security-login-error-handling/.classpath index 0f4a4c27e0ce..1151b0d2572a 100644 --- a/spring-security-login-error-handling/.classpath +++ b/spring-security-login-error-handling/.classpath @@ -17,15 +17,15 @@ - + + - + - - + diff --git a/spring-security-login-error-handling/.project b/spring-security-login-error-handling/.project index 41c4e13e7cea..818a1e1a48f9 100644 --- a/spring-security-login-error-handling/.project +++ b/spring-security-login-error-handling/.project @@ -35,6 +35,11 @@ + + org.hibernate.eclipse.console.hibernateBuilder + + + org.eclipse.jem.workbench.JavaEMFNature @@ -44,5 +49,6 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature + org.hibernate.eclipse.console.hibernateNature diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index d75067541192..53d446cc99b8 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.1.5.RELEASE + 1.1.4.RELEASE @@ -100,6 +100,10 @@ org.hibernate hibernate-entitymanager + + org.hibernate + hibernate-validator + @@ -137,6 +141,9 @@ 1.7 + 3.1.1.RELEASE + 3.2.4.RELEASE + 1.6.10 1.7.6 @@ -149,7 +156,7 @@ 1 - 1.6.2.RELEASE + 1.4.1.RELEASE 17.0 diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java index 373a28b4761b..d36cd1ba2fa7 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java @@ -3,6 +3,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.baeldung.persistence.model.User; -public interface UserRepository extends JpaRepository { + +public interface UserRepository extends JpaRepository{ public User findByUsername(String username); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java index 4be1696e6e2f..f0a08885f518 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java @@ -11,58 +11,52 @@ import javax.persistence.OneToOne; import javax.persistence.Table; -@Entity(name = "role") + +@Entity(name="role") @Table(name = "role") public class Role { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id") - private User user; - - @Column(name = "role") - private Integer role; - - public Role() { - super(); - - } - - public Role(Integer role) { - super(); - this.role = role; - } - - public Role(Integer role, User user) { - super(); - this.role = role; - this.user = user; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Integer getRole() { - return role; - } - - public void setRole(Integer role) { - this.role = role; - } + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + + @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @JoinColumn(name = "user_id") + private User user; + + @Column(name="role") + private Integer role; + + public Role(){ + super(); + + } + public Role(Integer role){ + super(); + this.role = role; + } + public Role(Integer role, User user){ + super(); + this.role = role; + this.user = user; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public User getUser() { + return user; + } + public void setUser(User user) { + this.user = user; + } + public Integer getRole() { + return role; + } + public void setRole(Integer role) { + this.role = role; + } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java index 33851c9fa5c6..4fe8c9986f99 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java @@ -17,16 +17,17 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; - @Column(name = "firstName") + @Column(name="firstName") private String firstName; - @Column(name = "lastName") + @Column(name="lastName") private String lastName; - @Column(name = "username") + @Column(name="username") private String username; - @Column(name = "password") + @Column(name="password") private String password; - - @OneToOne(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.ALL) + + + @OneToOne(mappedBy = "user",fetch = FetchType.EAGER, cascade = CascadeType.ALL) private Role role; public Long getId() { @@ -76,7 +77,8 @@ public Role getRole() { public void setRole(Role role) { this.role = role; } - + + @Override public int hashCode() { final int prime = 31; @@ -98,11 +100,11 @@ public boolean equals(final Object obj) { return false; return true; } - @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + builder.append("User [firstName=").append(firstName).append("]"). + append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); return builder.toString(); } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java index eaf5c3640990..edb44bd59893 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java @@ -1,7 +1,8 @@ package org.baeldung.persistence.service; -public class EmailExistsException extends Throwable { - +@SuppressWarnings("serial") +public class EmailExistsException extends Throwable{ + public EmailExistsException(String message) { super(message); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java deleted file mode 100644 index 6be64b841471..000000000000 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.baeldung.persistence.service; - -import javax.validation.constraints.Size; - -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotEmpty; - -public class RegistrationFormWithValidation { - - @Email - @NotEmpty - @Size(max = 100) - private String email; - - @NotEmpty - @Size(max = 100) - private String firstName; - - @NotEmpty - @Size(max = 100) - private String lastName; - - private String password; - - private String passwordVerification; - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getPasswordVerification() { - return passwordVerification; - } - - public void setPasswordVerification(String passwordVerification) { - this.passwordVerification = passwordVerification; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[email").append(email).append("]"); - return builder.toString(); - } -} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java index 25630ad9d620..e5fbc3622d08 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java @@ -1,48 +1,42 @@ package org.baeldung.persistence.service; import javax.transaction.Transactional; - import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.model.Role; import org.baeldung.persistence.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @Service public class RepositoryService implements UserService { - @Autowired + @Autowired private UserRepository repository; - - private final PasswordEncoder passwordEncoder; - + @Autowired private Environment env; - + @Autowired - public RepositoryService(PasswordEncoder passwordEncoder, UserRepository repository) { - this.passwordEncoder = passwordEncoder; + public RepositoryService( UserRepository repository) { this.repository = repository; - } - + } + @Transactional @Override public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { if (emailExist(userAccountData.getUsername())) { - + throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getUsername()); - } - - User user = new User(); + } + User user = new User(); user.setFirstName(userAccountData.getFirstName()); user.setLastName(userAccountData.getLastName()); user.setPassword(userAccountData.getPassword()); user.setUsername(userAccountData.getUsername()); user.setRole(new Role(userAccountData.getRole(), user)); - return repository.save(user); + return repository.save(user); } - + private boolean emailExist(String email) { User user = repository.findByUsername(email); if (user != null) { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java index 3d7dfd6642c1..b313b89b1395 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -1,68 +1,48 @@ package org.baeldung.persistence.service; -//Renamed original RegistrationForm - public class UserDto { private String firstName; private String lastName; private String password; private String username; - private Integer role; - private String lastError; - - public String getLastError() { - return lastError; - } - - public void setLastError(String lastError) { - this.lastError = lastError; - } - + private Integer role; + public Integer getRole() { return role; } - public void setRole(Integer role) { this.role = role; } - public String getUsername() { return username; } - public void setUsername(String username) { this.username = username; } - public String getFirstName() { return firstName; } - public void setFirstName(String firstName) { this.firstName = firstName; } - public String getLastName() { return lastName; } - public void setLastName(String lastName) { this.lastName = lastName; } - public String getPassword() { return password; } - public void setPassword(String password) { this.password = password; } - @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + builder.append("User [firstName=").append(firstName).append("]"). + append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]").append("[password").append(password).append("]"); return builder.toString(); } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java index 1166503fba98..b51bda5b3b41 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -1,8 +1,8 @@ package org.baeldung.persistence.service; - import org.baeldung.persistence.model.User; public interface UserService { - + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; + } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java index f93ba5825e0b..ac6bbb89f374 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java @@ -1,22 +1,33 @@ package org.baeldung.persistence.service; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.springframework.validation.Errors; import org.springframework.validation.ValidationUtils; import org.springframework.validation.Validator; public class UserValidator implements Validator { - + private Pattern pattern; + private Matcher matcher; + private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + @Override public boolean supports(Class clazz) { return UserDto.class.isAssignableFrom(clazz); } - + @Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "message.firstName", "Firstname is required."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "message.lastName", "LastName is required."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "message.password", "LastName is required."); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required."); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required."); } + public boolean validateEmail(String email) { + pattern = Pattern.compile(EMAIL_PATTERN); + matcher = pattern.matcher(email); + return matcher.matches(); + + } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java index 464a747683ca..41c27e2a9c3b 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -22,33 +22,33 @@ public class MyUserDetailsService implements UserDetailsService { private static final Logger LOGGER = LoggerFactory.getLogger(UserDetailsService.class); - + private UserRepository userRepository; @Autowired public MyUserDetailsService(UserRepository repository) { this.userRepository = repository; } - + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { try { LOGGER.debug("Loading user by username: {}", username); User user = userRepository.findByUsername(username); LOGGER.debug("Found user: {}", user); if (user == null) { - // throw new UsernameNotFoundException("No user found with username: " + username); - boolean enabled = false; - return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); + //throw new UsernameNotFoundException("No user found with username: " + username); + boolean enabled = false; + return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); } boolean enabled = true; boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; - return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); + return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); } catch (Exception e) { throw new RuntimeException(e); - } + } } public Collection getAuthorities(Integer role) { @@ -60,7 +60,7 @@ public List getRoles(Integer role) { List roles = new ArrayList(); if (role.intValue() == 2) { - // roles.add("ROLE_USER"); + // roles.add("ROLE_USER"); roles.add("ROLE_ADMIN"); } else if (role.intValue() == 1) { @@ -69,7 +69,7 @@ public List getRoles(Integer role) { return roles; } - + public static List getGrantedAuthorities(List roles) { List authorities = new ArrayList(); for (String role : roles) { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java index 987ae89cc707..6047130a698a 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java @@ -1,43 +1,20 @@ package org.baeldung.spring; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.core.env.Environment; @Configuration @ComponentScan(basePackages = { "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) @Import({ MvcConfig.class, PersistenceJPAConfig.class, SecSecurityConfig.class }) @PropertySource("classpath:application.properties") public class AppConfig { - @Autowired - private Environment env; - + @Bean public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } - -// @Bean -// public JavaMailSenderImpl javaMailSenderImpl() { -// JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl(); -// mailSenderImpl.setHost(env.getProperty("smtp.host")); -// mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class)); -// mailSenderImpl.setProtocol(env.getProperty("smtp.protocol")); -// mailSenderImpl.setUsername(env.getProperty("smtp.username")); -// mailSenderImpl.setPassword(env.getProperty("smtp.password")); -// -// Properties javaMailProps = new Properties(); -// javaMailProps.put("mail.smtp.auth", true); -// javaMailProps.put("mail.smtp.starttls.enable", true); -// -// mailSenderImpl.setJavaMailProperties(javaMailProps); -// -// return mailSenderImpl; -// } - } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index a7a46a10283e..4747821d1fb1 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -1,7 +1,6 @@ package org.baeldung.spring; import java.util.Locale; - import org.baeldung.persistence.service.UserValidator; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; @@ -12,6 +11,7 @@ import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.i18n.CookieLocaleResolver; @@ -19,8 +19,11 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; + @Configuration -@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) +@ComponentScan(basePackages = { + "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" +}) @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @@ -33,7 +36,6 @@ public MvcConfig() { @Override public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - registry.addViewController("/login.html"); registry.addViewController("/logout.html"); registry.addViewController("/homepage.html"); @@ -42,19 +44,23 @@ public void addViewControllers(final ViewControllerRegistry registry) { registry.addViewController("/console.html"); registry.addViewController("/admin.html"); registry.addViewController("/registration.html"); - registry.addViewController("/successRegister.html"); - + registry.addViewController("/successRegister.html"); } - + @Bean public ViewResolver viewResolver() { final InternalResourceViewResolver bean = new InternalResourceViewResolver(); bean.setViewClass(JstlView.class); bean.setPrefix("/WEB-INF/view/"); bean.setSuffix(".jsp"); - return bean; } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**") + .addResourceLocations("/","/resources/"); + } @Override public void addInterceptors(InterceptorRegistry registry) { @@ -79,11 +85,11 @@ public MessageSource messageSource() { messageSource.setCacheSeconds(0); return messageSource; } - + @Bean public UserValidator userValidator() { UserValidator userValidator = new UserValidator(); return userValidator; } - + } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java index 32cd80854cf4..e4c3d4835f30 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java @@ -1,9 +1,7 @@ package org.baeldung.spring; import java.util.Properties; - import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -18,14 +16,13 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; -//import com.google.common.base.Preconditions; - @Configuration @EnableTransactionManagement @PropertySource({ "classpath:application.properties" }) @ComponentScan({ "org.baeldung.persistence.model" }) @EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") public class PersistenceJPAConfig { + @Autowired private Environment env; @@ -38,12 +35,9 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - // vendorAdapter.set em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); - return em; } @@ -54,7 +48,6 @@ public DataSource dataSource() { dataSource.setUrl(env.getProperty("jdbc.url")); dataSource.setUsername(env.getProperty("jdbc.user")); dataSource.setPassword(env.getProperty("jdbc.pass")); - return dataSource; } @@ -74,8 +67,7 @@ final Properties additionalProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); return hibernateProperties; } - + } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4da114c78b62..3e793a33f660 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -10,5 +10,5 @@ public class SecSecurityConfig { public SecSecurityConfig() { super(); } - + } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java index 3d70f8b5a1ed..a8494efb2d7a 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -1,5 +1,6 @@ package org.baeldung.web.controller; +import javax.validation.Valid; import org.baeldung.persistence.model.User; import org.baeldung.persistence.service.EmailExistsException; import org.baeldung.persistence.service.UserDto; @@ -8,6 +9,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; @@ -17,29 +20,31 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.ModelAndView; + @Controller -@SessionAttributes("user") public class RegistrationController { private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationController.class); private UserService service; @Autowired + private MessageSource messages; + @Autowired + private JavaMailSender mailSender; + @Autowired private UserValidator validator; - + @InitBinder protected void initBinder(WebDataBinder binder) { binder.setValidator(this.validator); } - @Autowired public RegistrationController(UserService service) { this.service = service; } - + @RequestMapping(value = "/user/registration", method = RequestMethod.GET) public String showRegistrationForm(WebRequest request, Model model) { LOGGER.debug("Rendering registration page."); @@ -47,57 +52,34 @@ public String showRegistrationForm(WebRequest request, Model model) { model.addAttribute("user", userDto); return "registration"; } - - /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST) - public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData, - BindingResult result, - WebRequest request, Errors errors) { - LOGGER.debug("Registering user account with information: {}", userAccountData); - if (result.hasErrors()) { - LOGGER.debug("Validation errors found. Rendering form view."); - return "registration"; - } - LOGGER.debug("No validation errors found. Continuing registration process."); - User registered = createUserAccount(userAccountData, result); - if (registered == null) { - errors.rejectValue("lastError", "message.regError"); - return "registration"; - } - LOGGER.debug("Registered user account with information: {}", registered); - - sendConfirmMail(userAccountData.getUsername(), request.getLocale()); - return "successRegister"; - //return "redirect:/"; - }*/ + @RequestMapping(value = "/user/registration", method = RequestMethod.POST) - public ModelAndView registerUserAccount(@ModelAttribute("user") UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { - LOGGER.debug("Registering user account with information: {}", userAccountData); - validator.validate(userAccountData, result); - User registered = createUserAccount(userAccountData, result); - if (registered == null) { - result.rejectValue("lastError", "message.regError"); + public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { + boolean goodEmailCheck = validator.validateEmail(userAccountData.getUsername()); + if (!goodEmailCheck) + result.rejectValue("username", "message.badEmail"); + User registered = null; + if (!result.hasErrors()) + registered = createUserAccount(userAccountData, result); + if (registered == null && !userAccountData.getUsername().isEmpty() && goodEmailCheck) { + result.rejectValue("username", "message.regError"); } if (result.hasErrors()) { - // show errors return new ModelAndView("registration", "user", userAccountData); } else { - - // success return new ModelAndView("successRegister", "user", userAccountData); } } - + private User createUserAccount(UserDto userAccountData, BindingResult result) { - LOGGER.debug("Creating user account with information: {}", userAccountData); User registered = null; try { registered = service.registerNewUserAccount(userAccountData); } catch (EmailExistsException e) { - // TODO Auto-generated catch block return null; - } + } return registered; - } - + } } + diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index 1144b5f03f64..334ec63ed017 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,6 +1,6 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql init-db=false diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-error-handling/src/main/resources/messages_en.properties index 66a58dfeabf5..de6630ec92f2 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_en.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_en.properties @@ -8,7 +8,8 @@ message.logoutSucc=You logged out successfully message.regSucc=You registered successfully. We will send you a confirmation message to your email account. message.regError=An account for that username/email already exists. Please enter a different username. message.lastName=Last name is required -message.firstName=First name is required +message.firstName=First name required +message.badEmail=Invalid email address label.user.email=Email label.user.firstName=First name label.user.lastName=Last name diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties index 0becc40dd413..3f870472a4fd 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties @@ -3,14 +3,15 @@ message.password=Por favor ingrese una clave message.unauth=Acceso denegado !! message.badCredentials=Usuario o clave invalida message.sessionExpired=La sesion expiro -message.logoutError=Lo sentimos, hubo problemas en logout -message.logoutSucc=Logout con exito +message.logoutError=Lo sentimos, hubo problemas al salir +message.logoutSucc=Salida con exito message.regSucc=Se registro correctamente. Le enviaremos un mensaje de confirmacion a su direccion de email. message.regError=Ya existe una cuenta con ese nombre de usuario. Ingrese un nombre de usuario diferente. -message.lastName=El campo Last Name es obligatorio -message.firstName=El campo First Name es obligatorio +message.lastName=Por favor ingrese su apellido +message.firstName=Por favor ingrese su nombre +message.badEmail=Direccion de correo no es valida label.user.email=Email label.user.firstName=Nombre label.user.lastName=Apellido label.user.password=Clave -label.login=Loguee aqui \ No newline at end of file +label.login=Autehtifiquese aqui \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index ef5ba495dad8..7c362885aef9 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -29,22 +29,13 @@ - - - - - - - \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp index 5aefc9ab5590..027b387b96e1 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp @@ -5,7 +5,9 @@ - + +" rel="stylesheet"> + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp index 05a930731be4..b82842169f17 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp @@ -1,7 +1,9 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - + +" rel="stylesheet"> +

This is the landing page for the admin

diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp index fe6e572b99f9..4d54257bff34 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp @@ -2,6 +2,7 @@ <%@ page session="true" %> +" rel="stylesheet"> Home diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp index fab96383df5d..c13acb775652 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp @@ -2,7 +2,9 @@ <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <%@ page session="true" %> - + +" rel="stylesheet"> + diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp index 175c49811730..8aa9d7b49f34 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -1,10 +1,12 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +" rel="stylesheet"> Home -

+

diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp index 97bc749acc23..97c8b3317d1d 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -5,28 +5,17 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ page session="true"%> - -
- -
-
- -
- -
-
- -
- -
- Register -
- +" rel="stylesheet"> + +
+ +
+
-

Login

English | Spanish -
- - - - - - - - - - - - - -
User:
Password:
- -
+
+ + + + + + + + + + + + +
User:
Password:
+

Current Locale : ${pageContext.response.locale}
">Sign Up - \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp index a234f11d093b..ed05de34583f 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp @@ -11,7 +11,7 @@
- +
@@ -20,7 +20,6 @@ Logged Out - Login \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp index 979da1142784..a4c40d670b53 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp @@ -35,6 +35,11 @@ + + + + +
diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp index ca676a499981..d937128a599f 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp @@ -13,8 +13,10 @@ Registration Success - -

- "> +
+ +
+ "> \ No newline at end of file From 2f22feaf46c68dc43c14a81ed88ea23c35ab1aaf Mon Sep 17 00:00:00 2001 From: egmp777 Date: Mon, 25 Aug 2014 15:25:58 -0500 Subject: [PATCH 624/796] New Cleanup Added hashCode, equals and toString to Role --- .../org/baeldung/persistence/model/Role.java | 29 +++++++++++++++++++ .../src/main/resources/application.properties | 7 ++--- .../src/main/webapp/WEB-INF/view/admin.jsp | 14 ++++----- .../src/main/webapp/WEB-INF/view/console.jsp | 12 ++++---- .../src/main/webapp/WEB-INF/view/homepage.jsp | 9 ------ .../src/main/webapp/WEB-INF/view/login.jsp | 1 - .../src/main/webapp/WEB-INF/view/logout.jsp | 1 - 7 files changed, 44 insertions(+), 29 deletions(-) diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java index 7fcfce196a3c..bb4b86e32f95 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java @@ -66,4 +66,33 @@ public Integer getRole() { public void setRole(Integer role) { this.role = role; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((role == null) ? 0 : role.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Role role = (Role) obj; + if (!role.equals(role.role)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Role [role=").append(role).append("]").append("[id=").append(id).append("]"); + return builder.toString(); + } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index 425018eea6f0..bcff123738c3 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,11 +1,10 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql init-db=false ################### Hibernate Configuration ########################## hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop - +hibernate.show_sql=true +hibernate.hbm2ddl.auto=validate \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp index 923971cb0839..3b88dbdb12ff 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp @@ -1,18 +1,16 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - + " rel="stylesheet"> -<<<<<<< HEAD -======= - ->>>>>>> FETCH_HEAD + + +

Hello Admin

diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp index 2243df768c94..f6ab8b612124 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp @@ -1,20 +1,20 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> - " rel="stylesheet">

This is the landing page for the admin

- + This text is only visible to a user
-
- + + This text is only visible to an admin
-
+ ">Logout ">Administrator Page diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp index 9b6502c9071d..4fb2853ef1f7 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,10 +1,5 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<<<<<<< HEAD -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -======= <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> ->>>>>>> FETCH_HEAD <%@ page session="true"%> @@ -27,8 +22,4 @@ ">Home ">Administrator Page -<<<<<<< HEAD -======= - ->>>>>>> FETCH_HEAD \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp index ecc8965f7db3..626554b4af43 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -4,7 +4,6 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ page session="true"%> - diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp index d87e41fc6c47..f33773b2170b 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp @@ -1,7 +1,6 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - From 7f8eea622ef6913089027078bc5a82f85cb462c5 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Mon, 25 Aug 2014 15:32:22 -0500 Subject: [PATCH 625/796] Forgot Properties Changed the Properties File back to properties set by eugen. --- .../src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index bcff123738c3..1144b5f03f64 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,10 +1,10 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql init-db=false ################### Hibernate Configuration ########################## hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=true -hibernate.hbm2ddl.auto=validate \ No newline at end of file +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop From 9254032a037ca803396b33547a6cb3c18cbfc60f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 5 Sep 2014 20:29:14 +0300 Subject: [PATCH 626/796] gson serialization work --- .../serialization/GsonSerializationTest.java | 64 +++++++++++++++++++ .../gson/serialization/SourceClass.java | 45 +++++++++++++ ...urceClassChangingFieldNamesSerializer.java | 24 +++++++ ...rceClassIgnoringExtraFieldsSerializer.java | 21 ++++++ 4 files changed, 154 insertions(+) create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java new file mode 100644 index 000000000000..a0fd3c0ff9ee --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java @@ -0,0 +1,64 @@ +package org.baeldung.gson.serialization; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Type; +import java.util.Collection; + +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; + +public class GsonSerializationTest { + + @Test + public void givenCollection_whenSerializing_thenCorrect() { + final Collection sourceCollection = Lists.newArrayList(new SourceClass(1, "one"), new SourceClass(2, "two")); + final Type sourceCollectionType = new TypeToken>() { + }.getType(); + final String jsonCollection = new Gson().toJson(sourceCollection, sourceCollectionType); + + // test + final Collection testCollection = new Gson().fromJson(jsonCollection, sourceCollectionType); + assertEquals(sourceCollection, testCollection); + } + + @Test + public void givenArrayOfObjects_whenSerializing_thenMapToJsonCollection() { + final SourceClass[] sourceArray = { new SourceClass(1, "one"), new SourceClass(2, "two") }; + final String jsonCollection = new Gson().toJson(sourceArray); + + // test + final String estimatedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; + assertEquals(estimatedResult, jsonCollection); + } + + @Test + public void givenUsingCustomSerializer_whenSerializingObjectToJsonWithDissimilarFieldNames_thenCorrect() { + final SourceClass sourceObject = new SourceClass(7, "seven"); + final GsonBuilder gsonBuildr = new GsonBuilder(); + gsonBuildr.registerTypeAdapter(SourceClass.class, new SourceClassChangingFieldNamesSerializer()); + final Gson gson = gsonBuildr.create(); + final String jsonString = gson.toJson(sourceObject); + + // test + final String estimatedResult = "{\"otherIntValue\":7,\"otherStringValue\":\"seven\"}"; + assertEquals(estimatedResult, jsonString); + } + + @Test + public void givenUsingCustomSerializer_whenSerializingObject_thenFieldIgnored() { + final SourceClass sourceObject = new SourceClass(7, "seven"); + final GsonBuilder gsonBuildr = new GsonBuilder(); + gsonBuildr.registerTypeAdapter(SourceClass.class, new SourceClassIgnoringExtraFieldsSerializer()); + final Gson gson = gsonBuildr.create(); + final String jsonString = gson.toJson(sourceObject); + + // test + final String estimatedResult = "{\"intValue\":7}"; + assertEquals(estimatedResult, jsonString); + } +} \ No newline at end of file diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java new file mode 100644 index 000000000000..27f9192ab8d2 --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java @@ -0,0 +1,45 @@ +package org.baeldung.gson.serialization; + +public class SourceClass { + public int intValue; + public String stringValue; + + public SourceClass(final int intValue, final String stringValue) { + this.intValue = intValue; + this.stringValue = stringValue; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + intValue; + result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final SourceClass other = (SourceClass) obj; + if (intValue != other.intValue) + return false; + if (stringValue == null) { + if (other.stringValue != null) + return false; + } else if (!stringValue.equals(other.stringValue)) + return false; + return true; + } + + @Override + public String toString() { + return "SourceClass{" + "intValue=" + intValue + ", stringValue='" + stringValue + '\'' + '}'; + } + +} diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java new file mode 100644 index 000000000000..b15a9aa4e5c7 --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java @@ -0,0 +1,24 @@ +package org.baeldung.gson.serialization; + +import java.lang.reflect.Type; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +public class SourceClassChangingFieldNamesSerializer implements JsonSerializer { + + @Override + public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final JsonSerializationContext context) { + final String otherIntValueName = "otherIntValue"; + final String otherStringValueName = "otherStringValue"; + + final JsonObject jObject = new JsonObject(); + jObject.addProperty(otherIntValueName, src.intValue); + jObject.addProperty(otherStringValueName, src.stringValue); + + return jObject; + } + +} diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java new file mode 100644 index 000000000000..fd4bb64a3aba --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java @@ -0,0 +1,21 @@ +package org.baeldung.gson.serialization; + +import java.lang.reflect.Type; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +public class SourceClassIgnoringExtraFieldsSerializer implements JsonSerializer { + + @Override + public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final JsonSerializationContext context) { + final String intValue = "intValue"; + final JsonObject jObject = new JsonObject(); + jObject.addProperty(intValue, src.intValue); + + return jObject; + } + +} From c9f92be3b1699d9119459f87317f99f58fb09fd6 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 8 Sep 2014 20:05:53 +0300 Subject: [PATCH 627/796] gson work --- .../serialization/GsonSerializationTest.java | 15 ++++++ .../gson/serialization/SourceClass.java | 51 +++++++++++-------- ...urceClassChangingFieldNamesSerializer.java | 4 +- ...rceClassIgnoringExtraFieldsSerializer.java | 3 +- 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java index a0fd3c0ff9ee..4f233e7d478f 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java @@ -1,9 +1,11 @@ package org.baeldung.gson.serialization; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.lang.reflect.Type; import java.util.Collection; +import java.util.Date; import org.junit.Test; @@ -61,4 +63,17 @@ public void givenUsingCustomSerializer_whenSerializingObject_thenFieldIgnored() final String estimatedResult = "{\"intValue\":7}"; assertEquals(estimatedResult, jsonString); } + + @Test + public void givenDate_whenSerializing_thenCorrect() { + final Date sourceDate = new Date(1000000L); + final Gson gson = new Gson(); + final Type sourceDateType = new TypeToken() { + }.getType(); + final String jsonDate = gson.toJson(sourceDate, sourceDateType); + + // test + final Date testDate = gson.fromJson(jsonDate, sourceDateType); + assertTrue(sourceDate.equals(testDate)); + } } \ No newline at end of file diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java index 27f9192ab8d2..02de2636c207 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java @@ -1,45 +1,52 @@ package org.baeldung.gson.serialization; public class SourceClass { - public int intValue; - public String stringValue; + private int intValue; + private String stringValue; public SourceClass(final int intValue, final String stringValue) { this.intValue = intValue; this.stringValue = stringValue; } + // API + + public int getIntValue() { + return intValue; + } + + public String getStringValue() { + return stringValue; + } + + // + @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + intValue; - result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode()); - return result; + public String toString() { + return "SourceClass{" + "intValue=" + intValue + ", stringValue='" + stringValue + '\'' + '}'; } @Override - public boolean equals(final Object obj) { - if (this == obj) + public boolean equals(final Object o) { + if (this == o) return true; - if (obj == null) + if (!(o instanceof SourceClass)) return false; - if (getClass() != obj.getClass()) - return false; - final SourceClass other = (SourceClass) obj; - if (intValue != other.intValue) + + final SourceClass that = (SourceClass) o; + + if (intValue != that.intValue) return false; - if (stringValue == null) { - if (other.stringValue != null) - return false; - } else if (!stringValue.equals(other.stringValue)) + if (!stringValue.equals(that.stringValue)) return false; + return true; } @Override - public String toString() { - return "SourceClass{" + "intValue=" + intValue + ", stringValue='" + stringValue + '\'' + '}'; + public int hashCode() { + int result = intValue; + result = 31 * result + stringValue.hashCode(); + return result; } - } diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java index b15a9aa4e5c7..aef2d31011ee 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java @@ -15,8 +15,8 @@ public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final final String otherStringValueName = "otherStringValue"; final JsonObject jObject = new JsonObject(); - jObject.addProperty(otherIntValueName, src.intValue); - jObject.addProperty(otherStringValueName, src.stringValue); + jObject.addProperty(otherIntValueName, src.getIntValue()); + jObject.addProperty(otherStringValueName, src.getStringValue()); return jObject; } diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java index fd4bb64a3aba..de8487e09730 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java @@ -8,12 +8,11 @@ import com.google.gson.JsonSerializer; public class SourceClassIgnoringExtraFieldsSerializer implements JsonSerializer { - @Override public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final JsonSerializationContext context) { final String intValue = "intValue"; final JsonObject jObject = new JsonObject(); - jObject.addProperty(intValue, src.intValue); + jObject.addProperty(intValue, src.getIntValue()); return jObject; } From eb3925fb0e9896f319b6371b170c445e6ba96f97 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 8 Sep 2014 20:06:05 +0300 Subject: [PATCH 628/796] gson work --- .../gson/serialization/GsonSerializationTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java index 4f233e7d478f..5a3b779ebbd6 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java @@ -24,18 +24,18 @@ public void givenCollection_whenSerializing_thenCorrect() { final String jsonCollection = new Gson().toJson(sourceCollection, sourceCollectionType); // test - final Collection testCollection = new Gson().fromJson(jsonCollection, sourceCollectionType); - assertEquals(sourceCollection, testCollection); + final String estimatedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; + assertEquals(estimatedResult, jsonCollection); } @Test - public void givenArrayOfObjects_whenSerializing_thenMapToJsonCollection() { + public void givenArrayOfObjects_whenSerializing_thenCorrect() { final SourceClass[] sourceArray = { new SourceClass(1, "one"), new SourceClass(2, "two") }; - final String jsonCollection = new Gson().toJson(sourceArray); + final String jsonString = new Gson().toJson(sourceArray); // test final String estimatedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; - assertEquals(estimatedResult, jsonCollection); + assertEquals(estimatedResult, jsonString); } @Test @@ -73,7 +73,7 @@ public void givenDate_whenSerializing_thenCorrect() { final String jsonDate = gson.toJson(sourceDate, sourceDateType); // test - final Date testDate = gson.fromJson(jsonDate, sourceDateType); - assertTrue(sourceDate.equals(testDate)); + final String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; + assertTrue(jsonDate.equals(estimatedResult)); } } \ No newline at end of file From 895e273ec565e2977da103b071c08da1c50b4db3 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 8 Sep 2014 20:59:31 +0300 Subject: [PATCH 629/796] gson cleanup --- ...NamesSerializer.java => DifferentNameSerializer.java} | 2 +- .../gson/serialization/GsonSerializationTest.java | 9 +++++---- ...eldsSerializer.java => IgnoringFieldsSerializer.java} | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename gson/src/test/java/org/baeldung/gson/serialization/{SourceClassChangingFieldNamesSerializer.java => DifferentNameSerializer.java} (88%) rename gson/src/test/java/org/baeldung/gson/serialization/{SourceClassIgnoringExtraFieldsSerializer.java => IgnoringFieldsSerializer.java} (85%) diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java similarity index 88% rename from gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java rename to gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java index aef2d31011ee..9cef1da37bfc 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassChangingFieldNamesSerializer.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java @@ -7,7 +7,7 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -public class SourceClassChangingFieldNamesSerializer implements JsonSerializer { +public class DifferentNameSerializer implements JsonSerializer { @Override public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final JsonSerializationContext context) { diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java index 5a3b779ebbd6..93a44647e39f 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java @@ -39,10 +39,10 @@ public void givenArrayOfObjects_whenSerializing_thenCorrect() { } @Test - public void givenUsingCustomSerializer_whenSerializingObjectToJsonWithDissimilarFieldNames_thenCorrect() { + public void givenUsingCustomSerializer_whenChangingNameOfFieldOnSerializing_thenCorrect() { final SourceClass sourceObject = new SourceClass(7, "seven"); final GsonBuilder gsonBuildr = new GsonBuilder(); - gsonBuildr.registerTypeAdapter(SourceClass.class, new SourceClassChangingFieldNamesSerializer()); + gsonBuildr.registerTypeAdapter(SourceClass.class, new DifferentNameSerializer()); final Gson gson = gsonBuildr.create(); final String jsonString = gson.toJson(sourceObject); @@ -52,10 +52,10 @@ public void givenUsingCustomSerializer_whenSerializingObjectToJsonWithDissimilar } @Test - public void givenUsingCustomSerializer_whenSerializingObject_thenFieldIgnored() { + public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgnored() { final SourceClass sourceObject = new SourceClass(7, "seven"); final GsonBuilder gsonBuildr = new GsonBuilder(); - gsonBuildr.registerTypeAdapter(SourceClass.class, new SourceClassIgnoringExtraFieldsSerializer()); + gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsSerializer()); final Gson gson = gsonBuildr.create(); final String jsonString = gson.toJson(sourceObject); @@ -76,4 +76,5 @@ public void givenDate_whenSerializing_thenCorrect() { final String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; assertTrue(jsonDate.equals(estimatedResult)); } + } \ No newline at end of file diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java similarity index 85% rename from gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java rename to gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java index de8487e09730..c8fb95028cac 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClassIgnoringExtraFieldsSerializer.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java @@ -7,7 +7,7 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -public class SourceClassIgnoringExtraFieldsSerializer implements JsonSerializer { +public class IgnoringFieldsSerializer implements JsonSerializer { @Override public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final JsonSerializationContext context) { final String intValue = "intValue"; From 53c0dbbbdd231c7deb0c393eeb66ece4265b20c0 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Mon, 8 Sep 2014 13:55:58 -0500 Subject: [PATCH 630/796] Changes September --- .../persistence/dao/UserRepository.java | 2 +- .../org/baeldung/persistence/model/User.java | 18 ++++---- ...nameValidator.java => EmailValidator.java} | 4 +- .../persistence/service/IUserService.java | 9 ++++ .../service/RepositoryService.java | 46 ------------------- .../baeldung/persistence/service/UserDto.java | 22 ++++----- .../persistence/service/UserService.java | 34 +++++++++++++- .../{ValidUsername.java => ValidEmail.java} | 4 +- .../security/MyUserDetailsService.java | 19 ++++---- .../java/org/baeldung/spring/MvcConfig.java | 6 +-- .../controller/RegistrationController.java | 17 +++++-- .../src/main/resources/messages_en.properties | 22 ++++++--- .../main/resources/messages_es_ES.properties | 24 +++++++--- .../src/main/resources/webSecurityConfig.xml | 5 +- .../src/main/webapp/WEB-INF/view/login.jsp | 14 +++--- .../main/webapp/WEB-INF/view/registration.jsp | 25 +++++----- .../webapp/WEB-INF/view/successRegister.jsp | 4 +- 17 files changed, 147 insertions(+), 128 deletions(-) rename spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/{UsernameValidator.java => EmailValidator.java} (83%) create mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java delete mode 100644 spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java rename spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/{ValidUsername.java => ValidEmail.java} (88%) diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java index 373a28b4761b..2dd1849078e1 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java @@ -4,5 +4,5 @@ import org.baeldung.persistence.model.User; public interface UserRepository extends JpaRepository { - public User findByUsername(String username); + public User findByEmail(String email); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java index 33851c9fa5c6..0a803c251b1f 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java @@ -21,8 +21,8 @@ public class User { private String firstName; @Column(name = "lastName") private String lastName; - @Column(name = "username") - private String username; + @Column(name = "email") + private String email; @Column(name = "password") private String password; @@ -53,12 +53,12 @@ public void setLastName(String lastName) { this.lastName = lastName; } - public String getUsername() { - return username; + public String getEmail() { + return email; } - public void setUsername(String username) { - this.username = username; + public void setEmail(String email) { + this.email = email; } public String getPassword() { @@ -81,7 +81,7 @@ public void setRole(Role role) { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((username == null) ? 0 : username.hashCode()); + result = prime * result + ((email == null) ? 0 : email.hashCode()); return result; } @@ -94,7 +94,7 @@ public boolean equals(final Object obj) { if (getClass() != obj.getClass()) return false; final User user = (User) obj; - if (!username.equals(user.username)) + if (!email.equals(user.email)) return false; return true; } @@ -102,7 +102,7 @@ public boolean equals(final Object obj) { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]"); + builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[email").append(email).append("]"); return builder.toString(); } } \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UsernameValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java similarity index 83% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UsernameValidator.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java index 67a77538013e..19907ce50459 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UsernameValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java @@ -6,13 +6,13 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -public class UsernameValidator implements ConstraintValidator { +public class EmailValidator implements ConstraintValidator { private Pattern pattern; private Matcher matcher; private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; @Override - public void initialize(ValidUsername constraintAnnotation) { + public void initialize(ValidEmail constraintAnnotation) { } @Override diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java new file mode 100644 index 000000000000..f8e065187170 --- /dev/null +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java @@ -0,0 +1,9 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.model.User; + +public interface IUserService { + + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; + +} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java deleted file mode 100644 index 06730f1b65c8..000000000000 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.baeldung.persistence.service; - -import javax.transaction.Transactional; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.model.Role; -import org.baeldung.persistence.model.User; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -@Service -public class RepositoryService implements UserService { - @Autowired - private UserRepository repository; - @Autowired - private Environment env; - - @Autowired - public RepositoryService(UserRepository repository) { - this.repository = repository; - } - - @Transactional - @Override - public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { - if (emailExist(userAccountData.getUsername())) { - - throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getUsername()); - } - User user = new User(); - user.setFirstName(userAccountData.getFirstName()); - user.setLastName(userAccountData.getLastName()); - user.setPassword(userAccountData.getPassword()); - user.setUsername(userAccountData.getUsername()); - user.setRole(new Role(userAccountData.getRole(), user)); - return repository.save(user); - } - - private boolean emailExist(String email) { - User user = repository.findByUsername(email); - if (user != null) { - return true; - } - return false; - } -} diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java index bc2bd020c94f..61aff3156719 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -16,10 +16,18 @@ public class UserDto { @NotNull @NotEmpty private String matchingPassword; - @ValidUsername + @ValidEmail @NotNull @NotEmpty - private String username; + private String email; + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + private Integer role; public Integer getRole() { @@ -30,14 +38,6 @@ public void setRole(Integer role) { this.role = role; } - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - public String getFirstName() { return firstName; } @@ -71,7 +71,7 @@ public void setMatchingPassword(String matchingPassword) { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]").append("[password").append(password).append("]"); + builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[email").append(email).append("]").append("[password").append(password).append("]"); return builder.toString(); } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java index 44187e2c85de..1a083c557cb7 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -1,9 +1,39 @@ package org.baeldung.persistence.service; +import javax.transaction.Transactional; +import org.baeldung.persistence.dao.UserRepository; +import org.baeldung.persistence.model.Role; import org.baeldung.persistence.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; -public interface UserService { +@Service +public class UserService implements IUserService { + @Autowired + private UserRepository repository; + + @Transactional + @Override + public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { + if (emailExist(userAccountData.getEmail())) { - public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; + throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getEmail()); + } + User user = new User(); + user.setFirstName(userAccountData.getFirstName()); + user.setLastName(userAccountData.getLastName()); + user.setPassword(userAccountData.getPassword()); + user.setEmail(userAccountData.getEmail()); + //ROLE WILL ALWAYS BE USER. HARDCODING IT + user.setRole(new Role(Integer.valueOf(1),user)); + return repository.save(user); + } + private boolean emailExist(String email) { + User user = repository.findByEmail(email); + if (user != null) { + return true; + } + return false; + } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidUsername.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java similarity index 88% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidUsername.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java index 9aed81171391..3ad5558df2b3 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidUsername.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java @@ -12,9 +12,9 @@ @Target({ TYPE, FIELD, ANNOTATION_TYPE }) @Retention(RUNTIME) -@Constraint(validatedBy = UsernameValidator.class) +@Constraint(validatedBy = EmailValidator.class) @Documented -public @interface ValidUsername { +public @interface ValidEmail { String message() default "Invalid Email"; diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java index 464a747683ca..7ff77895193d 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -21,19 +21,20 @@ @Transactional public class MyUserDetailsService implements UserDetailsService { - private static final Logger LOGGER = LoggerFactory.getLogger(UserDetailsService.class); + private final Logger LOGGER = LoggerFactory.getLogger(getClass()); + @Autowired private UserRepository userRepository; - @Autowired - public MyUserDetailsService(UserRepository repository) { - this.userRepository = repository; - } + // @Autowired + // public MyUserDetailsService(UserRepository repository) { + // this.userRepository = repository; + // } - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { try { - LOGGER.debug("Loading user by username: {}", username); - User user = userRepository.findByUsername(username); + LOGGER.debug("Loading user by username: {}", email); + User user = userRepository.findByEmail(email); LOGGER.debug("Found user: {}", user); if (user == null) { // throw new UsernameNotFoundException("No user found with username: " + username); @@ -44,7 +45,7 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; - return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); + return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole())); } catch (Exception e) { throw new RuntimeException(e); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index 4dc7f039fecd..4c7a84ef8601 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -3,7 +3,7 @@ import java.util.Locale; import org.baeldung.persistence.service.PasswordMatchesValidator; -import org.baeldung.persistence.service.UsernameValidator; +import org.baeldung.persistence.service.EmailValidator; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -85,8 +85,8 @@ public MessageSource messageSource() { } @Bean - public UsernameValidator usernameValidator() { - UsernameValidator userNameValidator = new UsernameValidator(); + public EmailValidator usernameValidator() { + EmailValidator userNameValidator = new EmailValidator(); return userNameValidator; } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java index e41cb267831a..73732c7a2cdf 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -1,10 +1,11 @@ package org.baeldung.web.controller; import javax.validation.Valid; + import org.baeldung.persistence.model.User; import org.baeldung.persistence.service.EmailExistsException; import org.baeldung.persistence.service.UserDto; -import org.baeldung.persistence.service.UserService; +import org.baeldung.persistence.service.IUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,12 +24,12 @@ public class RegistrationController { private final Logger LOGGER = LoggerFactory.getLogger(getClass()); - private UserService service; + private IUserService service; @Autowired private MessageSource messages; @Autowired - public RegistrationController(UserService service) { + public RegistrationController(IUserService service) { this.service = service; } @@ -47,12 +48,20 @@ public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto u if (!result.hasErrors()) registered = createUserAccount(userAccountData, result); if (registered == null) { - result.rejectValue("username", "message.regError"); + result.rejectValue("email", "message.regError"); } if (result.hasErrors()) { return new ModelAndView("registration", "user", userAccountData); } else { + // Will show the success registration page--ORIGINAL return new ModelAndView("successRegister", "user", userAccountData); + + // Will redirect to login view (not in url as login.html) and user model can be accessed + // return new ModelAndView("login","user", userAccountData); + + + // Will redirect to login html but no model object---we send a success param to the login form + //return new ModelAndView("redirect:/login.html?success=true", "", null); } } diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-error-handling/src/main/resources/messages_en.properties index 0d4393fb5ece..b8ec5102fa2a 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_en.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_en.properties @@ -10,12 +10,22 @@ message.regError=An account for that username/email already exists. Please enter message.lastName=Last name is required message.firstName=First name required message.badEmail=Invalid email address -label.user.email=Email -label.user.firstName=First name -label.user.lastName=Last name -label.user.password=Password +label.user.email=Email: +label.user.firstName=First name: +label.user.lastName=Last name: +label.user.password=Password: +label.user.confirmPass=Confirm password +label.form.submit=Submit +label.form.title=Registration Form +label.form.loginLink=Back to login label.login=Login here -ValidUsername.user.username=Invalid Username (Email) +label.form.loginTitle=Login +label.form.loginEmail=Email +label.form.loginPass=Password +label.form.loginEnglish=English +label.form.loginSpanish=Spanish +label.form.loginSignUp=Sign up +ValidEmail.user.email=Invalid email address! UniqueUsername.user.username=An account with that username/email already exists NotNull.user.firstName=First name required NotEmpty.user.firstName=First name required @@ -28,4 +38,4 @@ NotEmpty.user.password=Password required NotNull.user.matchingPassword=Required NotEmpty.user.matchingPassword=Required PasswordMatches.user:Password does not match! -Email.user.username=Invalid Username (Email) \ No newline at end of file +Email.user.email=Invalid Username (Email) \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties index 2084b1466746..c28ee68c24e4 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties @@ -10,12 +10,22 @@ message.regError=Ya existe una cuenta con ese nombre de usuario. Ingrese un nomb message.lastName=Por favor ingrese su apellido message.firstName=Por favor ingrese su nombre message.badEmail=Direccion de correo no es valida -label.user.email=Email -label.user.firstName=Nombre -label.user.lastName=Apellido -label.user.password=Clave +label.user.email=Correo Electronico: +label.user.firstName=Nombre: +label.user.lastName=Apellido: +label.user.password=Contrasenia: +label.user.confirmPass=Confirme la contrasenia +label.form.submit=Enviar +label.form.title=Formulario de Registro label.login=Autehtifiquese aqui -ValidUsername.user.username=Email no es valido +label.form.loginTitle=Ingreso +label.form.loginLink=Regrese a autentificacion +label.form.loginEmail=Correo Electronico +label.form.loginPass=Contrasenia +label.form.loginEnglish=Ingles +label.form.loginSpanish=Espaniol +label.form.loginSignUp=Registrese +ValidEmail.user.email=Cuenta correo invlida! UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario NotNull.user.firstName=Por favor ingrese su nombre NotEmpty.user.firstName=Por favor ingrese su nombre @@ -24,8 +34,8 @@ NotEmpty.user.lastName=Por favor ingrese su apellido NotNull.user.username=Por favor ingrese su cuenta de email NotEmpty.user.username=Por favor ingrese su cuenta de email NotNull.user.password=Por favor ingrese su clave -NotEmpty.user.password=Por favor ingrese su clave +NotEmpty.user.password=Por favor ingrese su contraseña NotNull.user.matchingPassword=Campo obligatirio NotEmpty.user.matchingPassword=Campo obligatrio PasswordMatches.user:Las claves no coinciden! -Email.user.username=Email no es valido +Email.user.email=Email no es valido diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index 70e80d90230e..d584ff342fdc 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -28,12 +28,9 @@ class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" /> - + - \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp index 626554b4af43..ea196f011403 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -37,28 +37,28 @@ -

Login

- English | - Spanish +

+ | +
- + - + - +
User:
Password:
/>

Current Locale : ${pageContext.response.locale}
- ">Sign Up + "> \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp index ae9015947513..38eb4cf9ebe5 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp @@ -9,43 +9,42 @@ " rel="stylesheet"> -Registration +<spring:message code="label.form.title"></spring:message> -

This is the registration page

- +

+
- + - + - - - + + + - + - + - - +

- ">Back to Login + "> \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp index 323780263d45..d23a2e298fbf 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp @@ -13,9 +13,9 @@ Registration Success -

+
-

+ "> From 42d17c1c4dfd7904b52478ca6badadedda006e85 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 11 Sep 2014 18:38:42 +0300 Subject: [PATCH 631/796] gson cleanup work --- gson/.project | 2 +- .../serialization/GsonSerializationTest.java | 80 ---------------- ...ngFieldsNotMatchingCriteriaSerializer.java | 27 ++++++ .../test/GsonSerializationTest.java | 93 +++++++++++++++++++ 4 files changed, 121 insertions(+), 81 deletions(-) delete mode 100644 gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java create mode 100644 gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java diff --git a/gson/.project b/gson/.project index ea8ae1a67fa9..010b65738c16 100644 --- a/gson/.project +++ b/gson/.project @@ -1,6 +1,6 @@ - jackson + gson diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java deleted file mode 100644 index 93a44647e39f..000000000000 --- a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.baeldung.gson.serialization; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.Date; - -import org.junit.Test; - -import com.google.common.collect.Lists; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; - -public class GsonSerializationTest { - - @Test - public void givenCollection_whenSerializing_thenCorrect() { - final Collection sourceCollection = Lists.newArrayList(new SourceClass(1, "one"), new SourceClass(2, "two")); - final Type sourceCollectionType = new TypeToken>() { - }.getType(); - final String jsonCollection = new Gson().toJson(sourceCollection, sourceCollectionType); - - // test - final String estimatedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; - assertEquals(estimatedResult, jsonCollection); - } - - @Test - public void givenArrayOfObjects_whenSerializing_thenCorrect() { - final SourceClass[] sourceArray = { new SourceClass(1, "one"), new SourceClass(2, "two") }; - final String jsonString = new Gson().toJson(sourceArray); - - // test - final String estimatedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; - assertEquals(estimatedResult, jsonString); - } - - @Test - public void givenUsingCustomSerializer_whenChangingNameOfFieldOnSerializing_thenCorrect() { - final SourceClass sourceObject = new SourceClass(7, "seven"); - final GsonBuilder gsonBuildr = new GsonBuilder(); - gsonBuildr.registerTypeAdapter(SourceClass.class, new DifferentNameSerializer()); - final Gson gson = gsonBuildr.create(); - final String jsonString = gson.toJson(sourceObject); - - // test - final String estimatedResult = "{\"otherIntValue\":7,\"otherStringValue\":\"seven\"}"; - assertEquals(estimatedResult, jsonString); - } - - @Test - public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgnored() { - final SourceClass sourceObject = new SourceClass(7, "seven"); - final GsonBuilder gsonBuildr = new GsonBuilder(); - gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsSerializer()); - final Gson gson = gsonBuildr.create(); - final String jsonString = gson.toJson(sourceObject); - - // test - final String estimatedResult = "{\"intValue\":7}"; - assertEquals(estimatedResult, jsonString); - } - - @Test - public void givenDate_whenSerializing_thenCorrect() { - final Date sourceDate = new Date(1000000L); - final Gson gson = new Gson(); - final Type sourceDateType = new TypeToken() { - }.getType(); - final String jsonDate = gson.toJson(sourceDate, sourceDateType); - - // test - final String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; - assertTrue(jsonDate.equals(estimatedResult)); - } - -} \ No newline at end of file diff --git a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java new file mode 100644 index 000000000000..4a6c1a14d322 --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java @@ -0,0 +1,27 @@ +package org.baeldung.gson.serialization; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; + +public class IgnoringFieldsNotMatchingCriteriaSerializer implements JsonSerializer { + @Override + public JsonElement serialize(SourceClass src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject jObject = new JsonObject(); + + // Criteria: intValue >= 0 + if (src.getIntValue() >= 0) { + String intValue = "intValue"; + jObject.addProperty(intValue, src.getIntValue()); + } + + String stringValue = "stringValue"; + jObject.addProperty(stringValue, src.getStringValue()); + + return jObject; + } + +} diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java new file mode 100644 index 000000000000..a7ad7b67facf --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java @@ -0,0 +1,93 @@ +package org.baeldung.gson.serialization.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Date; + +import org.baeldung.gson.serialization.DifferentNameSerializer; +import org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer; +import org.baeldung.gson.serialization.IgnoringFieldsSerializer; +import org.baeldung.gson.serialization.SourceClass; +import org.junit.Test; + +import com.google.common.collect.Lists; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; + +public class GsonSerializationTest { + + @Test + public void givenArrayOfObjects_whenSerializing_thenCorrect() { + final SourceClass[] sourceArray = { new SourceClass(1, "one"), new SourceClass(2, "two") }; + final String jsonString = new Gson().toJson(sourceArray); + + // test + final String expectedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; + assertEquals(expectedResult, jsonString); + } + + @Test + public void givenCollection_whenSerializing_thenCorrect() { + final Collection sourceCollection = Lists.newArrayList(new SourceClass(1, "one"), new SourceClass(2, "two")); + final Type sourceCollectionType = new TypeToken>() { + }.getType(); + final String jsonCollection = new Gson().toJson(sourceCollection, sourceCollectionType); + + final String expectedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; + assertEquals(expectedResult, jsonCollection); + } + + @Test + public void givenUsingCustomSerializer_whenChangingNameOfFieldOnSerializing_thenCorrect() { + final SourceClass sourceObject = new SourceClass(7, "seven"); + final GsonBuilder gsonBuildr = new GsonBuilder(); + gsonBuildr.registerTypeAdapter(SourceClass.class, new DifferentNameSerializer()); + final String jsonString = gsonBuildr.create().toJson(sourceObject); + + final String expectedResult = "{\"otherIntValue\":7,\"otherStringValue\":\"seven\"}"; + assertEquals(expectedResult, jsonString); + } + + @Test + public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgnored() { + final SourceClass sourceObject = new SourceClass(7, "seven"); + final GsonBuilder gsonBuildr = new GsonBuilder(); + gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsSerializer()); + final String jsonString = gsonBuildr.create().toJson(sourceObject); + + final String expectedResult = "{\"intValue\":7}"; + assertEquals(expectedResult, jsonString); + } + + @Test + public void givenDate_whenSerializing_thenCorrect() { + Date sourceDate = new Date(1000000L); + Gson gson = new Gson(); + Type sourceDateType = new TypeToken() { + }.getType(); + String jsonDate = gson.toJson(sourceDate, sourceDateType); + // test + System.out.println("jsonDate:\n" + jsonDate); + String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; + assertTrue(jsonDate.equals(estimatedResult)); + } + + @Test + public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnoringIt() { + SourceClass sourceObject = new SourceClass(-1, "minus 1"); + GsonBuilder gsonBuildr = new GsonBuilder(); + gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer()); + Gson gson = gsonBuildr.create(); + Type sourceObjectType = new TypeToken() { + }.getType(); + String jsonString = gson.toJson(sourceObject, sourceObjectType); + // test + String estimatedResult = "{\"stringValue\":\"minus 1\"}"; + assertEquals(estimatedResult, jsonString); + } + +} \ No newline at end of file From ee27f3d75aa4299f26cc9d76de138e2094046f81 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 11 Sep 2014 18:41:00 +0300 Subject: [PATCH 632/796] small gson test changes --- .../serialization/test/GsonSerializationTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java index a7ad7b67facf..1c23a072f3f0 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java @@ -72,12 +72,12 @@ public void givenDate_whenSerializing_thenCorrect() { String jsonDate = gson.toJson(sourceDate, sourceDateType); // test System.out.println("jsonDate:\n" + jsonDate); - String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; - assertTrue(jsonDate.equals(estimatedResult)); + String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; + assertTrue(jsonDate.equals(expectedResult)); } @Test - public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnoringIt() { + public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored() { SourceClass sourceObject = new SourceClass(-1, "minus 1"); GsonBuilder gsonBuildr = new GsonBuilder(); gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer()); @@ -85,9 +85,9 @@ public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnorin Type sourceObjectType = new TypeToken() { }.getType(); String jsonString = gson.toJson(sourceObject, sourceObjectType); - // test - String estimatedResult = "{\"stringValue\":\"minus 1\"}"; - assertEquals(estimatedResult, jsonString); + + String expectedResult = "{\"stringValue\":\"minus 1\"}"; + assertEquals(expectedResult, jsonString); } } \ No newline at end of file From 2b879ce8c387a27db8ebdc0cde5fd45c65ff6856 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 11 Sep 2014 18:42:37 +0300 Subject: [PATCH 633/796] small testing cleaup --- .../test/GsonSerializationTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java index 1c23a072f3f0..fe19efdb45c9 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java @@ -65,29 +65,29 @@ public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgn @Test public void givenDate_whenSerializing_thenCorrect() { - Date sourceDate = new Date(1000000L); - Gson gson = new Gson(); - Type sourceDateType = new TypeToken() { + final Date sourceDate = new Date(1000000L); + final Gson gson = new Gson(); + final Type sourceDateType = new TypeToken() { }.getType(); String jsonDate = gson.toJson(sourceDate, sourceDateType); - // test + System.out.println("jsonDate:\n" + jsonDate); - String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; + final String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; assertTrue(jsonDate.equals(expectedResult)); } @Test public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored() { - SourceClass sourceObject = new SourceClass(-1, "minus 1"); - GsonBuilder gsonBuildr = new GsonBuilder(); + final SourceClass sourceObject = new SourceClass(-1, "minus 1"); + final GsonBuilder gsonBuildr = new GsonBuilder(); gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer()); - Gson gson = gsonBuildr.create(); - Type sourceObjectType = new TypeToken() { + final Gson gson = gsonBuildr.create(); + final Type sourceObjectType = new TypeToken() { }.getType(); String jsonString = gson.toJson(sourceObject, sourceObjectType); - - String expectedResult = "{\"stringValue\":\"minus 1\"}"; + + final String expectedResult = "{\"stringValue\":\"minus 1\"}"; assertEquals(expectedResult, jsonString); } - + } \ No newline at end of file From 782216f214f9c9cb5676ef1e71f04ca06d98e49d Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 11 Sep 2014 21:34:40 +0300 Subject: [PATCH 634/796] gson cleanup --- .../IgnoringFieldsSerializer.java | 1 - .../test/GsonSerializationTest.java | 32 +++++++++---------- .../org/baeldung/gson/GenericSourceClass.java | 10 ------ .../gson/GsonDeserializationUnitTest.java | 32 ------------------- 4 files changed, 15 insertions(+), 60 deletions(-) delete mode 100644 jackson/src/test/java/org/baeldung/gson/GenericSourceClass.java delete mode 100644 jackson/src/test/java/org/baeldung/gson/GsonDeserializationUnitTest.java diff --git a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java index c8fb95028cac..bd1928cb18b5 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java @@ -16,5 +16,4 @@ public JsonElement serialize(final SourceClass src, final Type typeOfSrc, final return jObject; } - } diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java index fe19efdb45c9..3e957ea6f86d 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java @@ -33,9 +33,7 @@ public void givenArrayOfObjects_whenSerializing_thenCorrect() { @Test public void givenCollection_whenSerializing_thenCorrect() { final Collection sourceCollection = Lists.newArrayList(new SourceClass(1, "one"), new SourceClass(2, "two")); - final Type sourceCollectionType = new TypeToken>() { - }.getType(); - final String jsonCollection = new Gson().toJson(sourceCollection, sourceCollectionType); + final String jsonCollection = new Gson().toJson(sourceCollection); final String expectedResult = "[{\"intValue\":1,\"stringValue\":\"one\"},{\"intValue\":2,\"stringValue\":\"two\"}]"; assertEquals(expectedResult, jsonCollection); @@ -63,19 +61,6 @@ public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgn assertEquals(expectedResult, jsonString); } - @Test - public void givenDate_whenSerializing_thenCorrect() { - final Date sourceDate = new Date(1000000L); - final Gson gson = new Gson(); - final Type sourceDateType = new TypeToken() { - }.getType(); - String jsonDate = gson.toJson(sourceDate, sourceDateType); - - System.out.println("jsonDate:\n" + jsonDate); - final String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; - assertTrue(jsonDate.equals(expectedResult)); - } - @Test public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored() { final SourceClass sourceObject = new SourceClass(-1, "minus 1"); @@ -84,10 +69,23 @@ public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored final Gson gson = gsonBuildr.create(); final Type sourceObjectType = new TypeToken() { }.getType(); - String jsonString = gson.toJson(sourceObject, sourceObjectType); + final String jsonString = gson.toJson(sourceObject, sourceObjectType); final String expectedResult = "{\"stringValue\":\"minus 1\"}"; assertEquals(expectedResult, jsonString); } + @Test + public void givenDate_whenSerializing_thenCorrect() { + final Date sourceDate = new Date(1000000L); + final Gson gson = new Gson(); + final Type sourceDateType = new TypeToken() { + }.getType(); + final String jsonDate = gson.toJson(sourceDate, sourceDateType); + + System.out.println("jsonDate:\n" + jsonDate); + final String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; + assertTrue(jsonDate.equals(expectedResult)); + } + } \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/gson/GenericSourceClass.java b/jackson/src/test/java/org/baeldung/gson/GenericSourceClass.java deleted file mode 100644 index 8e3a8d749b48..000000000000 --- a/jackson/src/test/java/org/baeldung/gson/GenericSourceClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.baeldung.gson; - -public class GenericSourceClass { - int intField; - - public GenericSourceClass(final int i) { - intField = i; - } - -} \ No newline at end of file diff --git a/jackson/src/test/java/org/baeldung/gson/GsonDeserializationUnitTest.java b/jackson/src/test/java/org/baeldung/gson/GsonDeserializationUnitTest.java deleted file mode 100644 index dabc861ce112..000000000000 --- a/jackson/src/test/java/org/baeldung/gson/GsonDeserializationUnitTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.gson; - -import org.junit.Before; -import org.junit.Test; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -public class GsonDeserializationUnitTest { - - private Gson gson; - - @Before - public final void before() { - gson = new Gson(); - } - - // tests - - @Test - public void givenUsingGson_whenDeserializingGeneric_thenCorrect() { - final java.lang.reflect.Type genericSourceClassType = new TypeToken() { - }.getType(); - final GenericSourceClass sourceObject = new GenericSourceClass(1); - final String serializedSourceObject = gson.toJson(sourceObject, genericSourceClassType); - - final GenericSourceClass targetObject = gson.fromJson(serializedSourceObject, genericSourceClassType); - - System.out.println(targetObject); - } - -} From 6584041f8d8f8f691b3d585f969ec33bf4dfaa62 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 12 Sep 2014 16:25:31 +0300 Subject: [PATCH 635/796] date work for gson --- gson/pom.xml | 8 +++++++- .../serialization/test/GsonSerializationTest.java | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gson/pom.xml b/gson/pom.xml index 9c041f0cc1fe..d512842eb12a 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -11,10 +11,16 @@ + + joda-time + joda-time + 2.4 + + com.google.guava guava - 17.0 + 18.0 commons-io diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java index 3e957ea6f86d..84e550f0bd43 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationTest.java @@ -4,13 +4,16 @@ import static org.junit.Assert.assertTrue; import java.lang.reflect.Type; +import java.util.Calendar; import java.util.Collection; import java.util.Date; +import java.util.GregorianCalendar; import org.baeldung.gson.serialization.DifferentNameSerializer; import org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer; import org.baeldung.gson.serialization.IgnoringFieldsSerializer; import org.baeldung.gson.serialization.SourceClass; +import org.joda.time.DateTime; import org.junit.Test; import com.google.common.collect.Lists; @@ -77,15 +80,16 @@ public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored @Test public void givenDate_whenSerializing_thenCorrect() { - final Date sourceDate = new Date(1000000L); + Date sourceDate = new DateTime().withYear(2000).withMonthOfYear(1).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).toDate(); + final Gson gson = new Gson(); - final Type sourceDateType = new TypeToken() { + Type sourceDateType = new TypeToken() { }.getType(); - final String jsonDate = gson.toJson(sourceDate, sourceDateType); + String jsonDate = gson.toJson(sourceDate, sourceDateType); System.out.println("jsonDate:\n" + jsonDate); - final String expectedResult = "\"Jan 1, 1970 3:16:40 AM\""; - assertTrue(jsonDate.equals(expectedResult)); + String expectedResult = "\"Jan 1, 2000 12:00:00 AM\""; + assertEquals(expectedResult, jsonDate); } } \ No newline at end of file From 19131413c56e471f12ce3742447da480e1f53775 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 13 Sep 2014 19:15:25 +0300 Subject: [PATCH 636/796] work on maven upgrades --- core-java/pom.xml | 6 +++--- experiments/pom.xml | 6 +++--- gson/pom.xml | 6 +++--- guava/pom.xml | 6 +++--- httpclient/pom.xml | 6 +++--- jackson/pom.xml | 8 ++++---- mockito/pom.xml | 6 +++--- rest-testing/pom.xml | 4 ++-- sandbox/pom.xml | 4 ++-- spring-all/pom.xml | 6 +++--- spring-exceptions/pom.xml | 6 +++--- spring-hibernate3/pom.xml | 6 +++--- spring-hibernate4/pom.xml | 6 +++--- spring-jpa/pom.xml | 6 +++--- spring-mvc-java/pom.xml | 6 +++--- spring-mvc-no-xml/pom.xml | 4 ++-- spring-mvc-xml/pom.xml | 4 ++-- spring-rest/pom.xml | 8 ++++---- spring-security-basic-auth/pom.xml | 6 +++--- spring-security-login-error-handling/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 6 +++--- spring-security-mvc-digest-auth/pom.xml | 6 +++--- spring-security-mvc-login/pom.xml | 6 +++--- spring-security-mvc-persisted-remember-me/pom.xml | 6 +++--- spring-security-mvc-session/pom.xml | 6 +++--- spring-security-rest-basic-auth/pom.xml | 6 +++--- spring-security-rest-custom/pom.xml | 6 +++--- spring-security-rest-digest-auth/pom.xml | 6 +++--- spring-security-rest-full/pom.xml | 8 ++++---- spring-security-rest/pom.xml | 6 +++--- 30 files changed, 87 insertions(+), 87 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 131a328834b6..de3631d7575c 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -145,7 +145,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -153,7 +153,7 @@ 5.1.32 - 2.4.1 + 2.4.2 1.7.7 @@ -174,7 +174,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/experiments/pom.xml b/experiments/pom.xml index b7794ef2f46a..4ca03b75e180 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -255,7 +255,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -270,7 +270,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -281,7 +281,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/gson/pom.xml b/gson/pom.xml index d512842eb12a..8b86c587605c 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -114,7 +114,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -132,7 +132,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -143,7 +143,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/guava/pom.xml b/guava/pom.xml index 0297b706b6fb..ad82de3d678a 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,7 +94,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -109,7 +109,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -120,7 +120,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 529fdb2c38ea..0e86cd0cd2af 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -149,7 +149,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -164,7 +164,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -175,7 +175,7 @@ 4.3.2 4.3.4 - 2.3.2 + 2.3.3 3.1 diff --git a/jackson/pom.xml b/jackson/pom.xml index 7d7b6421a470..c38eafda7d98 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -114,7 +114,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -122,7 +122,7 @@ 5.1.32 - 2.4.1 + 2.4.2 1.7.7 @@ -132,7 +132,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -143,7 +143,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/mockito/pom.xml b/mockito/pom.xml index 3ad055690a79..e350e0fe70d2 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,7 +89,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -104,7 +104,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -115,7 +115,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index d55d16302a5c..3f3d9a2fea14 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -141,7 +141,7 @@ 4.0.3.RELEASE - 2.4.1 + 2.4.2 1.7.7 @@ -162,7 +162,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 57734d73932f..012016008d1a 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -141,7 +141,7 @@ 5.1.29 - 2.4.1 + 2.4.2 1.7.7 @@ -162,7 +162,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 07c842aaad1b..e7350e46128b 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,7 +192,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE 3.18.1-GA 1.2 @@ -209,7 +209,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -220,7 +220,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 1c0c06062fc2..dbe6a13d709b 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,7 +204,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE 3.18.1-GA 1.2 @@ -222,7 +222,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -233,7 +233,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 1.8.9 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 23ab319e24d1..020140d902dd 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -163,7 +163,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE 3.18.1-GA @@ -180,7 +180,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -191,7 +191,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 47c5c13d7e11..387ffd3ff9fe 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -170,7 +170,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE 3.18.1-GA @@ -187,7 +187,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -198,7 +198,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index b2d3525dcc93..972f49ec1db8 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -165,7 +165,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -180,7 +180,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -191,7 +191,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index d9c27481d438..69d94ec34d4b 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,7 +141,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -156,7 +156,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -167,7 +167,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 264879437c92..5b906006c80a 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 1.7.7 @@ -159,7 +159,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index df23cf654c4b..01eef969d40a 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -147,7 +147,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 1.7.7 @@ -161,7 +161,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index f59a8128da2d..de9dbfc3e815 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,7 +202,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -211,13 +211,13 @@ - 2.4.1 + 2.4.2 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -228,7 +228,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 1.7.7 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 6ce841c95496..20403c12d049 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -226,7 +226,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -241,7 +241,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -252,7 +252,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index a98aceed2e3e..68f217afc5e1 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -137,6 +137,6 @@ 1.4.5.RELEASE - 17.0 + 18.0 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index b8e7f4b5a8a3..1c064d93bdc6 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -231,7 +231,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -246,7 +246,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -257,7 +257,7 @@ 4.3.5 4.3.2 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index cf6a001b126a..162d0f61ee7b 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -226,7 +226,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -241,7 +241,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -252,7 +252,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index fa16d2c393b2..9e5286a5c73d 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -223,7 +223,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -238,7 +238,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -249,7 +249,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml index caf00b6d9868..843cf7789ac7 100644 --- a/spring-security-mvc-persisted-remember-me/pom.xml +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -260,7 +260,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -275,7 +275,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -286,7 +286,7 @@ 4.3.5 4.3.2 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 95dfcf9fdff1..26d4932c8ca0 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -231,7 +231,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -246,7 +246,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -257,7 +257,7 @@ 4.3.5 4.3.2 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index fc273049ba1d..a4eb760874a2 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,7 +287,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -306,7 +306,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -314,7 +314,7 @@ 4.11 1.9.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 80a37c908035..15f50841bdfe 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -251,7 +251,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -266,7 +266,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -277,7 +277,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 6a8124879cc2..f119377c5a99 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,7 +275,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -297,7 +297,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -305,7 +305,7 @@ 4.11 1.9.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index d76b90b4f29e..0431d94ad533 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -371,7 +371,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -381,7 +381,7 @@ - 2.4.1 + 2.4.2 1.7.7 @@ -391,7 +391,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -402,7 +402,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index b85fd3565aba..7d92c99e300e 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -238,7 +238,7 @@ - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.5.RELEASE @@ -253,7 +253,7 @@ 5.1.2.Final - 17.0 + 18.0 3.3.2 @@ -264,7 +264,7 @@ 4.3.2 4.3.5 - 2.3.2 + 2.3.3 3.1 From 7da44d2140654a0360a9ea5e112d966c70b3629a Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Sep 2014 00:53:34 +0300 Subject: [PATCH 637/796] minor java testign work --- .../java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index 7247ab1eb93c..e587bfcf186f 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -142,7 +142,7 @@ public final void givenUsingGuava_whenConvertingAnInputStreamToAByteArray_thenCo @Test public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { - final ByteArrayInputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); final byte[] targetArray = IOUtils.toByteArray(initialStream); } From 1e36d212d1d843da8478e532997b8d44797791e8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Sep 2014 14:26:17 +0300 Subject: [PATCH 638/796] spring updates --- core-java/src/main/resources/targetFile.tmp | 2 ++ core-java/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- gson/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- guava/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- jackson/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- mockito/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- rest-testing/pom.xml | 10 +++++----- rest-testing/src/main/webapp/WEB-INF/api-servlet.xml | 2 +- spring-all/src/main/resources/configForProperties.xml | 6 +++--- .../src/main/resources/configForPropertiesOne.xml | 6 +++--- .../src/main/resources/configForPropertiesTwo.xml | 6 +++--- spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../main/resources/beancreationexception_cause4.xml | 6 +++--- .../main/resources/beancreationexception_cause6.xml | 6 +++--- .../main/resources/beancreationexception_cause7.xml | 6 +++--- .../main/resources/beancreationexception_cause9.xml | 6 +++--- .../src/main/resources/configForProperties.xml | 6 +++--- .../src/main/resources/configForPropertiesOne.xml | 6 +++--- .../src/main/resources/configForPropertiesTwo.xml | 6 +++--- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/persistenceConfig.xml | 4 ++-- .../src/main/resources/hibernate4Config.xml | 4 ++-- .../src/main/resources/webSecurityConfig.xml | 2 +- spring-jpa/src/main/resources/jpaConfig.xml | 6 +++--- spring-jpa/src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- spring-mvc-xml/src/main/resources/webMvcConfig.xml | 6 +++--- spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 6 +++--- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/prop.xml | 4 ++-- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/springDataPersistenceConfig.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/api-servlet.xml | 2 +- 53 files changed, 87 insertions(+), 85 deletions(-) create mode 100644 core-java/src/main/resources/targetFile.tmp diff --git a/core-java/src/main/resources/targetFile.tmp b/core-java/src/main/resources/targetFile.tmp new file mode 100644 index 000000000000..20f137b41622 --- /dev/null +++ b/core-java/src/main/resources/targetFile.tmp @@ -0,0 +1,2 @@ +line 1 +a second line \ No newline at end of file diff --git a/core-java/src/main/webapp/WEB-INF/api-servlet.xml b/core-java/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/core-java/src/main/webapp/WEB-INF/api-servlet.xml +++ b/core-java/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/gson/src/main/webapp/WEB-INF/api-servlet.xml b/gson/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/gson/src/main/webapp/WEB-INF/api-servlet.xml +++ b/gson/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/guava/src/main/webapp/WEB-INF/api-servlet.xml b/guava/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/guava/src/main/webapp/WEB-INF/api-servlet.xml +++ b/guava/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/jackson/src/main/webapp/WEB-INF/api-servlet.xml b/jackson/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/jackson/src/main/webapp/WEB-INF/api-servlet.xml +++ b/jackson/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/mockito/src/main/webapp/WEB-INF/api-servlet.xml b/mockito/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/mockito/src/main/webapp/WEB-INF/api-servlet.xml +++ b/mockito/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 3f3d9a2fea14..866428f4aa97 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -138,7 +138,7 @@ - 4.0.3.RELEASE + 4.1.0.RELEASE 2.4.2 @@ -151,8 +151,8 @@ 5.1.2.Final - 16.0.1 - 3.3 + 18.0 + 3.3.2 1.3 @@ -167,9 +167,9 @@ 3.1 2.4 - 2.16 + 2.17 2.6 - 1.4.7 + 1.4.9 diff --git a/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml b/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml +++ b/rest-testing/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-all/src/main/resources/configForProperties.xml b/spring-all/src/main/resources/configForProperties.xml index ca7e269c67e0..3d3331c1d4c8 100644 --- a/spring-all/src/main/resources/configForProperties.xml +++ b/spring-all/src/main/resources/configForProperties.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-all/src/main/resources/configForPropertiesOne.xml b/spring-all/src/main/resources/configForPropertiesOne.xml index fc20d9a99a23..7652894f6c8f 100644 --- a/spring-all/src/main/resources/configForPropertiesOne.xml +++ b/spring-all/src/main/resources/configForPropertiesOne.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-all/src/main/resources/configForPropertiesTwo.xml b/spring-all/src/main/resources/configForPropertiesTwo.xml index 25983530ad40..edeb41a463a9 100644 --- a/spring-all/src/main/resources/configForPropertiesTwo.xml +++ b/spring-all/src/main/resources/configForPropertiesTwo.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-all/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml index 67c0ffca0d0d..6569788db618 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml index 6510edd176a8..4600a0ed5507 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml index e04c096678cc..b11a35442abe 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml index 59e30c3ede2b..7585e6c38a45 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/configForProperties.xml b/spring-exceptions/src/main/resources/configForProperties.xml index ca7e269c67e0..3d3331c1d4c8 100644 --- a/spring-exceptions/src/main/resources/configForProperties.xml +++ b/spring-exceptions/src/main/resources/configForProperties.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/configForPropertiesOne.xml b/spring-exceptions/src/main/resources/configForPropertiesOne.xml index fc20d9a99a23..7652894f6c8f 100644 --- a/spring-exceptions/src/main/resources/configForPropertiesOne.xml +++ b/spring-exceptions/src/main/resources/configForPropertiesOne.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/resources/configForPropertiesTwo.xml b/spring-exceptions/src/main/resources/configForPropertiesTwo.xml index 25983530ad40..edeb41a463a9 100644 --- a/spring-exceptions/src/main/resources/configForPropertiesTwo.xml +++ b/spring-exceptions/src/main/resources/configForPropertiesTwo.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-exceptions/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-hibernate3/src/main/resources/persistenceConfig.xml b/spring-hibernate3/src/main/resources/persistenceConfig.xml index f05f05eb1f94..abb0982a0477 100644 --- a/spring-hibernate3/src/main/resources/persistenceConfig.xml +++ b/spring-hibernate3/src/main/resources/persistenceConfig.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml index bef5a012be61..530e816bcf6c 100644 --- a/spring-hibernate4/src/main/resources/hibernate4Config.xml +++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/spring-hibernate4/src/main/resources/webSecurityConfig.xml index 35dcb9c1ef53..8866255479f9 100644 --- a/spring-hibernate4/src/main/resources/webSecurityConfig.xml +++ b/spring-hibernate4/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-jpa/src/main/resources/jpaConfig.xml b/spring-jpa/src/main/resources/jpaConfig.xml index a291786a5ce1..8b9c4efff1e7 100644 --- a/spring-jpa/src/main/resources/jpaConfig.xml +++ b/spring-jpa/src/main/resources/jpaConfig.xml @@ -2,9 +2,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-jpa/src/main/resources/webSecurityConfig.xml b/spring-jpa/src/main/resources/webSecurityConfig.xml index 35dcb9c1ef53..8866255479f9 100644 --- a/spring-jpa/src/main/resources/webSecurityConfig.xml +++ b/spring-jpa/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml index 35dcb9c1ef53..8866255479f9 100644 --- a/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml +++ b/spring-mvc-no-xml/src/main/resources/webSecurityConfig.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-no-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-mvc-xml/src/main/resources/webMvcConfig.xml index 278f6c553322..e249425447e9 100644 --- a/spring-mvc-xml/src/main/resources/webMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/webMvcConfig.xml @@ -4,11 +4,11 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.2.xsd + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.2.xsd + http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/mvc - http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> + http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd"> diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index d584ff342fdc..f02290fc2c7b 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml index 94bd63e068a3..8b81b56aa4af 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -2,6 +2,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index 0d87cc747e69..203f1c6a0bf3 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml index c8fb708c0b59..641a8b49dd3c 100644 --- a/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-digest-auth/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-digest-auth/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml index ea424e5e7887..5bc330d0be07 100644 --- a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml index 77e907b44e4c..0fa077db00fb 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml @@ -8,10 +8,10 @@ xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd - http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd"> diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index 22409c67ee16..b1f4674e1e1b 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml index a0f45d48f25b..cc8428b16297 100644 --- a/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-basic-auth/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-basic-auth/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-rest-custom/src/main/resources/prop.xml b/spring-security-rest-custom/src/main/resources/prop.xml index 4c11f2154cce..75e386894efb 100644 --- a/spring-security-rest-custom/src/main/resources/prop.xml +++ b/spring-security-rest-custom/src/main/resources/prop.xml @@ -4,9 +4,9 @@ xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-4.0.xsd"> + http://www.springframework.org/schema/context/spring-context-4.1.xsd"> diff --git a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml index db4f4051031d..314684e96ca1 100644 --- a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 802167c3ebad..9e63a24b796c 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-digest-auth/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml index f9116a31abc1..8b88167b56f1 100644 --- a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml +++ b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml @@ -1,7 +1,7 @@ diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index b159881360bd..f5d7b9e16a6a 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest-full/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index cff7c1cc0729..28fc4ffe1c84 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> diff --git a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml index a675fc6d954f..4c74be891219 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" > \ No newline at end of file From 71ffd8fb58580a9378cdeca642687fe0e6d94904 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 15 Sep 2014 14:35:41 +0300 Subject: [PATCH 639/796] cleanup work --- bin/.springBeans | 15 - bin/pom.xml | 179 ----------- bin/src/main/resources/logback.xml | 20 -- bin/src/main/resources/messages_en.properties | 9 - .../main/resources/messages_es_ES.properties | 9 - bin/src/main/resources/webSecurityConfig.xml | 36 --- bin/src/main/webapp/WEB-INF/mvc-servlet.xml | 10 - bin/src/main/webapp/WEB-INF/view/admin.jsp | 23 -- bin/src/main/webapp/WEB-INF/view/console.jsp | 23 -- bin/src/main/webapp/WEB-INF/view/home.jsp | 13 - bin/src/main/webapp/WEB-INF/view/homepage.jsp | 28 -- .../webapp/WEB-INF/view/invalidSession.jsp | 12 - bin/src/main/webapp/WEB-INF/view/login.jsp | 79 ----- bin/src/main/webapp/WEB-INF/view/logout.jsp | 24 -- .../main/webapp/WEB-INF/view/registration.jsp | 25 -- bin/src/main/webapp/WEB-INF/web.xml | 41 --- .../src/main/webapp/WEB-INF/api-servlet.xml | 6 - core-java-8/src/main/webapp/WEB-INF/web.xml | 42 --- experiments/.classpath | 37 --- ...e.wst.jsdt.core.javascriptValidator.launch | 7 - experiments/.gitignore | 13 - experiments/.project | 42 --- experiments/.settings/.jsdtscope | 5 - .../.settings/org.eclipse.jdt.core.prefs | 95 ------ .../.settings/org.eclipse.jdt.ui.prefs | 55 ---- .../.settings/org.eclipse.m2e.core.prefs | 4 - .../.settings/org.eclipse.m2e.wtp.prefs | 2 - .../org.eclipse.wst.common.component | 10 - ....eclipse.wst.common.project.facet.core.xml | 5 - ...rg.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .../org.eclipse.wst.validation.prefs | 15 - .../org.eclipse.wst.ws.service.policy.prefs | 2 - experiments/.springBeans | 14 - experiments/README.md | 7 - experiments/pom.xml | 295 ------------------ experiments/src/main/resources/logback.xml | 20 -- .../src/main/webapp/WEB-INF/api-servlet.xml | 6 - experiments/src/main/webapp/WEB-INF/web.xml | 50 --- .../java/org/baeldung/live/CrawlLiveTest.java | 131 -------- experiments/src/test/resources/.gitignore | 13 - starting/spring-jpa/.classpath | 37 --- starting/spring-jpa/.gitignore | 13 - starting/spring-jpa/.project | 43 --- starting/spring-jpa/.settings/.jsdtscope | 12 - .../.settings/org.eclipse.jdt.core.prefs | 95 ------ .../.settings/org.eclipse.jdt.ui.prefs | 55 ---- .../.settings/org.eclipse.m2e.core.prefs | 4 - .../.settings/org.eclipse.m2e.wtp.prefs | 2 - .../org.eclipse.wst.common.component | 10 - ....eclipse.wst.common.project.facet.core.xml | 6 - ...rg.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .../org.eclipse.wst.validation.prefs | 15 - .../org.eclipse.wst.ws.service.policy.prefs | 2 - starting/spring-jpa/.springBeans | 14 - starting/spring-jpa/README.md | 8 - starting/spring-jpa/pom.xml | 215 ------------- starting/spring-jpa/src/main/java/.gitignore | 13 - .../src/main/resources/jpaConfig.xml | 43 --- .../spring-jpa/src/main/resources/logback.xml | 20 -- .../resources/persistence-mysql.properties | 10 - .../src/main/resources/webSecurityConfig.xml | 36 --- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 6 - .../src/main/webapp/WEB-INF/view/sample.jsp | 7 - .../src/main/webapp/WEB-INF/web.xml | 21 -- starting/spring-jpa/src/test/java/.gitignore | 13 - .../spring-jpa/src/test/resources/.gitignore | 13 - 68 files changed, 2139 deletions(-) delete mode 100644 bin/.springBeans delete mode 100644 bin/pom.xml delete mode 100644 bin/src/main/resources/logback.xml delete mode 100644 bin/src/main/resources/messages_en.properties delete mode 100644 bin/src/main/resources/messages_es_ES.properties delete mode 100644 bin/src/main/resources/webSecurityConfig.xml delete mode 100644 bin/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 bin/src/main/webapp/WEB-INF/view/admin.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/console.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/home.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/homepage.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/invalidSession.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/login.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/logout.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/view/registration.jsp delete mode 100644 bin/src/main/webapp/WEB-INF/web.xml delete mode 100644 core-java-8/src/main/webapp/WEB-INF/api-servlet.xml delete mode 100644 core-java-8/src/main/webapp/WEB-INF/web.xml delete mode 100644 experiments/.classpath delete mode 100644 experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch delete mode 100644 experiments/.gitignore delete mode 100644 experiments/.project delete mode 100644 experiments/.settings/.jsdtscope delete mode 100644 experiments/.settings/org.eclipse.jdt.core.prefs delete mode 100644 experiments/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 experiments/.settings/org.eclipse.m2e.core.prefs delete mode 100644 experiments/.settings/org.eclipse.m2e.wtp.prefs delete mode 100644 experiments/.settings/org.eclipse.wst.common.component delete mode 100644 experiments/.settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 experiments/.settings/org.eclipse.wst.validation.prefs delete mode 100644 experiments/.settings/org.eclipse.wst.ws.service.policy.prefs delete mode 100644 experiments/.springBeans delete mode 100644 experiments/README.md delete mode 100644 experiments/pom.xml delete mode 100644 experiments/src/main/resources/logback.xml delete mode 100644 experiments/src/main/webapp/WEB-INF/api-servlet.xml delete mode 100644 experiments/src/main/webapp/WEB-INF/web.xml delete mode 100644 experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java delete mode 100644 experiments/src/test/resources/.gitignore delete mode 100644 starting/spring-jpa/.classpath delete mode 100644 starting/spring-jpa/.gitignore delete mode 100644 starting/spring-jpa/.project delete mode 100644 starting/spring-jpa/.settings/.jsdtscope delete mode 100644 starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs delete mode 100644 starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs delete mode 100644 starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.common.component delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs delete mode 100644 starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs delete mode 100644 starting/spring-jpa/.springBeans delete mode 100644 starting/spring-jpa/README.md delete mode 100644 starting/spring-jpa/pom.xml delete mode 100644 starting/spring-jpa/src/main/java/.gitignore delete mode 100644 starting/spring-jpa/src/main/resources/jpaConfig.xml delete mode 100644 starting/spring-jpa/src/main/resources/logback.xml delete mode 100644 starting/spring-jpa/src/main/resources/persistence-mysql.properties delete mode 100644 starting/spring-jpa/src/main/resources/webSecurityConfig.xml delete mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml delete mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp delete mode 100644 starting/spring-jpa/src/main/webapp/WEB-INF/web.xml delete mode 100644 starting/spring-jpa/src/test/java/.gitignore delete mode 100644 starting/spring-jpa/src/test/resources/.gitignore diff --git a/bin/.springBeans b/bin/.springBeans deleted file mode 100644 index 8096aa036b39..000000000000 --- a/bin/.springBeans +++ /dev/null @@ -1,15 +0,0 @@ - - - 1 - - - - - - - - - - - - diff --git a/bin/pom.xml b/bin/pom.xml deleted file mode 100644 index 413dbd2c972b..000000000000 --- a/bin/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - 4.0.0 - org.baeldung - spring-security-login-error-handling - spring-security-login-error-handling - war - 1.0.0-BUILD-SNAPSHOT - - - org.springframework.boot - spring-boot-starter-parent - 1.1.4.RELEASE - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context - - - - commons-logging - commons-logging - - - - - org.springframework - spring-core - - - org.springframework - spring-webmvc - - - org.springframework - spring-jdbc - - - org.springframework - spring-beans - - - org.springframework - spring-aop - - - org.springframework - spring-tx - - - org.springframework - spring-expression - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.springframework.security - spring-security-config - runtime - - - - - org.aspectj - aspectjrt - - - - - org.hibernate - hibernate-validator - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - org.slf4j - jcl-over-slf4j - - - - org.slf4j - log4j-over-slf4j - - - - - javax.inject - javax.inject - 1 - - - - - javax.servlet - javax.servlet-api - - - javax.servlet.jsp - jsp-api - 2.1 - provided - - - javax.servlet - jstl - - - - - org.springframework.security - spring-security-taglibs - - - - - junit - junit - test - - - - - - spring-security-login-and-registration - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-war-plugin - - - - - 1.7 - 3.1.1.RELEASE - 3.2.4.RELEASE - 1.6.10 - - - 1.7.6 - 1.1.1 - - - - diff --git a/bin/src/main/resources/logback.xml b/bin/src/main/resources/logback.xml deleted file mode 100644 index 1146dade632e..000000000000 --- a/bin/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bin/src/main/resources/messages_en.properties b/bin/src/main/resources/messages_en.properties deleted file mode 100644 index 3e05a6b76a3b..000000000000 --- a/bin/src/main/resources/messages_en.properties +++ /dev/null @@ -1,9 +0,0 @@ -message.username=Username required -message.password=Password required -message.unauth=Unauthorized Access !! -message.badCredentials=Invalid Username or Password -message.sessionExpired=Session Timed Out -message.logoutError=Sorry, error logging out -message.logoutSucc=You logged out successfully -message.regSucc=You registrated correctly, please log in -message.regError=There was a registration error please go back to registration \ No newline at end of file diff --git a/bin/src/main/resources/messages_es_ES.properties b/bin/src/main/resources/messages_es_ES.properties deleted file mode 100644 index 842a899e4316..000000000000 --- a/bin/src/main/resources/messages_es_ES.properties +++ /dev/null @@ -1,9 +0,0 @@ -message.username=Por favor ingrese el nombre de usuario -message.password=Por favor ingrese una clave -message.unauth=Acceso denegado !! -message.badCredentials=Usuario o clave invalida -message.sessionExpired=La sesion expiro -message.logoutError=Lo sentimos, hubo problemas en logout -message.logoutSucc=Logout con exito -message.regSucc=Se registro correctamente, por favor ingrese -message.regError=Hubo un error, por favor vuelva a registrarse \ No newline at end of file diff --git a/bin/src/main/resources/webSecurityConfig.xml b/bin/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 46550f03da76..000000000000 --- a/bin/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/mvc-servlet.xml b/bin/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index b885d2c10aef..000000000000 --- a/bin/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/admin.jsp b/bin/src/main/webapp/WEB-INF/view/admin.jsp deleted file mode 100644 index 12f9f7aba986..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/admin.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - -

Hello Admin

-
- - ">Logout - ">Home - - - - diff --git a/bin/src/main/webapp/WEB-INF/view/console.jsp b/bin/src/main/webapp/WEB-INF/view/console.jsp deleted file mode 100644 index 05a930731be4..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/console.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - -

This is the landing page for the admin

- - - This text is only visible to a user -
-
- - - This text is only visible to an admin -
-
- - ">Logout - ">Administrator Page - - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/home.jsp b/bin/src/main/webapp/WEB-INF/view/home.jsp deleted file mode 100644 index fe6e572b99f9..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/home.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ page session="true" %> - - - Home - - -

- Welcome back home! -

- - - diff --git a/bin/src/main/webapp/WEB-INF/view/homepage.jsp b/bin/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index fab96383df5d..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,28 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> -<%@ page session="true" %> - - - - - -

This is the homepage for the user

- - - This text is only visible to a user -
-
- - - This text is only visible to an admin -
-
- - ">Logout - ">Home - ">Administrator Page - - - - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp b/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp deleted file mode 100644 index 175c49811730..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/invalidSession.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - Home - - -

- -

- - - diff --git a/bin/src/main/webapp/WEB-INF/view/login.jsp b/bin/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 815c6ca891d5..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,79 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="false"%> - -
- -
-
- -
- -
-
- - -
- -
- Register -
- - - - - - - - - -

Login

- English | - Spanish -
- - - - - - - - - - - - - -
User:
Password:
- -
-
Current Locale : ${pageContext.response.locale} - - ">Home - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/logout.jsp b/bin/src/main/webapp/WEB-INF/view/logout.jsp deleted file mode 100644 index e8618b74e3aa..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/logout.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - -
- -
-
- -
- -
-
- - - -Logged Out - - - - Login - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/view/registration.jsp b/bin/src/main/webapp/WEB-INF/view/registration.jsp deleted file mode 100644 index dc85ce8afa5a..000000000000 --- a/bin/src/main/webapp/WEB-INF/view/registration.jsp +++ /dev/null @@ -1,25 +0,0 @@ - -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - - -Registration - - -

This is the registration page

- - - - - - - - - - - - \ No newline at end of file diff --git a/bin/src/main/webapp/WEB-INF/web.xml b/bin/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 463b3093771c..000000000000 --- a/bin/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - localizationFilter - org.springframework.web.filter.RequestContextFilter - - - localizationFilter - /* - - \ No newline at end of file diff --git a/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml b/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml deleted file mode 100644 index 5463820874c8..000000000000 --- a/core-java-8/src/main/webapp/WEB-INF/api-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/core-java-8/src/main/webapp/WEB-INF/web.xml b/core-java-8/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 48d4b8fe61af..000000000000 --- a/core-java-8/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - Spring MVC Application - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.config - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - / - - - - - - - \ No newline at end of file diff --git a/experiments/.classpath b/experiments/.classpath deleted file mode 100644 index ca257cf1f962..000000000000 --- a/experiments/.classpath +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch deleted file mode 100644 index 627021fb9640..000000000000 --- a/experiments/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/experiments/.gitignore b/experiments/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/experiments/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/experiments/.project b/experiments/.project deleted file mode 100644 index 13c876f10671..000000000000 --- a/experiments/.project +++ /dev/null @@ -1,42 +0,0 @@ - - - experiments - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/experiments/.settings/.jsdtscope b/experiments/.settings/.jsdtscope deleted file mode 100644 index 7b3f0c8b9fae..000000000000 --- a/experiments/.settings/.jsdtscope +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/experiments/.settings/org.eclipse.jdt.core.prefs b/experiments/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index df8135651462..000000000000 --- a/experiments/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,95 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=error -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=error -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/experiments/.settings/org.eclipse.jdt.ui.prefs b/experiments/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 471e9b0d81fc..000000000000 --- a/experiments/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,55 +0,0 @@ -#Sat Jan 21 23:04:06 EET 2012 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=true -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=true -sp_cleanup.correct_indentation=true -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=true -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=true -sp_cleanup.make_private_fields_final=false -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=true -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=false -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=true -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=true -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/experiments/.settings/org.eclipse.m2e.core.prefs b/experiments/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb23..000000000000 --- a/experiments/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/experiments/.settings/org.eclipse.m2e.wtp.prefs b/experiments/.settings/org.eclipse.m2e.wtp.prefs deleted file mode 100644 index ef8608962237..000000000000 --- a/experiments/.settings/org.eclipse.m2e.wtp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/experiments/.settings/org.eclipse.wst.common.component b/experiments/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 893209cc5760..000000000000 --- a/experiments/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml b/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index b46bc511b943..000000000000 --- a/experiments/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a48039..000000000000 --- a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name b/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6ec2c..000000000000 --- a/experiments/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/experiments/.settings/org.eclipse.wst.validation.prefs b/experiments/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 0d0aee4f7201..000000000000 --- a/experiments/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,15 +0,0 @@ -DELEGATES_PREFERENCE=delegateValidatorList -USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 -disabled=06target -eclipse.preferences.version=1 -override=true -suspend=false -vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 -vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 -vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 -vf.version=3 diff --git a/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs b/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs deleted file mode 100644 index 9cfcabe16f73..000000000000 --- a/experiments/.settings/org.eclipse.wst.ws.service.policy.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/experiments/.springBeans b/experiments/.springBeans deleted file mode 100644 index d11fb034bdc0..000000000000 --- a/experiments/.springBeans +++ /dev/null @@ -1,14 +0,0 @@ - - - 1 - - - - - - - src/main/webapp/WEB-INF/api-servlet.xml - - - - diff --git a/experiments/README.md b/experiments/README.md deleted file mode 100644 index 11522e362f47..000000000000 --- a/experiments/README.md +++ /dev/null @@ -1,7 +0,0 @@ -========= - -## Spring Security for REST Example Project - - -### Relevant Articles: -- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) \ No newline at end of file diff --git a/experiments/pom.xml b/experiments/pom.xml deleted file mode 100644 index 4ca03b75e180..000000000000 --- a/experiments/pom.xml +++ /dev/null @@ -1,295 +0,0 @@ - - 4.0.0 - org.baeldung - experiments - 0.1-SNAPSHOT - - experiments - war - - - - - - - xml-apis - xml-apis - 1.4.01 - - - - xalan - xalan - 2.7.1 - - - - net.sourceforge.nekohtml - nekohtml - 1.9.18 - - - - net.sourceforge.htmlcleaner - htmlcleaner - 2.6 - - - - - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - - - - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - - - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - - - - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - - - - javax.servlet - jstl - 1.2 - runtime - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.2.2 - - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - commons-logging - commons-logging - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - experiments - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 4.1.0.RELEASE - 3.2.5.RELEASE - - - 4.3.6.Final - 5.1.32 - - - 1.7.7 - 1.1.2 - - - 5.1.2.Final - - - 18.0 - 3.3.2 - - - 1.3 - 4.11 - 1.9.5 - - 4.3.2 - 4.3.5 - - 2.3.3 - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.9 - - - - \ No newline at end of file diff --git a/experiments/src/main/resources/logback.xml b/experiments/src/main/resources/logback.xml deleted file mode 100644 index 1146dade632e..000000000000 --- a/experiments/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/src/main/webapp/WEB-INF/api-servlet.xml b/experiments/src/main/webapp/WEB-INF/api-servlet.xml deleted file mode 100644 index a675fc6d954f..000000000000 --- a/experiments/src/main/webapp/WEB-INF/api-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/experiments/src/main/webapp/WEB-INF/web.xml b/experiments/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index fe62026bc7d6..000000000000 --- a/experiments/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - Spring MVC Application - - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - - - - - \ No newline at end of file diff --git a/experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java b/experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java deleted file mode 100644 index d7367d7bd0c8..000000000000 --- a/experiments/src/test/java/org/baeldung/live/CrawlLiveTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.baeldung.live; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpParams; -import org.apache.http.util.EntityUtils; -import org.cyberneko.html.parsers.DOMParser; -import org.htmlcleaner.CleanerProperties; -import org.htmlcleaner.HtmlCleaner; -import org.htmlcleaner.TagNode; -import org.htmlcleaner.XPatherException; -import org.junit.Before; -import org.junit.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -public class CrawlLiveTest { - - private DefaultHttpClient client; - - // fixtures - - @Before - public final void before() { - final HttpParams httpParameters = new BasicHttpParams(); - client = new DefaultHttpClient(httpParameters); - } - - // tests - - @Test - public final void when_then() throws ClientProtocolException, IOException, XPathExpressionException, SAXException, ParserConfigurationException { - final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; - final String xpathEx = ".//*[@id='search_results_table']/tbody/tr/td[1]"; - - HttpGet request = null; - HttpEntity httpEntity = null; - InputStream entityContentStream = null; - - try { - request = new HttpGet(url); - final HttpResponse httpResponse = client.execute(request); - - httpEntity = httpResponse.getEntity(); - entityContentStream = httpEntity.getContent(); - - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - final DocumentBuilder builder = factory.newDocumentBuilder(); - final Document doc = builder.parse(entityContentStream); - - final XPathFactory xPathfactory = XPathFactory.newInstance(); - final XPath xpath = xPathfactory.newXPath(); - final XPathExpression expr = xpath.compile(xpathEx); - final Object evaluated = expr.evaluate(doc, XPathConstants.STRING); - System.out.println(evaluated); - } catch (final RuntimeException runEx) { - runEx.printStackTrace(); - } finally { - if (request != null) { - request.releaseConnection(); - } - if (entityContentStream != null) { - entityContentStream.close(); - } - if (httpEntity != null) { - EntityUtils.consume(httpEntity); - } - } - } - - // http://htmlcleaner.sourceforge.net/parameters.php - @SuppressWarnings("unused") - @Test - public final void givenCleaningWithHtmlCleaner_whenPageIsRetrieved_thenContentCanBeExtracted() throws XPatherException, MalformedURLException, IOException { - final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; - final String xpathEx1 = ".//*[@id='search_results_table']/tbody/tr/td[1]/b/a/text()"; - final String xpathEx2 = ".//*[@id='search_results_table']/tbody/tr"; - - final CleanerProperties props = new CleanerProperties(); - // set some properties to non-default values - props.setAdvancedXmlEscape(true); - // props.setOmitComments(true); - - // do parsing - final TagNode tagNode = new HtmlCleaner(props).clean(new URL(url)); - final Object[] evaluateXPath = tagNode.evaluateXPath(xpathEx2); - final Object ex = evaluateXPath[7]; - - System.out.println(ex); - // System.out.println(Arrays.toString(evaluateXPath)); - // new PrettyXmlSerializer(props).writeToStream(tagNode, System.out); - } - - @SuppressWarnings("unused") - @Test - public final void givenCleaningWithNeko_whenPageIsRetrieved_thenContentCanBeExtracted() throws XPatherException, MalformedURLException, IOException, XPathExpressionException, SAXException { - final String url = "http://sales.starcitygames.com/category.php?cat=5260&start=50"; - final String xpathEx1 = ".//*[@id='search_results_table']/tbody/tr/td[1]/b/a/text()"; - final String xpathEx2 = ".//*[@id='search_results_table']/tbody/tr"; - - final DOMParser parser = new DOMParser(); - parser.setFeature("http://xml.org/sax/features/namespaces", false); - parser.parse(url); - final Document document = parser.getDocument(); - - final XPathFactory xpf = XPathFactory.newInstance(); - final XPath xpath = xpf.newXPath(); - final Object evaluate = xpath.evaluate(xpathEx2, document); - - System.out.println(evaluate); - } - -} diff --git a/experiments/src/test/resources/.gitignore b/experiments/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/experiments/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/starting/spring-jpa/.classpath b/starting/spring-jpa/.classpath deleted file mode 100644 index ca257cf1f962..000000000000 --- a/starting/spring-jpa/.classpath +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/starting/spring-jpa/.gitignore b/starting/spring-jpa/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/starting/spring-jpa/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/starting/spring-jpa/.project b/starting/spring-jpa/.project deleted file mode 100644 index 20cc7fd450ed..000000000000 --- a/starting/spring-jpa/.project +++ /dev/null @@ -1,43 +0,0 @@ - - - spring-jpa-start - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/starting/spring-jpa/.settings/.jsdtscope b/starting/spring-jpa/.settings/.jsdtscope deleted file mode 100644 index b46b9207a89e..000000000000 --- a/starting/spring-jpa/.settings/.jsdtscope +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs b/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c201ee1f7a18..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,95 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs b/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 471e9b0d81fc..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,55 +0,0 @@ -#Sat Jan 21 23:04:06 EET 2012 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=true -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=true -sp_cleanup.correct_indentation=true -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=true -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=true -sp_cleanup.make_private_fields_final=false -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=true -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=false -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=true -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=true -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs b/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb23..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs b/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs deleted file mode 100644 index ef8608962237..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.m2e.wtp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.common.component b/starting/spring-jpa/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 0327e45de6dc..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml b/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index a67649dfa5ae..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a48039..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name b/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6ec2c..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs b/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 0d0aee4f7201..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,15 +0,0 @@ -DELEGATES_PREFERENCE=delegateValidatorList -USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.402.v201212031633 -disabled=06target -eclipse.preferences.version=1 -override=true -suspend=false -vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01 -vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01 -vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01 -vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02 -vf.version=3 diff --git a/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs b/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs deleted file mode 100644 index 9cfcabe16f73..000000000000 --- a/starting/spring-jpa/.settings/org.eclipse.wst.ws.service.policy.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/starting/spring-jpa/.springBeans b/starting/spring-jpa/.springBeans deleted file mode 100644 index 7623a7e88836..000000000000 --- a/starting/spring-jpa/.springBeans +++ /dev/null @@ -1,14 +0,0 @@ - - - 1 - - - - - - - src/main/webapp/WEB-INF/mvc-servlet.xml - - - - diff --git a/starting/spring-jpa/README.md b/starting/spring-jpa/README.md deleted file mode 100644 index c62c4eabed74..000000000000 --- a/starting/spring-jpa/README.md +++ /dev/null @@ -1,8 +0,0 @@ -========= - -## Spring JPA Example Project - - -### Relevant Articles: -- [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) -- [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) diff --git a/starting/spring-jpa/pom.xml b/starting/spring-jpa/pom.xml deleted file mode 100644 index a8cd778faf8d..000000000000 --- a/starting/spring-jpa/pom.xml +++ /dev/null @@ -1,215 +0,0 @@ - - 4.0.0 - - org.baeldung - spring-jpa - 0.1-SNAPSHOT - - war - spring-jpa - - - - - org.javassist - javassist - 3.18.1-GA - - - - - - org.springframework - spring-context - ${org.springframework.version} - - - - - - - - - - - - - - - - - - - - - - - - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - junit - junit-dep - ${junit.version} - test - - - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - spring-jpa - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - - - - - - - - 4.0.0.RELEASE - 3.2.0.RELEASE - - - 4.3.0.Final - 5.1.28 - - - 1.7.5 - 1.0.11 - - - 5.0.2.Final - - - 16.0-rc1 - 3.2.1 - - - 1.3 - 4.11 - 1.9.5 - - 4.3 - 4.3.1 - - 2.1.0 - - - - 3.1 - 2.4 - 2.17 - 2.6 - 1.4.6 - - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/java/.gitignore b/starting/spring-jpa/src/main/java/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/starting/spring-jpa/src/main/java/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/jpaConfig.xml b/starting/spring-jpa/src/main/resources/jpaConfig.xml deleted file mode 100644 index a291786a5ce1..000000000000 --- a/starting/spring-jpa/src/main/resources/jpaConfig.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - ${hibernate.hbm2ddl.auto} - ${hibernate.dialect} - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/logback.xml b/starting/spring-jpa/src/main/resources/logback.xml deleted file mode 100644 index 1146dade632e..000000000000 --- a/starting/spring-jpa/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/resources/persistence-mysql.properties b/starting/spring-jpa/src/main/resources/persistence-mysql.properties deleted file mode 100644 index c4de4ceb80a5..000000000000 --- a/starting/spring-jpa/src/main/resources/persistence-mysql.properties +++ /dev/null @@ -1,10 +0,0 @@ -# jdbc.X -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_jpa_01?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/starting/spring-jpa/src/main/resources/webSecurityConfig.xml b/starting/spring-jpa/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 35dcb9c1ef53..000000000000 --- a/starting/spring-jpa/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml b/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index a675fc6d954f..000000000000 --- a/starting/spring-jpa/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp b/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp deleted file mode 100644 index 7cc14b5dcddf..000000000000 --- a/starting/spring-jpa/src/main/webapp/WEB-INF/view/sample.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml b/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 90f2abc2f6c9..000000000000 --- a/starting/spring-jpa/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - Spring JPA Application - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.baeldung.spring - - - org.springframework.web.context.ContextLoaderListener - - - \ No newline at end of file diff --git a/starting/spring-jpa/src/test/java/.gitignore b/starting/spring-jpa/src/test/java/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/starting/spring-jpa/src/test/java/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/starting/spring-jpa/src/test/resources/.gitignore b/starting/spring-jpa/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c802..000000000000 --- a/starting/spring-jpa/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file From 7400fdff984533c320730b7613cde94b3eb42262 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 18 Sep 2014 17:33:26 +0300 Subject: [PATCH 640/796] cleanup work --- core-java/src/main/resources/targetFile.tmp | 2 -- .../java/io/JavaInputStreamToXUnitTest.java | 18 +++++++++++++- ...rnalPropertiesWithJavaIntegrationTest.java | 2 ++ ...ertiesWithMultipleXmlsIntegrationTest.java | 2 ++ ...ernalPropertiesWithXmlIntegrationTest.java | 2 ++ .../baeldung/test/IntegrationTestSuite.java | 24 +++++++++++++++++++ 6 files changed, 47 insertions(+), 3 deletions(-) delete mode 100644 core-java/src/main/resources/targetFile.tmp create mode 100644 spring-all/src/test/java/org/baeldung/test/IntegrationTestSuite.java diff --git a/core-java/src/main/resources/targetFile.tmp b/core-java/src/main/resources/targetFile.tmp deleted file mode 100644 index 20f137b41622..000000000000 --- a/core-java/src/main/resources/targetFile.tmp +++ /dev/null @@ -1,2 +0,0 @@ -line 1 -a second line \ No newline at end of file diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index e587bfcf186f..982b84df3691 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -149,7 +149,7 @@ public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_th // tests - InputStream to File @Test - public final void givenUsingPlainJava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException { + public final void givenUsingPlainJava_whenConvertingAnFullInputStreamToAFile_thenCorrect() throws IOException { final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt")); final byte[] buffer = new byte[initialStream.available()]; initialStream.read(buffer); @@ -162,6 +162,22 @@ public final void givenUsingPlainJava_whenConvertingAnInputStreamToAFile_thenCor IOUtils.closeQuietly(outStream); } + @Test + public final void givenUsingPlainJava_whenConvertingAnInProgressInputStreamToAFile_thenCorrect() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt")); + final File targetFile = new File("src/main/resources/targetFile.tmp"); + final OutputStream outStream = new FileOutputStream(targetFile); + + final byte[] buffer = new byte[8 * 1024]; + int bytesRead; + while ((bytesRead = initialStream.read(buffer)) != -1) { + outStream.write(buffer, 0, bytesRead); + } + + IOUtils.closeQuietly(initialStream); + IOUtils.closeQuietly(outStream); + } + @Test public final void givenUsingGuava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException { final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt")); diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java index bfc2f52579e9..1cf9c774f4c7 100644 --- a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java @@ -2,6 +2,7 @@ import org.baeldung.properties.spring.PropertiesWithJavaConfig; import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +14,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class) +@Ignore("manual only") public class ExternalPropertiesWithJavaIntegrationTest { @Autowired diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java index 6391b8d655f8..98654ee4b60b 100644 --- a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java @@ -2,6 +2,7 @@ import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +14,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class) +@Ignore("manual only") public class ExternalPropertiesWithMultipleXmlsIntegrationTest { @Autowired diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java index 0d437842e6f1..b77aac63d82d 100644 --- a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java @@ -1,6 +1,7 @@ package org.baeldung.properties.core; import org.baeldung.properties.spring.PropertiesWithXmlConfig; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +13,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +@Ignore("manual only") public class ExternalPropertiesWithXmlIntegrationTest { @Autowired diff --git a/spring-all/src/test/java/org/baeldung/test/IntegrationTestSuite.java b/spring-all/src/test/java/org/baeldung/test/IntegrationTestSuite.java new file mode 100644 index 000000000000..9957b1951632 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/test/IntegrationTestSuite.java @@ -0,0 +1,24 @@ +package org.baeldung.test; + +import org.baeldung.properties.core.ExternalPropertiesWithJavaIntegrationTest; +import org.baeldung.properties.core.ExternalPropertiesWithMultipleXmlsIntegrationTest; +import org.baeldung.properties.core.ExternalPropertiesWithXmlIntegrationTest; +import org.baeldung.properties.core.PropertiesWithJavaIntegrationTest; +import org.baeldung.properties.core.PropertiesWithMultipleXmlsIntegrationTest; +import org.baeldung.properties.core.PropertiesWithXmlIntegrationTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({//@formatter:off + PropertiesWithXmlIntegrationTest.class, + ExternalPropertiesWithJavaIntegrationTest.class, + ExternalPropertiesWithMultipleXmlsIntegrationTest.class, + ExternalPropertiesWithXmlIntegrationTest.class, + PropertiesWithJavaIntegrationTest.class, + PropertiesWithMultipleXmlsIntegrationTest.class, +})// @formatter:on +public final class IntegrationTestSuite { + // +} From 6e10b7d2d21608029b4beb14d04383c87ad7d0d5 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 18 Sep 2014 17:38:05 +0300 Subject: [PATCH 641/796] minor generated file --- core-java/src/main/resources/targetFile.tmp | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 core-java/src/main/resources/targetFile.tmp diff --git a/core-java/src/main/resources/targetFile.tmp b/core-java/src/main/resources/targetFile.tmp new file mode 100644 index 000000000000..20f137b41622 --- /dev/null +++ b/core-java/src/main/resources/targetFile.tmp @@ -0,0 +1,2 @@ +line 1 +a second line \ No newline at end of file From 2080f93e39ba2cf32686913163d0cec988944be7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 25 Sep 2014 12:08:40 +0300 Subject: [PATCH 642/796] minor sandbox test for unfinished samples --- .../java/sandbox/SandboxJavaTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java diff --git a/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java b/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java new file mode 100644 index 000000000000..f746ce63e219 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java @@ -0,0 +1,29 @@ +package org.baeldung.java.sandbox; + +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +import org.junit.Test; + +public class SandboxJavaTest { + + @Test + public void givenUsingTimer_whenSchedulingTaskOnce_thenCorrect() throws InterruptedException { + final Timer timer = new Timer("Thread's name"); + System.out.println("Current time:" + new Date()); + System.out.println("Thread name: " + Thread.currentThread().getName()); + + final TimerTask timerTask = new TimerTask() { + @Override + public void run() { + System.out.println("Time when task performed" + new Date()); + System.out.println("Thread name: " + Thread.currentThread().getName()); + timer.cancel(); + } + }; + final long delay = 2 * 1000; + timer.schedule(timerTask, delay); + } + +} From 1b8f1ce06df5c1eb09b94368736c4e55f0c48de1 Mon Sep 17 00:00:00 2001 From: egmp777 Date: Fri, 26 Sep 2014 17:45:37 -0500 Subject: [PATCH 643/796] ChangesSept26 --- .../persistence/service/IUserService.java | 3 +- .../baeldung/persistence/service/UserDto.java | 3 + .../persistence/service/UserService.java | 16 ++-- .../security/MyUserDetailsService.java | 12 +-- .../java/org/baeldung/spring/MvcConfig.java | 4 +- .../service/EmailExistsException.java | 2 +- .../service/EmailValidator.java | 4 +- .../service/PasswordMatches.java | 2 +- .../service/PasswordMatchesValidator.java | 4 +- .../service/UserValidator.java | 14 +--- .../service/ValidEmail.java | 2 +- .../controller/RegistrationController.java | 24 ++---- .../src/main/resources/application.properties | 6 +- .../src/main/resources/messages_en.properties | 7 ++ .../main/resources/messages_es_ES.properties | 7 ++ .../src/main/resources/webSecurityConfig.xml | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 2 +- .../src/main/webapp/WEB-INF/view/admin.jsp | 25 ++++-- .../src/main/webapp/WEB-INF/view/console.jsp | 21 +++-- .../src/main/webapp/WEB-INF/view/home.jsp | 13 ++- .../src/main/webapp/WEB-INF/view/homepage.jsp | 36 ++++---- .../webapp/WEB-INF/view/invalidSession.jsp | 14 +++- .../src/main/webapp/WEB-INF/view/login.jsp | 64 +++++++++------ .../src/main/webapp/WEB-INF/view/logout.jsp | 18 ++-- .../main/webapp/WEB-INF/view/registration.jsp | 82 +++++++++++-------- .../webapp/WEB-INF/view/successRegister.jsp | 15 ++-- .../src/main/webapp/resources/bootstrap.css | 2 +- 27 files changed, 237 insertions(+), 167 deletions(-) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/EmailExistsException.java (79%) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/EmailValidator.java (89%) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/PasswordMatches.java (94%) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/PasswordMatchesValidator.java (84%) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/UserValidator.java (63%) rename spring-security-login-error-handling/src/main/java/org/baeldung/{persistence => validation}/service/ValidEmail.java (94%) diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java index f8e065187170..6c9f50acfcef 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java @@ -1,9 +1,10 @@ package org.baeldung.persistence.service; import org.baeldung.persistence.model.User; +import org.baeldung.validation.service.EmailExistsException; public interface IUserService { - public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; + public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException; } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java index 61aff3156719..af299520fd84 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -1,6 +1,9 @@ package org.baeldung.persistence.service; import javax.validation.constraints.NotNull; + +import org.baeldung.validation.service.PasswordMatches; +import org.baeldung.validation.service.ValidEmail; import org.hibernate.validator.constraints.NotEmpty; @PasswordMatches public class UserDto { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java index 1a083c557cb7..bb84fc81ab48 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -1,9 +1,11 @@ package org.baeldung.persistence.service; import javax.transaction.Transactional; + import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.model.Role; import org.baeldung.persistence.model.User; +import org.baeldung.validation.service.EmailExistsException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -14,16 +16,16 @@ public class UserService implements IUserService { @Transactional @Override - public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { - if (emailExist(userAccountData.getEmail())) { + public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException { + if (emailExist(accountDto.getEmail())) { - throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getEmail()); + throw new EmailExistsException("There is an account with that email adress: " + accountDto.getEmail()); } User user = new User(); - user.setFirstName(userAccountData.getFirstName()); - user.setLastName(userAccountData.getLastName()); - user.setPassword(userAccountData.getPassword()); - user.setEmail(userAccountData.getEmail()); + user.setFirstName(accountDto.getFirstName()); + user.setLastName(accountDto.getLastName()); + user.setPassword(accountDto.getPassword()); + user.setEmail(accountDto.getEmail()); //ROLE WILL ALWAYS BE USER. HARDCODING IT user.setRole(new Role(Integer.valueOf(1),user)); return repository.save(user); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java index 7ff77895193d..9e57ef2f6d25 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -26,18 +26,12 @@ public class MyUserDetailsService implements UserDetailsService { @Autowired private UserRepository userRepository; - // @Autowired - // public MyUserDetailsService(UserRepository repository) { - // this.userRepository = repository; - // } - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { try { LOGGER.debug("Loading user by username: {}", email); User user = userRepository.findByEmail(email); LOGGER.debug("Found user: {}", user); if (user == null) { - // throw new UsernameNotFoundException("No user found with username: " + username); boolean enabled = false; return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); } @@ -52,7 +46,7 @@ public UserDetails loadUserByUsername(String email) throws UsernameNotFoundExcep } } - public Collection getAuthorities(Integer role) { + private Collection getAuthorities(Integer role) { List authList = getGrantedAuthorities(getRoles(role)); return authList; } @@ -61,17 +55,15 @@ public List getRoles(Integer role) { List roles = new ArrayList(); if (role.intValue() == 2) { - // roles.add("ROLE_USER"); roles.add("ROLE_ADMIN"); } else if (role.intValue() == 1) { roles.add("ROLE_USER"); } - return roles; } - public static List getGrantedAuthorities(List roles) { + private static List getGrantedAuthorities(List roles) { List authorities = new ArrayList(); for (String role : roles) { authorities.add(new SimpleGrantedAuthority(role)); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index 4c7a84ef8601..429ed2342d04 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -2,8 +2,8 @@ import java.util.Locale; -import org.baeldung.persistence.service.PasswordMatchesValidator; -import org.baeldung.persistence.service.EmailValidator; +import org.baeldung.validation.service.EmailValidator; +import org.baeldung.validation.service.PasswordMatchesValidator; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailExistsException.java similarity index 79% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailExistsException.java index ad00388f06ae..7b60bb9f0879 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailExistsException.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; @SuppressWarnings("serial") public class EmailExistsException extends Throwable { diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailValidator.java similarity index 89% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailValidator.java index 19907ce50459..1ff8c4251f9e 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailValidator.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -20,7 +20,7 @@ public boolean isValid(String username, ConstraintValidatorContext context) { return (validateEmail(username)); } - public boolean validateEmail(String email) { + private boolean validateEmail(String email) { pattern = Pattern.compile(EMAIL_PATTERN); matcher = pattern.matcher(email); return matcher.matches(); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatches.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java similarity index 94% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatches.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java index eb98a73d2c5b..5499921aed52 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatches.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; import javax.validation.Constraint; import javax.validation.Payload; diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatchesValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java similarity index 84% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatchesValidator.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java index 18a70637e576..10fa21d02e93 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/PasswordMatchesValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java @@ -1,8 +1,10 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; +import org.baeldung.persistence.service.UserDto; + public class PasswordMatchesValidator implements ConstraintValidator { @Override diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/UserValidator.java similarity index 63% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/UserValidator.java index 45d453b934b6..45de9e3a9404 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/UserValidator.java @@ -1,15 +1,11 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.baeldung.persistence.service.UserDto; import org.springframework.validation.Errors; import org.springframework.validation.ValidationUtils; import org.springframework.validation.Validator; public class UserValidator implements Validator { - private Pattern pattern; - private Matcher matcher; - private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; @Override public boolean supports(Class clazz) { @@ -24,10 +20,4 @@ public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required."); } - public boolean validateEmail(String email) { - pattern = Pattern.compile(EMAIL_PATTERN); - matcher = pattern.matcher(email); - return matcher.matches(); - - } } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/ValidEmail.java similarity index 94% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java rename to spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/ValidEmail.java index 3ad5558df2b3..df852351c356 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/ValidEmail.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/ValidEmail.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package org.baeldung.validation.service; import javax.validation.Constraint; import javax.validation.Payload; diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java index 73732c7a2cdf..c91fcae56dad 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -3,13 +3,12 @@ import javax.validation.Valid; import org.baeldung.persistence.model.User; -import org.baeldung.persistence.service.EmailExistsException; import org.baeldung.persistence.service.UserDto; import org.baeldung.persistence.service.IUserService; +import org.baeldung.validation.service.EmailExistsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; @@ -25,8 +24,6 @@ public class RegistrationController { private final Logger LOGGER = LoggerFactory.getLogger(getClass()); private IUserService service; - @Autowired - private MessageSource messages; @Autowired public RegistrationController(IUserService service) { @@ -42,34 +39,27 @@ public String showRegistrationForm(WebRequest request, Model model) { } @RequestMapping(value = "/user/registration", method = RequestMethod.POST) - public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { + public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto accountDto, BindingResult result, WebRequest request, Errors errors) { User registered = new User(); if (!result.hasErrors()) - registered = createUserAccount(userAccountData, result); + registered = createUserAccount(accountDto, result); if (registered == null) { result.rejectValue("email", "message.regError"); } if (result.hasErrors()) { - return new ModelAndView("registration", "user", userAccountData); + return new ModelAndView("registration", "user", accountDto); } else { - // Will show the success registration page--ORIGINAL - return new ModelAndView("successRegister", "user", userAccountData); - // Will redirect to login view (not in url as login.html) and user model can be accessed - // return new ModelAndView("login","user", userAccountData); - - - // Will redirect to login html but no model object---we send a success param to the login form - //return new ModelAndView("redirect:/login.html?success=true", "", null); + return new ModelAndView("successRegister", "user", accountDto); } } - private User createUserAccount(UserDto userAccountData, BindingResult result) { + private User createUserAccount(UserDto accountDto, BindingResult result) { User registered = null; try { - registered = service.registerNewUserAccount(userAccountData); + registered = service.registerNewUserAccount(accountDto); } catch (EmailExistsException e) { return null; } diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index 1144b5f03f64..70a8ae5daa45 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,10 +1,10 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true +jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql init-db=false ################### Hibernate Configuration ########################## hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop +hibernate.show_sql=true +hibernate.hbm2ddl.auto=validate diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-error-handling/src/main/resources/messages_en.properties index b8ec5102fa2a..de1d25c84ca4 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_en.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_en.properties @@ -25,6 +25,13 @@ label.form.loginPass=Password label.form.loginEnglish=English label.form.loginSpanish=Spanish label.form.loginSignUp=Sign up +label.pages.logout=Logout +label.pages.admin=Administrator +label.pages.home.title=Home +label.pages.home.message=Welcome Home +label.pages.admin.message=Welcome Admin +label.pages.user.message=Welcome User +label.successRegister.title=Registration Success ValidEmail.user.email=Invalid email address! UniqueUsername.user.username=An account with that username/email already exists NotNull.user.firstName=First name required diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties index c28ee68c24e4..f3fdb6330430 100644 --- a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties +++ b/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties @@ -25,6 +25,13 @@ label.form.loginPass=Contrasenia label.form.loginEnglish=Ingles label.form.loginSpanish=Espaniol label.form.loginSignUp=Registrese +label.pages.logout=Salir +label.pages.admin=Administrador +label.pages.home.title=Inicio +label.pages.home.message=Bienveni@ a Casa +label.pages.admin.message=Bienvenido Admin +label.pages.user.message=Bienvenido Usuario +label.successRegister.title=Registro Exitoso ValidEmail.user.email=Cuenta correo invlida! UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario NotNull.user.firstName=Por favor ingrese su nombre diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index f02290fc2c7b..d584ff342fdc 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml index 8b81b56aa4af..94bd63e068a3 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -2,6 +2,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp index 3b88dbdb12ff..574f84453ee0 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp @@ -8,14 +8,21 @@ " rel="stylesheet"> - - - - -

Hello Admin

-
- - ">Logout - ">Home +
+
+ + + + +

+ +

+
+ "> "> +
+
diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp index f6ab8b612124..da04eac57d8f 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp @@ -1,22 +1,29 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> " rel="stylesheet"> -

This is the landing page for the admin

- +
+
+

This is the landing page for the admin

+ This text is only visible to a user
-
- + + This text is only visible to an admin
-
- ">Logout - ">Administrator Page + + "> "> +
+
\ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp index 79461bef1d22..68819f09f4f5 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp @@ -1,13 +1,22 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ page session="true"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> " rel="stylesheet"> -Home +<spring:message code="label.pages.home.title"></spring:message> -

Welcome back home!

+
+
+

+ +

+ "> +
+
diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp index 4fb2853ef1f7..c24fee98764c 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,25 +1,31 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@ page session="true"%> " rel="stylesheet"> -

This is the homepage for the user

+
+
+ + +
+
- - This text is only visible to a user -
-
- - - This text is only visible to an admin -
-
- - ">Logout - ">Home - ">Administrator Page + + +
+
+ "> "> "> +
+
\ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp index 59e9cdc22b70..4e62083a525b 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp @@ -3,12 +3,18 @@ " rel="stylesheet"> -Home +<spring:message code="label.pages.home.title"></spring:message> -

- -

+
+
+

+ +

+ "> +
+
diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp index ea196f011403..98d983b2116c 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp @@ -1,5 +1,6 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> @@ -11,8 +12,12 @@ " rel="stylesheet"> -
- +
+
+
+ +
+
-

- | - -
- - - - - - - - - - - - -
/>
+
+
+

+ +

+ + | + + + + + + + + + + + + + +
/>
- -
Current Locale : ${pageContext.response.locale} -
- "> + +
Current Locale : ${pageContext.response.locale}
"> +
+
\ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp index f33773b2170b..10cc4591b4fa 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp @@ -1,5 +1,6 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> @@ -15,12 +16,17 @@ - -
- +
+
+ +
+ +
+
+ "> +
- - Login \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp index 38eb4cf9ebe5..0d6781a5db2a 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp @@ -3,7 +3,8 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> <%@ page session="false"%> @@ -11,40 +12,53 @@ <spring:message code="label.form.title"></spring:message> - -

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- "> +
+
+

+ +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
"> +
+
\ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp index d23a2e298fbf..883a5aad82d0 100644 --- a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp +++ b/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp @@ -1,5 +1,6 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> @@ -13,10 +14,14 @@ Registration Success -
- +
+
+
+ +
+ "> +
- "> - \ No newline at end of file diff --git a/spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css b/spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css index 5b7fe7e8562e..a5b7ccc211ac 100644 --- a/spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css +++ b/spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css @@ -1091,7 +1091,7 @@ input[type="tel"], input[type="color"], .uneditable-input { display: inline-block; - height: 20px; + height: 30px; padding: 4px 6px; margin-bottom: 10px; font-size: 14px; From 686fdd8ee2841ede23add4d6eb36fc186b314ebb Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 27 Sep 2014 22:18:28 +0300 Subject: [PATCH 644/796] small cleanup --- spring-security-login-error-handling/pom.xml | 4 ++- .../org/baeldung/persistence/model/Role.java | 3 +-- .../baeldung/persistence/service/UserDto.java | 4 +++ .../persistence/service/UserService.java | 9 +++---- .../java/org/baeldung/spring/MvcConfig.java | 2 +- .../validation/service/PasswordMatches.java | 8 +++--- .../service/PasswordMatchesValidator.java | 11 ++++---- .../src/main/resources/webSecurityConfig.xml | 26 +++++++------------ 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index 68f217afc5e1..45ff89f52a01 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -7,11 +7,13 @@ spring-security-login-and-registration war 1.0.0-BUILD-SNAPSHOT + org.springframework.boot spring-boot-starter-parent - 1.1.5.RELEASE + 1.1.6.RELEASE + diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java index bb4b86e32f95..dcbdd8436b2c 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java @@ -23,7 +23,6 @@ public class Role { @JoinColumn(name = "user_id") private User user; - @Column(name = "role") private Integer role; @@ -66,7 +65,7 @@ public Integer getRole() { public void setRole(Integer role) { this.role = role; } - + @Override public int hashCode() { final int prime = 31; diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java index af299520fd84..c8d63fb89180 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java @@ -5,6 +5,7 @@ import org.baeldung.validation.service.PasswordMatches; import org.baeldung.validation.service.ValidEmail; import org.hibernate.validator.constraints.NotEmpty; + @PasswordMatches public class UserDto { @NotNull @@ -23,6 +24,7 @@ public class UserDto { @NotNull @NotEmpty private String email; + public String getEmail() { return email; } @@ -64,9 +66,11 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } + public String getMatchingPassword() { return matchingPassword; } + public void setMatchingPassword(String matchingPassword) { this.matchingPassword = matchingPassword; } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java index bb84fc81ab48..6bde98bf4d84 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java @@ -10,15 +10,14 @@ import org.springframework.stereotype.Service; @Service -public class UserService implements IUserService { +public class UserService implements IUserService { @Autowired private UserRepository repository; - + @Transactional @Override public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException { if (emailExist(accountDto.getEmail())) { - throw new EmailExistsException("There is an account with that email adress: " + accountDto.getEmail()); } User user = new User(); @@ -26,8 +25,8 @@ public User registerNewUserAccount(UserDto accountDto) throws EmailExistsExcepti user.setLastName(accountDto.getLastName()); user.setPassword(accountDto.getPassword()); user.setEmail(accountDto.getEmail()); - //ROLE WILL ALWAYS BE USER. HARDCODING IT - user.setRole(new Role(Integer.valueOf(1),user)); + // ROLE WILL ALWAYS BE USER. HARDCODING IT + user.setRole(new Role(Integer.valueOf(1), user)); return repository.save(user); } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java index 429ed2342d04..47c23ace50f5 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java @@ -83,7 +83,7 @@ public MessageSource messageSource() { messageSource.setCacheSeconds(0); return messageSource; } - + @Bean public EmailValidator usernameValidator() { EmailValidator userNameValidator = new EmailValidator(); diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java index 5499921aed52..63cfb297f08f 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java @@ -10,13 +10,15 @@ import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; -@Target({TYPE,ANNOTATION_TYPE}) +@Target({ TYPE, ANNOTATION_TYPE }) @Retention(RUNTIME) @Constraint(validatedBy = PasswordMatchesValidator.class) @Documented public @interface PasswordMatches { - + String message() default "Passwords don't match"; - Class[] groups() default {}; + + Class[] groups() default {}; + Class[] payload() default {}; } diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java index 10fa21d02e93..99f569957b85 100644 --- a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java +++ b/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java @@ -6,13 +6,14 @@ import org.baeldung.persistence.service.UserDto; public class PasswordMatchesValidator implements ConstraintValidator { - + @Override - public void initialize(PasswordMatches constraintAnnotation) { + public void initialize(PasswordMatches constraintAnnotation) { } + @Override - public boolean isValid(Object obj, ConstraintValidatorContext context){ + public boolean isValid(Object obj, ConstraintValidatorContext context) { UserDto user = (UserDto) obj; - return user.getPassword().equals(user.getMatchingPassword()); - } + return user.getPassword().equals(user.getMatchingPassword()); + } } diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml index d584ff342fdc..2dd759f8c3da 100644 --- a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml @@ -1,6 +1,5 @@ - - - - + + - + + + - - - + - + + \ No newline at end of file From f32730e8a30b3f0b1fa8af5c11a63a808d33e8d5 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 28 Sep 2014 09:39:26 +0200 Subject: [PATCH 645/796] Add TestWriter TestWriter contain methods used in Article Java - Write to file --- .../java/org/baeldung/java/io/TestWriter.java | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 core-java/src/test/java/org/baeldung/java/io/TestWriter.java diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java new file mode 100644 index 000000000000..0dfa854dc984 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -0,0 +1,202 @@ +package test; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.RandomAccessFile; +import java.util.List; + +import au.com.bytecode.opencsv.CSVReader; +import au.com.bytecode.opencsv.CSVWriter; +import main.Foo; +import junit.framework.TestCase; + +public class TestWriter extends TestCase { + + private String fileName1 = "test1.txt"; + private String fileName2 = "test2.txt"; + private String fileName3 = "test3.txt"; + private String fileName4 = "test4.csv"; + + public TestWriter(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testWriteDouble_thenReadIt_shouldBeTheSame() { + double value = 2.5; + testWriteDouble(value); + assertEquals(value, testReadDouble(), 0.0000001); + } + + public void testWriteToPosition_editValueIfSpecificPos_shouldChange() { + int data1 = 2014; + int data2 = 1500; + testWriteToPosition(data1, 4); + assertEquals(data1, testReadFromPosition(4)); + testWriteToPosition(data2, 4); + assertEquals(data2, testReadFromPosition(4)); + } + + public void testWriteObject_thenReadIt_instanceVariableValuesShouldBeTheSame() { + Foo foo = new Foo(1, "John"); + testWriteObject(foo); + Foo read = testReadObject(); + assertEquals(foo.getId(), read.getId()); + assertEquals(foo.getName(), read.getName()); + } + + public void testWriteCSVReport_thenReadAllData_shouldBeTheSame() { + Foo[] arr = new Foo[3]; + arr[0] = new Foo(1, "John"); + arr[1] = new Foo(2, "Adam"); + arr[2] = new Foo(3, "Jane"); + testWriteCSVReport(arr); + Foo[] read = testReadCSVReport(); + assertEquals(arr[0].getId(), read[0].getId()); + assertEquals(arr[2].getName(), read[2].getName()); + assertEquals(arr[1].getId(), read[1].getId()); + } +//================= writer methods======== + // use DataOutputStream to write primitive data types + public void testWriteDouble(double value) { + DataOutputStream stream; + try { + FileOutputStream fos = new FileOutputStream(fileName1); + stream = new DataOutputStream(new BufferedOutputStream(fos)); + stream.writeDouble(value); + stream.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + } + + // use RandomAccessFile to write data at specific position in the file + public void testWriteToPosition(int data, long position) { + try { + RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); + writer.seek(position); + writer.writeInt(data); + writer.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + } + + // use ObjectOutputStream to write object + public void testWriteObject(Foo foo) { + FileOutputStream fos; + try { + fos = new FileOutputStream(fileName3); + ObjectOutputStream writer = new ObjectOutputStream(fos); + writer.writeObject(foo); + writer.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + + } + + // use CSVWriter to write CSV data + public void testWriteCSVReport(Foo[] array) { + try { + CSVWriter writer = new CSVWriter(new FileWriter(fileName4, true), ','); + int len = array.length; + for (int i = 0; i < len; i++) { + writer.writeNext(array[i].toStringArray()); + } + writer.close(); + } catch (IOException e) { + System.out.println(e.getLocalizedMessage()); + } + } + + + //=============== read methods ====== + // use DataInputStream + public double testReadDouble() { + DataInputStream stream; + double result = 0; + try { + FileInputStream fis = new FileInputStream(fileName1); + stream = new DataInputStream(new BufferedInputStream(fis)); + result = stream.readDouble(); + stream.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + return result; + } + + // use RandomAccessFile to read data from specific position in the file + public int testReadFromPosition(long position) { + int result = 0; + try { + RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); + reader.seek(position); + result = reader.readInt(); + reader.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + return result; + } + + // use ObjectInputStream to read object + public Foo testReadObject() { + FileInputStream fis; + Foo result = null; + try { + fis = new FileInputStream(fileName3); + ObjectInputStream reader = new ObjectInputStream(fis); + result = (Foo) reader.readObject(); + reader.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + return result; + } + + // use CSVReader to read CSV data + public Foo[] testReadCSVReport() { + CSVReader reader; + Foo[] result = null; + try { + reader = new CSVReader(new FileReader(fileName4)); + List list = reader.readAll(); + int size = list.size(); + result = new Foo[size]; + Foo temp; + String[] currentItem; + for (int i = 0; i < size; i++) { + temp = new Foo(); + currentItem = (String[]) list.get(i); + temp.setId(Long.parseLong(currentItem[0])); + temp.setName(currentItem[1]); + result[i] = temp; + } + reader.close(); + } catch (Exception e) { + System.out.println(e.getLocalizedMessage()); + } + return result; + } + + + +} From fa4240311ddab4a4bbfb317927f6286b145c254e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 28 Sep 2014 15:16:46 +0300 Subject: [PATCH 646/796] small persistence fixes --- .../java/sandbox/SandboxJavaTest.java | 70 ++++++++++++++++--- .../src/main/resources/application.properties | 4 +- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java b/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java index f746ce63e219..5127ccb10c78 100644 --- a/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java +++ b/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaTest.java @@ -9,21 +9,75 @@ public class SandboxJavaTest { @Test - public void givenUsingTimer_whenSchedulingTaskOnce_thenCorrect() throws InterruptedException { + public void givenUsingTimer_whenSchedulingTimerTaskOnce_thenCorrect() throws InterruptedException { + final TimerTask timerTask = new TimerTask() { + @Override + public void run() { + System.out.println("Time when was task performed" + new Date()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + } + }; final Timer timer = new Timer("Thread's name"); System.out.println("Current time:" + new Date()); - System.out.println("Thread name: " + Thread.currentThread().getName()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + final long delay = 2L * 1000L; + timer.schedule(timerTask, delay); + Thread.sleep(delay); + } + + @Test + public void givenUsingTimer_whenSchedulingRepeatedTask_thenCorrect() throws InterruptedException { + final TimerTask repeatedTask = new TimerTask() { + int count = 0; - final TimerTask timerTask = new TimerTask() { @Override public void run() { - System.out.println("Time when task performed" + new Date()); - System.out.println("Thread name: " + Thread.currentThread().getName()); - timer.cancel(); + count++; + System.out.println("Time when task was performed: " + new Date()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + if (count >= 5) { + cancel(); + } } }; - final long delay = 2 * 1000; - timer.schedule(timerTask, delay); + final Timer timer = new Timer("Timer thread"); + System.out.println("Current time: " + new Date()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + final long delay = 2L * 1000L; + final long period = 1L * 1000L; + timer.scheduleAtFixedRate(repeatedTask, delay, period); + Thread.sleep(delay + period * 5L); + } + + @Test + public void givenUsingTimer_whenSchedulingRepeatedCustomTimerTask_thenCorrect() throws InterruptedException { + class MyTask extends TimerTask { + long timesToRun = 0; + long timesRunned = 0; + + public void setTimesToRun(final int timesToRun) { + this.timesToRun = timesToRun; + } + + @Override + public void run() { + timesRunned++; + System.out.println("Task performed on: " + new Date()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + if (timesRunned >= timesToRun) { + cancel(); + } + } + } + final MyTask repeatedTask = new MyTask(); + repeatedTask.setTimesToRun(5); + final long delay = 2L * 1000L; + final long period = 1L * 1000L; + final Timer timer = new Timer("Timer"); + System.out.println("Current time: " + new Date()); + System.out.println("Thread's name: " + Thread.currentThread().getName()); + timer.scheduleAtFixedRate(repeatedTask, delay, period); + Thread.sleep(delay + period * repeatedTask.timesToRun); } } diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties index 70a8ae5daa45..f80dba9ba510 100644 --- a/spring-security-login-error-handling/src/main/resources/application.properties +++ b/spring-security-login-error-handling/src/main/resources/application.properties @@ -1,10 +1,10 @@ ################### DataSource Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA +jdbc.url=jdbc:mysql://localhost:3306/authdata?createDatabaseIfNotExist=true jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql init-db=false ################### Hibernate Configuration ########################## hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.show_sql=true -hibernate.hbm2ddl.auto=validate +hibernate.hbm2ddl.auto=create-drop From 800cf141cfb13a81e57e47375f522e76ab6d0119 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 28 Sep 2014 17:04:53 +0200 Subject: [PATCH 647/796] Modify TestWriter Adding some test methods --- .../java/org/baeldung/java/io/TestWriter.java | 203 +++++++----------- 1 file changed, 82 insertions(+), 121 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index 0dfa854dc984..7605856b34f9 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -1,30 +1,32 @@ package test; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.PrintWriter; import java.io.RandomAccessFile; -import java.util.List; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; -import au.com.bytecode.opencsv.CSVReader; -import au.com.bytecode.opencsv.CSVWriter; import main.Foo; import junit.framework.TestCase; public class TestWriter extends TestCase { + private String fileName = "test.txt"; private String fileName1 = "test1.txt"; private String fileName2 = "test2.txt"; private String fileName3 = "test3.txt"; - private String fileName4 = "test4.csv"; + private String fileName4 = "test4.txt"; + private String fileName5 = "test5.txt"; public TestWriter(String name) { super(name); @@ -37,11 +39,28 @@ protected void setUp() throws Exception { protected void tearDown() throws Exception { super.tearDown(); } + + public void testWriteFormattedStringUsingPrintWriter() throws IOException{ + FileWriter fileWriter = new FileWriter(fileName); + PrintWriter printWriter = new PrintWriter(fileWriter); + printWriter.printf("Product name is %s and its price is %d $","iPhone",1000); + printWriter.close(); + } - public void testWriteDouble_thenReadIt_shouldBeTheSame() { - double value = 2.5; - testWriteDouble(value); - assertEquals(value, testReadDouble(), 0.0000001); + public void testWriteStringWithDataOutputStream_thenReadIt_shouldBeTheSame() throws IOException { + String value = "Hello"; + FileOutputStream fos = new FileOutputStream(fileName1); + DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); + outStream.writeUTF(value); + outStream.close(); + + String result; + FileInputStream fis = new FileInputStream(fileName1); + DataInputStream reader = new DataInputStream(fis); + result = reader.readUTF(); + reader.close(); + + assertEquals(value, result); } public void testWriteToPosition_editValueIfSpecificPos_shouldChange() { @@ -53,39 +72,62 @@ public void testWriteToPosition_editValueIfSpecificPos_shouldChange() { assertEquals(data2, testReadFromPosition(4)); } - public void testWriteObject_thenReadIt_instanceVariableValuesShouldBeTheSame() { + public void testWriteObject_thenReadIt_instanceVariableValuesShouldBeTheSame() throws Exception { Foo foo = new Foo(1, "John"); - testWriteObject(foo); - Foo read = testReadObject(); - assertEquals(foo.getId(), read.getId()); - assertEquals(foo.getName(), read.getName()); - } + FileOutputStream fos = new FileOutputStream(fileName3); + ObjectOutputStream writer = new ObjectOutputStream(fos); + writer.writeObject(foo); + writer.close(); + Foo result = null; - public void testWriteCSVReport_thenReadAllData_shouldBeTheSame() { - Foo[] arr = new Foo[3]; - arr[0] = new Foo(1, "John"); - arr[1] = new Foo(2, "Adam"); - arr[2] = new Foo(3, "Jane"); - testWriteCSVReport(arr); - Foo[] read = testReadCSVReport(); - assertEquals(arr[0].getId(), read[0].getId()); - assertEquals(arr[2].getName(), read[2].getName()); - assertEquals(arr[1].getId(), read[1].getId()); + FileInputStream fis = new FileInputStream(fileName3); + ObjectInputStream reader = new ObjectInputStream(fis); + result = (Foo) reader.readObject(); + reader.close(); + + assertEquals(foo.getId(), result.getId()); + assertEquals(foo.getName(), result.getName()); } -//================= writer methods======== - // use DataOutputStream to write primitive data types - public void testWriteDouble(double value) { - DataOutputStream stream; - try { - FileOutputStream fos = new FileOutputStream(fileName1); - stream = new DataOutputStream(new BufferedOutputStream(fos)); - stream.writeDouble(value); - stream.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } + + public void testFileLock() throws IOException { + RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); + FileChannel channel = stream.getChannel(); + + FileLock lock = channel.tryLock(); + stream.writeChars("test lock"); + lock.release(); + + stream.close(); + channel.close(); } + + public void testCreateFile_thenCheckIfItExists_thenDeleteAndCheckIfExist() throws IOException{ + File file = new File("test_create.txt"); + file.createNewFile(); + assertTrue(file.exists()); + file.delete(); + assertFalse(file.exists()); + } + + public void testWriteStringUsingFileChannel() throws IOException{ + RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); + FileChannel channel = stream.getChannel(); + String value = "Hello"; + byte[] strBytes = value.getBytes(); + ByteBuffer buffer = ByteBuffer.allocate(strBytes.length); + buffer.put(strBytes); + buffer.flip(); + channel.write(buffer); + stream.close(); + channel.close(); + + RandomAccessFile reader = new RandomAccessFile(fileName5, "r"); + assertEquals(value , reader.readLine()); + reader.close(); + + } + // use RandomAccessFile to write data at specific position in the file public void testWriteToPosition(int data, long position) { try { @@ -98,50 +140,7 @@ public void testWriteToPosition(int data, long position) { } } - // use ObjectOutputStream to write object - public void testWriteObject(Foo foo) { - FileOutputStream fos; - try { - fos = new FileOutputStream(fileName3); - ObjectOutputStream writer = new ObjectOutputStream(fos); - writer.writeObject(foo); - writer.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } - } - - // use CSVWriter to write CSV data - public void testWriteCSVReport(Foo[] array) { - try { - CSVWriter writer = new CSVWriter(new FileWriter(fileName4, true), ','); - int len = array.length; - for (int i = 0; i < len; i++) { - writer.writeNext(array[i].toStringArray()); - } - writer.close(); - } catch (IOException e) { - System.out.println(e.getLocalizedMessage()); - } - } - - - //=============== read methods ====== - // use DataInputStream - public double testReadDouble() { - DataInputStream stream; - double result = 0; - try { - FileInputStream fis = new FileInputStream(fileName1); - stream = new DataInputStream(new BufferedInputStream(fis)); - result = stream.readDouble(); - stream.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } - return result; - } // use RandomAccessFile to read data from specific position in the file public int testReadFromPosition(long position) { @@ -157,46 +156,8 @@ public int testReadFromPosition(long position) { return result; } - // use ObjectInputStream to read object - public Foo testReadObject() { - FileInputStream fis; - Foo result = null; - try { - fis = new FileInputStream(fileName3); - ObjectInputStream reader = new ObjectInputStream(fis); - result = (Foo) reader.readObject(); - reader.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } - return result; - } - - // use CSVReader to read CSV data - public Foo[] testReadCSVReport() { - CSVReader reader; - Foo[] result = null; - try { - reader = new CSVReader(new FileReader(fileName4)); - List list = reader.readAll(); - int size = list.size(); - result = new Foo[size]; - Foo temp; - String[] currentItem; - for (int i = 0; i < size; i++) { - temp = new Foo(); - currentItem = (String[]) list.get(i); - temp.setId(Long.parseLong(currentItem[0])); - temp.setName(currentItem[1]); - result[i] = temp; - } - reader.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } - return result; - } - + + } From a06fead42f13c43289064b4d1f01dfb7a3a81a3e Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 29 Sep 2014 01:12:17 +0200 Subject: [PATCH 648/796] Modify test methods --- .../java/org/baeldung/java/io/TestWriter.java | 48 +++++-------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index 7605856b34f9..fbdae0de087f 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -3,20 +3,16 @@ import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.PrintWriter; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; - -import main.Foo; +import java.nio.channels.OverlappingFileLockException; import junit.framework.TestCase; public class TestWriter extends TestCase { @@ -24,7 +20,6 @@ public class TestWriter extends TestCase { private String fileName = "test.txt"; private String fileName1 = "test1.txt"; private String fileName2 = "test2.txt"; - private String fileName3 = "test3.txt"; private String fileName4 = "test4.txt"; private String fileName5 = "test5.txt"; @@ -40,14 +35,14 @@ protected void tearDown() throws Exception { super.tearDown(); } - public void testWriteFormattedStringUsingPrintWriter() throws IOException{ + public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException{ FileWriter fileWriter = new FileWriter(fileName); PrintWriter printWriter = new PrintWriter(fileWriter); printWriter.printf("Product name is %s and its price is %d $","iPhone",1000); printWriter.close(); } - public void testWriteStringWithDataOutputStream_thenReadIt_shouldBeTheSame() throws IOException { + public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { String value = "Hello"; FileOutputStream fos = new FileOutputStream(fileName1); DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); @@ -63,7 +58,7 @@ public void testWriteStringWithDataOutputStream_thenReadIt_shouldBeTheSame() thr assertEquals(value, result); } - public void testWriteToPosition_editValueIfSpecificPos_shouldChange() { + public void whenWriteToPositionAndEditIt_thenItShouldChange() { int data1 = 2014; int data2 = 1500; testWriteToPosition(data1, 4); @@ -72,28 +67,18 @@ public void testWriteToPosition_editValueIfSpecificPos_shouldChange() { assertEquals(data2, testReadFromPosition(4)); } - public void testWriteObject_thenReadIt_instanceVariableValuesShouldBeTheSame() throws Exception { - Foo foo = new Foo(1, "John"); - FileOutputStream fos = new FileOutputStream(fileName3); - ObjectOutputStream writer = new ObjectOutputStream(fos); - writer.writeObject(foo); - writer.close(); - Foo result = null; - - FileInputStream fis = new FileInputStream(fileName3); - ObjectInputStream reader = new ObjectInputStream(fis); - result = (Foo) reader.readObject(); - reader.close(); - - assertEquals(foo.getId(), result.getId()); - assertEquals(foo.getName(), result.getName()); - } - public void testFileLock() throws IOException { + public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); FileChannel channel = stream.getChannel(); - FileLock lock = channel.tryLock(); + FileLock lock = null; + try { + lock = channel.tryLock(); + } catch (OverlappingFileLockException e) { + stream.close(); + channel.close(); + } stream.writeChars("test lock"); lock.release(); @@ -102,15 +87,8 @@ public void testFileLock() throws IOException { } - public void testCreateFile_thenCheckIfItExists_thenDeleteAndCheckIfExist() throws IOException{ - File file = new File("test_create.txt"); - file.createNewFile(); - assertTrue(file.exists()); - file.delete(); - assertFalse(file.exists()); - } - public void testWriteStringUsingFileChannel() throws IOException{ + public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException{ RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); FileChannel channel = stream.getChannel(); String value = "Hello"; From 373758474041fa0d4b16a4155363093e6b016690 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 29 Sep 2014 15:15:49 +0200 Subject: [PATCH 649/796] Add few methods --- .../java/org/baeldung/java/io/TestWriter.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index fbdae0de087f..b8895f7f0a81 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -1,10 +1,14 @@ package test; import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.DataOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; @@ -13,6 +17,10 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + import junit.framework.TestCase; public class TestWriter extends TestCase { @@ -20,6 +28,7 @@ public class TestWriter extends TestCase { private String fileName = "test.txt"; private String fileName1 = "test1.txt"; private String fileName2 = "test2.txt"; + private String fileName3 = "test3.txt"; private String fileName4 = "test4.txt"; private String fileName5 = "test5.txt"; @@ -35,12 +44,36 @@ protected void tearDown() throws Exception { super.tearDown(); } + + public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException{ + String str = "Hello"; + BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); + writer.write(str); + writer.close(); + } + + public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException{ + String str = "World"; + BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3 , true)); + writer.append(' '); + writer.append(str); + writer.close(); + } + public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException{ FileWriter fileWriter = new FileWriter(fileName); PrintWriter printWriter = new PrintWriter(fileWriter); printWriter.printf("Product name is %s and its price is %d $","iPhone",1000); printWriter.close(); } + + public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException{ + String str = "Hello"; + FileOutputStream outputStream = new FileOutputStream(fileName3); + byte[] strToBytes = str.getBytes(); + outputStream.write(strToBytes); + outputStream.close(); + } public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { String value = "Hello"; @@ -106,6 +139,30 @@ public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOE } + public void whenWriteToTmpFile_thenCorrect() throws IOException{ + String toWrite = "Hello"; + File tmpFile = File.createTempFile("test", ".tmp"); + FileWriter writer = new FileWriter(tmpFile); + writer.write(toWrite); + writer.close(); + + BufferedReader reader = new BufferedReader(new FileReader(tmpFile)); + assertEquals(toWrite, reader.readLine()); + reader.close(); + } + + public void whenWriteUsingJava7_thenCorrect() throws IOException{ + String str = "Hello"; + + Path path = Paths.get(fileName3); + byte[] strToBytes = str.getBytes(); + + Files.write(path, strToBytes); + + String read = Files.readAllLines(path).get(0); + assertEquals(str, read); + } + // use RandomAccessFile to write data at specific position in the file public void testWriteToPosition(int data, long position) { try { From 0e3c0f36df187e7319b13bf7985d9fcf82bb7c69 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 30 Sep 2014 01:42:55 +0300 Subject: [PATCH 650/796] cleanup work --- .../java/org/baeldung/java/io/TestWriter.java | 146 +++++++++--------- 1 file changed, 69 insertions(+), 77 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index b8895f7f0a81..0c794d08099c 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -1,4 +1,4 @@ -package test; +package org.baeldung.java.io; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -32,167 +32,159 @@ public class TestWriter extends TestCase { private String fileName4 = "test4.txt"; private String fileName5 = "test5.txt"; - public TestWriter(String name) { + public TestWriter(final String name) { super(name); } + @Override protected void setUp() throws Exception { super.setUp(); } + @Override protected void tearDown() throws Exception { super.tearDown(); } - - - public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException{ - String str = "Hello"; - BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); + + public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException { + final String str = "Hello"; + final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); writer.write(str); writer.close(); } - - public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException{ - String str = "World"; - BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3 , true)); + + public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException { + final String str = "World"; + final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3, true)); writer.append(' '); writer.append(str); writer.close(); } - - public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException{ - FileWriter fileWriter = new FileWriter(fileName); - PrintWriter printWriter = new PrintWriter(fileWriter); - printWriter.printf("Product name is %s and its price is %d $","iPhone",1000); + + public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException { + final FileWriter fileWriter = new FileWriter(fileName); + final PrintWriter printWriter = new PrintWriter(fileWriter); + printWriter.printf("Product name is %s and its price is %d $", "iPhone", 1000); printWriter.close(); } - - public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException{ - String str = "Hello"; - FileOutputStream outputStream = new FileOutputStream(fileName3); - byte[] strToBytes = str.getBytes(); + + public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException { + final String str = "Hello"; + final FileOutputStream outputStream = new FileOutputStream(fileName3); + final byte[] strToBytes = str.getBytes(); outputStream.write(strToBytes); outputStream.close(); } public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { - String value = "Hello"; - FileOutputStream fos = new FileOutputStream(fileName1); - DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); + final String value = "Hello"; + final FileOutputStream fos = new FileOutputStream(fileName1); + final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); outStream.writeUTF(value); outStream.close(); - + String result; - FileInputStream fis = new FileInputStream(fileName1); - DataInputStream reader = new DataInputStream(fis); + final FileInputStream fis = new FileInputStream(fileName1); + final DataInputStream reader = new DataInputStream(fis); result = reader.readUTF(); reader.close(); - + assertEquals(value, result); } public void whenWriteToPositionAndEditIt_thenItShouldChange() { - int data1 = 2014; - int data2 = 1500; + final int data1 = 2014; + final int data2 = 1500; testWriteToPosition(data1, 4); assertEquals(data1, testReadFromPosition(4)); testWriteToPosition(data2, 4); assertEquals(data2, testReadFromPosition(4)); } - public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { - RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); - FileChannel channel = stream.getChannel(); + final RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); + final FileChannel channel = stream.getChannel(); FileLock lock = null; try { lock = channel.tryLock(); - } catch (OverlappingFileLockException e) { + } catch (final OverlappingFileLockException e) { stream.close(); channel.close(); } stream.writeChars("test lock"); lock.release(); - + stream.close(); channel.close(); } - - - public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException{ - RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); - FileChannel channel = stream.getChannel(); - String value = "Hello"; - byte[] strBytes = value.getBytes(); - ByteBuffer buffer = ByteBuffer.allocate(strBytes.length); + public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException { + final RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); + final FileChannel channel = stream.getChannel(); + final String value = "Hello"; + final byte[] strBytes = value.getBytes(); + final ByteBuffer buffer = ByteBuffer.allocate(strBytes.length); buffer.put(strBytes); buffer.flip(); - channel.write(buffer); + channel.write(buffer); stream.close(); channel.close(); - - RandomAccessFile reader = new RandomAccessFile(fileName5, "r"); - assertEquals(value , reader.readLine()); + + final RandomAccessFile reader = new RandomAccessFile(fileName5, "r"); + assertEquals(value, reader.readLine()); reader.close(); - + } - - public void whenWriteToTmpFile_thenCorrect() throws IOException{ - String toWrite = "Hello"; - File tmpFile = File.createTempFile("test", ".tmp"); - FileWriter writer = new FileWriter(tmpFile); + + public void whenWriteToTmpFile_thenCorrect() throws IOException { + final String toWrite = "Hello"; + final File tmpFile = File.createTempFile("test", ".tmp"); + final FileWriter writer = new FileWriter(tmpFile); writer.write(toWrite); writer.close(); - - BufferedReader reader = new BufferedReader(new FileReader(tmpFile)); + + final BufferedReader reader = new BufferedReader(new FileReader(tmpFile)); assertEquals(toWrite, reader.readLine()); reader.close(); } - - public void whenWriteUsingJava7_thenCorrect() throws IOException{ - String str = "Hello"; - - Path path = Paths.get(fileName3); - byte[] strToBytes = str.getBytes(); - + + public void whenWriteUsingJava7_thenCorrect() throws IOException { + final String str = "Hello"; + + final Path path = Paths.get(fileName3); + final byte[] strToBytes = str.getBytes(); + Files.write(path, strToBytes); - - String read = Files.readAllLines(path).get(0); + + final String read = Files.readAllLines(path).get(0); assertEquals(str, read); } - + // use RandomAccessFile to write data at specific position in the file - public void testWriteToPosition(int data, long position) { + public void testWriteToPosition(final int data, final long position) { try { - RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); + final RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); writer.seek(position); writer.writeInt(data); writer.close(); - } catch (Exception e) { + } catch (final Exception e) { System.out.println(e.getLocalizedMessage()); } } - - // use RandomAccessFile to read data from specific position in the file - public int testReadFromPosition(long position) { + public int testReadFromPosition(final long position) { int result = 0; try { - RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); + final RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); reader.seek(position); result = reader.readInt(); reader.close(); - } catch (Exception e) { + } catch (final Exception e) { System.out.println(e.getLocalizedMessage()); } return result; } - - - - } From 426af122003f14851a997fb885aabf802fc02312 Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 30 Sep 2014 01:47:23 +0300 Subject: [PATCH 651/796] testing work for writing to fiule --- .../java/org/baeldung/java/io/TestWriter.java | 60 ++++++++----------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index 0c794d08099c..43fd0c148f20 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -1,5 +1,7 @@ package org.baeldung.java.io; +import static org.junit.Assert.assertEquals; + import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -21,9 +23,9 @@ import java.nio.file.Path; import java.nio.file.Paths; -import junit.framework.TestCase; +import org.junit.Test; -public class TestWriter extends TestCase { +public class TestWriter { private String fileName = "test.txt"; private String fileName1 = "test1.txt"; @@ -32,20 +34,7 @@ public class TestWriter extends TestCase { private String fileName4 = "test4.txt"; private String fileName5 = "test5.txt"; - public TestWriter(final String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException { final String str = "Hello"; final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); @@ -53,6 +42,7 @@ public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException writer.close(); } + @Test public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException { final String str = "World"; final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3, true)); @@ -61,6 +51,7 @@ public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() writer.close(); } + @Test public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException { final FileWriter fileWriter = new FileWriter(fileName); final PrintWriter printWriter = new PrintWriter(fileWriter); @@ -68,6 +59,7 @@ public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted printWriter.close(); } + @Test public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException { final String str = "Hello"; final FileOutputStream outputStream = new FileOutputStream(fileName3); @@ -76,6 +68,7 @@ public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOExceptio outputStream.close(); } + @Test public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { final String value = "Hello"; final FileOutputStream fos = new FileOutputStream(fileName1); @@ -92,7 +85,8 @@ public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws assertEquals(value, result); } - public void whenWriteToPositionAndEditIt_thenItShouldChange() { + @Test + public void whenWriteToPositionAndEditIt_thenItShouldChange() throws IOException { final int data1 = 2014; final int data2 = 1500; testWriteToPosition(data1, 4); @@ -101,6 +95,7 @@ public void whenWriteToPositionAndEditIt_thenItShouldChange() { assertEquals(data2, testReadFromPosition(4)); } + @Test public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { final RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); final FileChannel channel = stream.getChannel(); @@ -119,6 +114,7 @@ public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { channel.close(); } + @Test public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException { final RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); final FileChannel channel = stream.getChannel(); @@ -137,6 +133,7 @@ public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOE } + @Test public void whenWriteToTmpFile_thenCorrect() throws IOException { final String toWrite = "Hello"; final File tmpFile = File.createTempFile("test", ".tmp"); @@ -149,6 +146,7 @@ public void whenWriteToTmpFile_thenCorrect() throws IOException { reader.close(); } + @Test public void whenWriteUsingJava7_thenCorrect() throws IOException { final String str = "Hello"; @@ -162,28 +160,20 @@ public void whenWriteUsingJava7_thenCorrect() throws IOException { } // use RandomAccessFile to write data at specific position in the file - public void testWriteToPosition(final int data, final long position) { - try { - final RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); - writer.seek(position); - writer.writeInt(data); - writer.close(); - } catch (final Exception e) { - System.out.println(e.getLocalizedMessage()); - } + private void testWriteToPosition(final int data, final long position) throws IOException { + final RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); + writer.seek(position); + writer.writeInt(data); + writer.close(); } // use RandomAccessFile to read data from specific position in the file - public int testReadFromPosition(final long position) { + private int testReadFromPosition(final long position) throws IOException { int result = 0; - try { - final RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); - reader.seek(position); - result = reader.readInt(); - reader.close(); - } catch (final Exception e) { - System.out.println(e.getLocalizedMessage()); - } + final RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); + reader.seek(position); + result = reader.readInt(); + reader.close(); return result; } From 2bdfde779578e37ad6656bdd3f91eb2829df4660 Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 30 Sep 2014 01:46:29 +0200 Subject: [PATCH 652/796] change test files location --- .../java/org/baeldung/java/io/TestWriter.java | 200 ++++++++---------- 1 file changed, 91 insertions(+), 109 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java index b8895f7f0a81..302c62f4b633 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/TestWriter.java @@ -1,4 +1,6 @@ -package test; +package org.baeldung.java.io; + +import static org.junit.Assert.assertEquals; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -21,178 +23,158 @@ import java.nio.file.Path; import java.nio.file.Paths; -import junit.framework.TestCase; - -public class TestWriter extends TestCase { +import org.junit.Test; - private String fileName = "test.txt"; - private String fileName1 = "test1.txt"; - private String fileName2 = "test2.txt"; - private String fileName3 = "test3.txt"; - private String fileName4 = "test4.txt"; - private String fileName5 = "test5.txt"; - - public TestWriter(String name) { - super(name); - } +public class TestWriter { - protected void setUp() throws Exception { - super.setUp(); - } + private String fileName = "src/test/resources/test_write.txt"; + private String fileName1 = "src/test/resources/test_write_1.txt"; + private String fileName2 = "src/test/resources/test_write_2.txt"; + private String fileName3 = "src/test/resources/test_write_3.txt"; + private String fileName4 = "src/test/resources/test_write_4.txt"; + private String fileName5 = "src/test/resources/test_write_5.txt"; - protected void tearDown() throws Exception { - super.tearDown(); - } - - - public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException{ - String str = "Hello"; - BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); + @Test + public void whenWriteStringUsingBufferedWritter_thenCorrect() throws IOException { + final String str = "Hello"; + final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3)); writer.write(str); writer.close(); } - - public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException{ - String str = "World"; - BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3 , true)); + + @Test + public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() throws IOException { + final String str = "World"; + final BufferedWriter writer = new BufferedWriter(new FileWriter(fileName3, true)); writer.append(' '); writer.append(str); writer.close(); } - - public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException{ - FileWriter fileWriter = new FileWriter(fileName); - PrintWriter printWriter = new PrintWriter(fileWriter); - printWriter.printf("Product name is %s and its price is %d $","iPhone",1000); + + @Test + public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException { + final FileWriter fileWriter = new FileWriter(fileName); + final PrintWriter printWriter = new PrintWriter(fileWriter); + printWriter.printf("Product name is %s and its price is %d $", "iPhone", 1000); printWriter.close(); } - - public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException{ - String str = "Hello"; - FileOutputStream outputStream = new FileOutputStream(fileName3); - byte[] strToBytes = str.getBytes(); + + @Test + public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException { + final String str = "Hello"; + final FileOutputStream outputStream = new FileOutputStream(fileName3); + final byte[] strToBytes = str.getBytes(); outputStream.write(strToBytes); outputStream.close(); } + @Test public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { - String value = "Hello"; - FileOutputStream fos = new FileOutputStream(fileName1); - DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); + final String value = "Hello"; + final FileOutputStream fos = new FileOutputStream(fileName1); + final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); outStream.writeUTF(value); outStream.close(); - + String result; - FileInputStream fis = new FileInputStream(fileName1); - DataInputStream reader = new DataInputStream(fis); + final FileInputStream fis = new FileInputStream(fileName1); + final DataInputStream reader = new DataInputStream(fis); result = reader.readUTF(); reader.close(); - + assertEquals(value, result); } - public void whenWriteToPositionAndEditIt_thenItShouldChange() { - int data1 = 2014; - int data2 = 1500; + @Test + public void whenWriteToPositionAndEditIt_thenItShouldChange() throws IOException { + final int data1 = 2014; + final int data2 = 1500; testWriteToPosition(data1, 4); assertEquals(data1, testReadFromPosition(4)); testWriteToPosition(data2, 4); assertEquals(data2, testReadFromPosition(4)); } - + @Test public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { - RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); - FileChannel channel = stream.getChannel(); + final RandomAccessFile stream = new RandomAccessFile(fileName4, "rw"); + final FileChannel channel = stream.getChannel(); FileLock lock = null; try { lock = channel.tryLock(); - } catch (OverlappingFileLockException e) { + } catch (final OverlappingFileLockException e) { stream.close(); channel.close(); } stream.writeChars("test lock"); lock.release(); - + stream.close(); channel.close(); } - - - public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException{ - RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); - FileChannel channel = stream.getChannel(); - String value = "Hello"; - byte[] strBytes = value.getBytes(); - ByteBuffer buffer = ByteBuffer.allocate(strBytes.length); + @Test + public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException { + final RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); + final FileChannel channel = stream.getChannel(); + final String value = "Hello"; + final byte[] strBytes = value.getBytes(); + final ByteBuffer buffer = ByteBuffer.allocate(strBytes.length); buffer.put(strBytes); buffer.flip(); - channel.write(buffer); + channel.write(buffer); stream.close(); channel.close(); - - RandomAccessFile reader = new RandomAccessFile(fileName5, "r"); - assertEquals(value , reader.readLine()); + + final RandomAccessFile reader = new RandomAccessFile(fileName5, "r"); + assertEquals(value, reader.readLine()); reader.close(); - + } - - public void whenWriteToTmpFile_thenCorrect() throws IOException{ - String toWrite = "Hello"; - File tmpFile = File.createTempFile("test", ".tmp"); - FileWriter writer = new FileWriter(tmpFile); + + @Test + public void whenWriteToTmpFile_thenCorrect() throws IOException { + final String toWrite = "Hello"; + final File tmpFile = File.createTempFile("test", ".tmp"); + final FileWriter writer = new FileWriter(tmpFile); writer.write(toWrite); writer.close(); - - BufferedReader reader = new BufferedReader(new FileReader(tmpFile)); + + final BufferedReader reader = new BufferedReader(new FileReader(tmpFile)); assertEquals(toWrite, reader.readLine()); reader.close(); } - - public void whenWriteUsingJava7_thenCorrect() throws IOException{ - String str = "Hello"; - - Path path = Paths.get(fileName3); - byte[] strToBytes = str.getBytes(); - + + @Test + public void whenWriteUsingJava7_thenCorrect() throws IOException { + final String str = "Hello"; + + final Path path = Paths.get(fileName3); + final byte[] strToBytes = str.getBytes(); + Files.write(path, strToBytes); - - String read = Files.readAllLines(path).get(0); + + final String read = Files.readAllLines(path).get(0); assertEquals(str, read); } - + // use RandomAccessFile to write data at specific position in the file - public void testWriteToPosition(int data, long position) { - try { - RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); - writer.seek(position); - writer.writeInt(data); - writer.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } + private void testWriteToPosition(final int data, final long position) throws IOException { + final RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); + writer.seek(position); + writer.writeInt(data); + writer.close(); } - - // use RandomAccessFile to read data from specific position in the file - public int testReadFromPosition(long position) { + private int testReadFromPosition(final long position) throws IOException { int result = 0; - try { - RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); - reader.seek(position); - result = reader.readInt(); - reader.close(); - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()); - } + final RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); + reader.seek(position); + result = reader.readInt(); + reader.close(); return result; } - - - - -} +} \ No newline at end of file From 3fd347537cd4244e9ce6ccd5e878b9fd761f65bb Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 30 Sep 2014 20:53:33 +0300 Subject: [PATCH 653/796] small testing modification in core java --- ...stWriter.java => JavaWriteToFileTest.java} | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) rename core-java/src/test/java/org/baeldung/java/io/{TestWriter.java => JavaWriteToFileTest.java} (86%) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java b/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java similarity index 86% rename from core-java/src/test/java/org/baeldung/java/io/TestWriter.java rename to core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java index 985124ac38f8..88173e80aa1d 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestWriter.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java @@ -25,7 +25,7 @@ import org.junit.Test; -public class TestWriter { +public class JavaWriteToFileTest { private String fileName = "src/test/resources/test_write.txt"; private String fileName1 = "src/test/resources/test_write_1.txt"; @@ -68,8 +68,10 @@ public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOExceptio outputStream.close(); } + // + @Test - public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws IOException { + public void givenWritingToFile_whenUsingDataOutputStream_thenCorrect() throws IOException { final String value = "Hello"; final FileOutputStream fos = new FileOutputStream(fileName1); final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(fos)); @@ -86,13 +88,13 @@ public void whenWriteStringWithDataOutputStream_thenReadShouldBeTheSame() throws } @Test - public void whenWriteToPositionAndEditIt_thenItShouldChange() throws IOException { + public void whenWritingToSpecificPositionInFile_thenCorrect() throws IOException { final int data1 = 2014; final int data2 = 1500; - testWriteToPosition(data1, 4); - assertEquals(data1, testReadFromPosition(4)); - testWriteToPosition(data2, 4); - assertEquals(data2, testReadFromPosition(4)); + writeToPosition(fileName2, data1, 4); + assertEquals(data1, readFromPosition(fileName2, 4)); + writeToPosition(fileName2, data2, 4); + assertEquals(data2, readFromPosition(fileName2, 4)); } @Test @@ -115,7 +117,7 @@ public void whenTryToLockFile_thenItShouldBeLocked() throws IOException { } @Test - public void whenWriteStringUsingFileChannel_thenReadShouldBeTheSame() throws IOException { + public void givenWritingToFile_whenUsingFileChannel_thenCorrect() throws IOException { final RandomAccessFile stream = new RandomAccessFile(fileName5, "rw"); final FileChannel channel = stream.getChannel(); final String value = "Hello"; @@ -147,7 +149,7 @@ public void whenWriteToTmpFile_thenCorrect() throws IOException { } @Test - public void whenWriteUsingJava7_thenCorrect() throws IOException { + public void givenUsingJava7_whenWritingToFile_thenCorrect() throws IOException { final String str = "Hello"; final Path path = Paths.get(fileName3); @@ -159,23 +161,24 @@ public void whenWriteUsingJava7_thenCorrect() throws IOException { assertEquals(str, read); } + // UTIL + // use RandomAccessFile to write data at specific position in the file - private void testWriteToPosition(final int data, final long position) throws IOException { - final RandomAccessFile writer = new RandomAccessFile(fileName2, "rw"); + private void writeToPosition(final String filename, final int data, final long position) throws IOException { + final RandomAccessFile writer = new RandomAccessFile(filename, "rw"); writer.seek(position); writer.writeInt(data); writer.close(); } // use RandomAccessFile to read data from specific position in the file - private int testReadFromPosition(final long position) throws IOException { + private int readFromPosition(final String filename, final long position) throws IOException { int result = 0; - final RandomAccessFile reader = new RandomAccessFile(fileName2, "r"); + final RandomAccessFile reader = new RandomAccessFile(filename, "r"); reader.seek(position); result = reader.readInt(); reader.close(); return result; } - } From 2a5d5481fc66294b728f87676c5657639a001d9b Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 1 Oct 2014 20:30:17 +0300 Subject: [PATCH 654/796] java io work --- .../test/java/org/baeldung/java/io/JavaWriteToFileTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java index 88173e80aa1d..696f24cd5dcf 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaWriteToFileTest.java @@ -52,15 +52,16 @@ public void whenAppendStringUsingBufferedWritter_thenOldContentShouldExistToo() } @Test - public void whenWriteFormattedStringUsingPrintWriter_thenOutputShouldBeFormatted() throws IOException { + public void givenWritingStringToFile_whenUsingPrintWriter_thenCorrect() throws IOException { final FileWriter fileWriter = new FileWriter(fileName); final PrintWriter printWriter = new PrintWriter(fileWriter); + printWriter.print("Some String"); printWriter.printf("Product name is %s and its price is %d $", "iPhone", 1000); printWriter.close(); } @Test - public void whenWriteStringUsingFileOutputStream_thenCorrect() throws IOException { + public void givenWritingStringToFile_whenUsingFileOutputStream_thenCorrect() throws IOException { final String str = "Hello"; final FileOutputStream outputStream = new FileOutputStream(fileName3); final byte[] strToBytes = str.getBytes(); From 1e087d811921a2737ac674f1d013a1181710f798 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Oct 2014 00:48:38 +0300 Subject: [PATCH 655/796] spring minor upgrade g --- core-java/pom.xml | 2 +- gson/pom.xml | 2 +- guava/pom.xml | 2 +- httpclient/pom.xml | 2 +- jackson/pom.xml | 2 +- mockito/pom.xml | 2 +- rest-testing/pom.xml | 2 +- spring-all/pom.xml | 2 +- spring-exceptions/pom.xml | 2 +- spring-hibernate3/pom.xml | 2 +- spring-hibernate4/pom.xml | 2 +- spring-jpa/pom.xml | 2 +- spring-mvc-java/pom.xml | 2 +- spring-mvc-no-xml/pom.xml | 2 +- spring-mvc-xml/pom.xml | 2 +- spring-rest/pom.xml | 2 +- spring-security-basic-auth/pom.xml | 2 +- spring-security-mvc-custom/pom.xml | 2 +- spring-security-mvc-digest-auth/pom.xml | 2 +- spring-security-mvc-login/pom.xml | 2 +- spring-security-mvc-persisted-remember-me/pom.xml | 2 +- spring-security-mvc-session/pom.xml | 2 +- spring-security-rest-basic-auth/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-digest-auth/pom.xml | 2 +- spring-security-rest-full/pom.xml | 5 ++--- spring-security-rest/pom.xml | 2 +- 27 files changed, 28 insertions(+), 29 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index de3631d7575c..294364d22cd5 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -145,7 +145,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/gson/pom.xml b/gson/pom.xml index 8b86c587605c..827f8a737825 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -114,7 +114,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/guava/pom.xml b/guava/pom.xml index ad82de3d678a..1dfbd626d1a8 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -94,7 +94,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 0e86cd0cd2af..355dd40ac756 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -149,7 +149,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/jackson/pom.xml b/jackson/pom.xml index c38eafda7d98..c08d4863b53a 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -114,7 +114,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/mockito/pom.xml b/mockito/pom.xml index e350e0fe70d2..caa2ceb1a3b3 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -89,7 +89,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 866428f4aa97..2385c0126027 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -138,7 +138,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 2.4.2 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index e7350e46128b..5fabeefd670d 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -192,7 +192,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE 3.18.1-GA 1.2 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index dbe6a13d709b..f93a0b4c3d18 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -204,7 +204,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE 3.18.1-GA 1.2 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 020140d902dd..3a4fcd2fd567 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -163,7 +163,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE 3.18.1-GA diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 387ffd3ff9fe..26c6d7ded1fb 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -170,7 +170,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE 3.18.1-GA diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 972f49ec1db8..7c83a549fdaf 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -165,7 +165,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 69d94ec34d4b..1df4984fba7a 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -141,7 +141,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index 5b906006c80a..0e772f03ddc9 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -145,7 +145,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 1.7.7 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 01eef969d40a..6537780ea289 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -147,7 +147,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 1.7.7 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index de9dbfc3e815..ef49fe227a13 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -202,7 +202,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 20403c12d049..a1f5f985a99a 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -226,7 +226,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 1c064d93bdc6..53aa2be09b3c 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -231,7 +231,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 162d0f61ee7b..cf3eadd68426 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -226,7 +226,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 9e5286a5c73d..b3e5d2593464 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -223,7 +223,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml index 843cf7789ac7..ccc9a289b6b6 100644 --- a/spring-security-mvc-persisted-remember-me/pom.xml +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -260,7 +260,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 26d4932c8ca0..60620f82de71 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -231,7 +231,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index a4eb760874a2..0fef185c0532 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -287,7 +287,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 15f50841bdfe..5551274cfd50 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -251,7 +251,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index f119377c5a99..e16839db6f79 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -275,7 +275,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 0431d94ad533..6f0208d323ec 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -1,5 +1,4 @@ - + 4.0.0 org.baeldung spring-security-rest-full @@ -371,7 +370,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 7d92c99e300e..09c15352f151 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -238,7 +238,7 @@ - 4.1.0.RELEASE + 4.1.1.RELEASE 3.2.5.RELEASE From f024fd8ebf54e37987c293a33d6694ce5a40da54 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 2 Oct 2014 01:26:27 +0300 Subject: [PATCH 656/796] fixing the xml maven dependency from hibernate --- spring-jpa/pom.xml | 7 ++++++- spring-security-login-error-handling/pom.xml | 5 +++++ spring-security-rest-full/pom.xml | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 7c83a549fdaf..c1d19ff0fc7e 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -30,10 +30,15 @@ hibernate-entitymanager ${hibernate.version} + + xml-apis + xml-apis + 1.4.01 + org.javassist javassist - 3.18.1-GA + 3.18.2-GA mysql diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml index 45ff89f52a01..0e35fd8070e4 100644 --- a/spring-security-login-error-handling/pom.xml +++ b/spring-security-login-error-handling/pom.xml @@ -87,6 +87,11 @@ org.hibernate hibernate-entitymanager + + xml-apis + xml-apis + 1.4.01 + org.hibernate hibernate-validator diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 6f0208d323ec..557c44d49075 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -113,10 +113,15 @@ hibernate-entitymanager ${hibernate.version} + + xml-apis + xml-apis + 1.4.01 + org.javassist javassist - 3.18.1-GA + 3.18.2-GA mysql From d1bc7d22cc8250d222d9d1da0c41fba4070eda60 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 2 Oct 2014 22:09:36 +0200 Subject: [PATCH 657/796] add TestReader to test Read from file --- .../java/org/baeldung/java/io/TestReader.java | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 core-java/src/test/java/org/baeldung/java/io/TestReader.java diff --git a/core-java/src/test/java/org/baeldung/java/io/TestReader.java b/core-java/src/test/java/org/baeldung/java/io/TestReader.java new file mode 100644 index 000000000000..517eac9f67a1 --- /dev/null +++ b/core-java/src/test/java/org/baeldung/java/io/TestReader.java @@ -0,0 +1,247 @@ +package org.baeldung.java.io; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.RandomAccessFile; +import java.io.SequenceInputStream; +import java.io.StreamTokenizer; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Enumeration; +import java.util.Scanner; +import java.util.Vector; + +import org.junit.Test; + + +/* +MappedByteBuffer + + */ +public class TestReader { + + @Test + public void whenReadWithBufferedReader_thenCorrect() throws IOException { + final String str = "Hello world"; + + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); + final String currentLine = reader.readLine(); + reader.close(); + + assertEquals(str, currentLine); + } + + @Test + public void whenReadWithScanner_thenCorrect() throws IOException { + final String str = "Hello world 1 2,3,4"; + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final Scanner scanner = new Scanner(new File("src/test/resources/test_read.txt")); + scanner.useDelimiter(" "); + + assertTrue(scanner.hasNext()); + assertEquals("Hello", scanner.next()); + assertEquals("world", scanner.next()); + assertEquals(1, scanner.nextInt()); + + scanner.useDelimiter(",| "); + + assertTrue(scanner.hasNextInt()); + assertEquals(2, scanner.nextInt()); + assertEquals(3, scanner.nextInt()); + assertEquals(4, scanner.nextInt()); + + scanner.close(); + + } + + @Test + public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException { + final String str = "Hello 1"; + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final FileReader reader = new FileReader("src/test/resources/test_read.txt"); + final StreamTokenizer tokenizer = new StreamTokenizer(reader); + + tokenizer.nextToken(); + assertEquals(StreamTokenizer.TT_WORD, tokenizer.ttype); + assertEquals("Hello", tokenizer.sval); + tokenizer.nextToken(); + assertEquals(StreamTokenizer.TT_NUMBER, tokenizer.ttype); + assertEquals(1, tokenizer.nval, 0.0000001); + + tokenizer.nextToken(); + assertEquals(StreamTokenizer.TT_EOF, tokenizer.ttype); + reader.close(); + } + + @Test + public void whenReadWithDataInputStream_thenCorrect() throws IOException { + final String value = "Hello"; + final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("src/test/resources/test_read.txt"))); + outStream.writeUTF(value); + outStream.close(); + + String result; + final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read.txt")); + result = reader.readUTF(); + reader.close(); + + assertEquals(value, result); + } + + public void whenReadTwoFilesWithSequenceInputStream_thenCorrect() throws IOException { + final int value1 = 2000; + final int value2 = 5000; + FileOutputStream writer = new FileOutputStream("src/test/resources/test_read.txt"); + writer.write(value1); + writer.close(); + writer = new FileOutputStream("src/test/resources/test_read1.txt"); + writer.write(value2); + writer.close(); + + final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read.txt"); + final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read1.txt"); + + final SequenceInputStream sequence = new SequenceInputStream(stream1, stream2); + final DataInputStream reader = new DataInputStream(sequence); + + assertEquals(value1, reader.readInt()); + assertEquals(value2, reader.readInt()); + + reader.close(); + stream2.close(); + } + + @Test + public void whenReadAllFilesInFolder_thenCorrect() throws IOException { + + final File dir = new File("src/test/resources"); + final File[] allFiles = dir.listFiles(); + final int noOfFiles = allFiles.length; + + final Vector allStreams = new Vector(); + + for (int i = 0; i < noOfFiles; i++) { + allStreams.add(new FileInputStream(allFiles[i])); + } + + final Enumeration enu = allStreams.elements(); + final SequenceInputStream sequence = new SequenceInputStream(enu); + + final BufferedReader reader = new BufferedReader(new InputStreamReader(sequence)); + + String line = reader.readLine(); + while (line != null) { + line = reader.readLine(); + } + reader.close(); + sequence.close(); + } + + @Test + public void whenReadUTFEncodedFile_thenCorrect() throws IOException { + final String str = "é’空"; + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read.txt"), "UTF-8")); + final String currentLine = reader.readLine(); + reader.close(); + + assertEquals(str, currentLine); + } + + @Test + public void whenReadFileContentsIntoString_thenCorrect() throws IOException { + final String str = "Hello world \n Test line \n"; + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); + final StringBuilder builder = new StringBuilder(); + String currentLine = reader.readLine(); + while (currentLine != null) { + builder.append(currentLine); + builder.append("\n"); + currentLine = reader.readLine(); + } + + reader.close(); + + assertEquals(str, builder.toString()); + } + + @Test + public void whenReadWithFileChannel_thenCorrect() throws IOException { + final String str = "Hello world"; + final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); + writer.write(str); + writer.close(); + + final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.txt", "r"); + final FileChannel channel = reader.getChannel(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) + bufferSize = (int) channel.size(); + final ByteBuffer buff = ByteBuffer.allocate(bufferSize); + channel.read(buff); + buff.flip(); + assertEquals(str, new String(buff.array())); + channel.close(); + reader.close(); + } + + @Test + public void whenReadSmallFileJava7_thenCorrect() throws IOException { + final String str = "Hello world"; + + final Path path = Paths.get("src/test/resources/test_read.txt"); + final byte[] strToBytes = str.getBytes(); + Files.write(path, strToBytes); + + final String read = Files.readAllLines(path).get(0); + assertEquals(str, read); + } + + @Test + public void whenReadLargeFileJava7_thenCorrect() throws IOException { + final String str = "Hello world"; + + final Path path = Paths.get("src/test/resources/test_read.txt"); + final byte[] strToBytes = str.getBytes(); + Files.write(path, strToBytes); + + final BufferedReader reader = Files.newBufferedReader(path); + final String line = reader.readLine(); + assertEquals(str, line); + } + +} From 00b5f89e87ace110a3d060b67334b084fbf66e60 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 5 Oct 2014 17:27:27 +0300 Subject: [PATCH 658/796] minor cleanup in java tests --- core-java/pom.xml | 2 +- .../test/java/org/baeldung/java/CoreJavaRandomUnitTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 294364d22cd5..a96da6761f82 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -163,7 +163,7 @@ 5.1.2.Final - 17.0 + 17.0 3.3.2 diff --git a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java index 95cd1b7c5044..2b688ecb1013 100644 --- a/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java @@ -1,5 +1,6 @@ package org.baeldung.java; +import java.nio.charset.Charset; import java.util.Random; import org.apache.commons.lang3.RandomStringUtils; @@ -151,7 +152,7 @@ public void givenUsingApache_whenGeneratingRandomDoubleBounded_thenCorrect() { public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() { final byte[] array = new byte[7]; // length is bounded by 7 new Random().nextBytes(array); - final String generatedString = new String(array); + final String generatedString = new String(array, Charset.forName("UTF-8")); System.out.println(generatedString); } @@ -166,7 +167,7 @@ public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() final int randomLimitedInt = leftLimit + (int) (new Random().nextFloat() * (rightLimit - leftLimit)); buffer.append((char) randomLimitedInt); } - final String generatedString = new String(buffer); + final String generatedString = buffer.toString(); System.out.println(generatedString); } From ac8b5e38ae34eb5f7463734f484ce5e50b56111c Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 6 Oct 2014 02:11:34 +0200 Subject: [PATCH 659/796] Modify JavaReadFromFileTest --- ...tReader.java => JavaReadFromFileTest.java} | 136 +++++------------- 1 file changed, 35 insertions(+), 101 deletions(-) rename core-java/src/test/java/org/baeldung/java/io/{TestReader.java => JavaReadFromFileTest.java} (55%) diff --git a/core-java/src/test/java/org/baeldung/java/io/TestReader.java b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java similarity index 55% rename from core-java/src/test/java/org/baeldung/java/io/TestReader.java rename to core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java index 517eac9f67a1..5ad6959707bd 100644 --- a/core-java/src/test/java/org/baeldung/java/io/TestReader.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java @@ -3,16 +3,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.BufferedOutputStream; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.RandomAccessFile; @@ -23,9 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Enumeration; import java.util.Scanner; -import java.util.Vector; import org.junit.Test; @@ -34,31 +27,22 @@ MappedByteBuffer */ -public class TestReader { +public class JavaReadFromFileTest { @Test public void whenReadWithBufferedReader_thenCorrect() throws IOException { - final String str = "Hello world"; - - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); + final String expected_value = "Hello world"; final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); final String currentLine = reader.readLine(); reader.close(); - assertEquals(str, currentLine); + assertEquals(expected_value, currentLine); } @Test public void whenReadWithScanner_thenCorrect() throws IOException { - final String str = "Hello world 1 2,3,4"; - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); - - final Scanner scanner = new Scanner(new File("src/test/resources/test_read.txt")); + final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.txt")); scanner.useDelimiter(" "); assertTrue(scanner.hasNext()); @@ -66,6 +50,13 @@ public void whenReadWithScanner_thenCorrect() throws IOException { assertEquals("world", scanner.next()); assertEquals(1, scanner.nextInt()); + scanner.close(); + + } + + @Test + public void whenReadWithScannerTwoDelimiters_thenCorrect() throws IOException { + final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.txt")); scanner.useDelimiter(",| "); assertTrue(scanner.hasNextInt()); @@ -74,17 +65,11 @@ public void whenReadWithScanner_thenCorrect() throws IOException { assertEquals(4, scanner.nextInt()); scanner.close(); - } @Test public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException { - final String str = "Hello 1"; - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); - - final FileReader reader = new FileReader("src/test/resources/test_read.txt"); + final FileReader reader = new FileReader("src/test/resources/test_read3.txt"); final StreamTokenizer tokenizer = new StreamTokenizer(reader); tokenizer.nextToken(); @@ -101,90 +86,48 @@ public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException { @Test public void whenReadWithDataInputStream_thenCorrect() throws IOException { - final String value = "Hello"; - final DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("src/test/resources/test_read.txt"))); - outStream.writeUTF(value); - outStream.close(); + final String expected_value = "Hello"; String result; - final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read.txt")); + final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.txt")); result = reader.readUTF(); reader.close(); - assertEquals(value, result); + assertEquals(expected_value, result); } public void whenReadTwoFilesWithSequenceInputStream_thenCorrect() throws IOException { - final int value1 = 2000; - final int value2 = 5000; - FileOutputStream writer = new FileOutputStream("src/test/resources/test_read.txt"); - writer.write(value1); - writer.close(); - writer = new FileOutputStream("src/test/resources/test_read1.txt"); - writer.write(value2); - writer.close(); - - final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read.txt"); - final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read1.txt"); + final int expected_value1 = 2000; + final int expected_value2 = 5000; + + final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.txt"); + final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.txt"); final SequenceInputStream sequence = new SequenceInputStream(stream1, stream2); final DataInputStream reader = new DataInputStream(sequence); - assertEquals(value1, reader.readInt()); - assertEquals(value2, reader.readInt()); + assertEquals(expected_value1, reader.readInt()); + assertEquals(expected_value2, reader.readInt()); reader.close(); stream2.close(); } - @Test - public void whenReadAllFilesInFolder_thenCorrect() throws IOException { - - final File dir = new File("src/test/resources"); - final File[] allFiles = dir.listFiles(); - final int noOfFiles = allFiles.length; - - final Vector allStreams = new Vector(); - - for (int i = 0; i < noOfFiles; i++) { - allStreams.add(new FileInputStream(allFiles[i])); - } - - final Enumeration enu = allStreams.elements(); - final SequenceInputStream sequence = new SequenceInputStream(enu); - - final BufferedReader reader = new BufferedReader(new InputStreamReader(sequence)); - - String line = reader.readLine(); - while (line != null) { - line = reader.readLine(); - } - reader.close(); - sequence.close(); - } @Test public void whenReadUTFEncodedFile_thenCorrect() throws IOException { - final String str = "é’空"; - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); - - final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read.txt"), "UTF-8")); + final String expected_value = "é’空"; + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.txt"), "UTF-8")); final String currentLine = reader.readLine(); reader.close(); - assertEquals(str, currentLine); + assertEquals(expected_value, currentLine); } @Test public void whenReadFileContentsIntoString_thenCorrect() throws IOException { - final String str = "Hello world \n Test line \n"; - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); - - final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); + final String expected_value = "Hello world \n Test line \n"; + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.txt")); final StringBuilder builder = new StringBuilder(); String currentLine = reader.readLine(); while (currentLine != null) { @@ -195,16 +138,12 @@ public void whenReadFileContentsIntoString_thenCorrect() throws IOException { reader.close(); - assertEquals(str, builder.toString()); + assertEquals(expected_value, builder.toString()); } @Test public void whenReadWithFileChannel_thenCorrect() throws IOException { - final String str = "Hello world"; - final BufferedWriter writer = new BufferedWriter(new FileWriter("src/test/resources/test_read.txt")); - writer.write(str); - writer.close(); - + final String expected_value = "Hello world"; final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.txt", "r"); final FileChannel channel = reader.getChannel(); @@ -214,34 +153,29 @@ public void whenReadWithFileChannel_thenCorrect() throws IOException { final ByteBuffer buff = ByteBuffer.allocate(bufferSize); channel.read(buff); buff.flip(); - assertEquals(str, new String(buff.array())); + assertEquals(expected_value, new String(buff.array())); channel.close(); reader.close(); } @Test public void whenReadSmallFileJava7_thenCorrect() throws IOException { - final String str = "Hello world"; - + final String expected_value = "Hello world"; final Path path = Paths.get("src/test/resources/test_read.txt"); - final byte[] strToBytes = str.getBytes(); - Files.write(path, strToBytes); final String read = Files.readAllLines(path).get(0); - assertEquals(str, read); + assertEquals(expected_value, read); } @Test public void whenReadLargeFileJava7_thenCorrect() throws IOException { - final String str = "Hello world"; + final String expected_value = "Hello world"; final Path path = Paths.get("src/test/resources/test_read.txt"); - final byte[] strToBytes = str.getBytes(); - Files.write(path, strToBytes); - final BufferedReader reader = Files.newBufferedReader(path); final String line = reader.readLine(); - assertEquals(str, line); + assertEquals(expected_value, line); } + } From 357c71a96a3203a72324c96eac381e0719125de4 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 6 Oct 2014 09:28:15 +0200 Subject: [PATCH 660/796] Change input file extension Change input file extension from .txt to .in --- .../java/io/JavaReadFromFileTest.java | 24 +++++++++--------- core-java/src/test/resources/test_read.in | 1 + core-java/src/test/resources/test_read1.in | 1 + core-java/src/test/resources/test_read2.in | 1 + core-java/src/test/resources/test_read3.in | 1 + core-java/src/test/resources/test_read4.in | Bin 0 -> 7 bytes core-java/src/test/resources/test_read7.in | 1 + core-java/src/test/resources/test_read8.in | 2 ++ 8 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 core-java/src/test/resources/test_read.in create mode 100644 core-java/src/test/resources/test_read1.in create mode 100644 core-java/src/test/resources/test_read2.in create mode 100644 core-java/src/test/resources/test_read3.in create mode 100644 core-java/src/test/resources/test_read4.in create mode 100644 core-java/src/test/resources/test_read7.in create mode 100644 core-java/src/test/resources/test_read8.in diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java index 5ad6959707bd..72f658eb0649 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java @@ -33,7 +33,7 @@ public class JavaReadFromFileTest { public void whenReadWithBufferedReader_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.in")); final String currentLine = reader.readLine(); reader.close(); @@ -42,7 +42,7 @@ public void whenReadWithBufferedReader_thenCorrect() throws IOException { @Test public void whenReadWithScanner_thenCorrect() throws IOException { - final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.txt")); + final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.in")); scanner.useDelimiter(" "); assertTrue(scanner.hasNext()); @@ -56,7 +56,7 @@ public void whenReadWithScanner_thenCorrect() throws IOException { @Test public void whenReadWithScannerTwoDelimiters_thenCorrect() throws IOException { - final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.txt")); + final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.in")); scanner.useDelimiter(",| "); assertTrue(scanner.hasNextInt()); @@ -69,7 +69,7 @@ public void whenReadWithScannerTwoDelimiters_thenCorrect() throws IOException { @Test public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException { - final FileReader reader = new FileReader("src/test/resources/test_read3.txt"); + final FileReader reader = new FileReader("src/test/resources/test_read3.in"); final StreamTokenizer tokenizer = new StreamTokenizer(reader); tokenizer.nextToken(); @@ -89,7 +89,7 @@ public void whenReadWithDataInputStream_thenCorrect() throws IOException { final String expected_value = "Hello"; String result; - final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.txt")); + final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.in")); result = reader.readUTF(); reader.close(); @@ -100,8 +100,8 @@ public void whenReadTwoFilesWithSequenceInputStream_thenCorrect() throws IOExcep final int expected_value1 = 2000; final int expected_value2 = 5000; - final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.txt"); - final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.txt"); + final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.in"); + final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.in"); final SequenceInputStream sequence = new SequenceInputStream(stream1, stream2); final DataInputStream reader = new DataInputStream(sequence); @@ -117,7 +117,7 @@ public void whenReadTwoFilesWithSequenceInputStream_thenCorrect() throws IOExcep @Test public void whenReadUTFEncodedFile_thenCorrect() throws IOException { final String expected_value = "é’空"; - final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.txt"), "UTF-8")); + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8")); final String currentLine = reader.readLine(); reader.close(); @@ -127,7 +127,7 @@ public void whenReadUTFEncodedFile_thenCorrect() throws IOException { @Test public void whenReadFileContentsIntoString_thenCorrect() throws IOException { final String expected_value = "Hello world \n Test line \n"; - final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.txt")); + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.in")); final StringBuilder builder = new StringBuilder(); String currentLine = reader.readLine(); while (currentLine != null) { @@ -144,7 +144,7 @@ public void whenReadFileContentsIntoString_thenCorrect() throws IOException { @Test public void whenReadWithFileChannel_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.txt", "r"); + final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); final FileChannel channel = reader.getChannel(); int bufferSize = 1024; @@ -161,7 +161,7 @@ public void whenReadWithFileChannel_thenCorrect() throws IOException { @Test public void whenReadSmallFileJava7_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final Path path = Paths.get("src/test/resources/test_read.txt"); + final Path path = Paths.get("src/test/resources/test_read.in"); final String read = Files.readAllLines(path).get(0); assertEquals(expected_value, read); @@ -171,7 +171,7 @@ public void whenReadSmallFileJava7_thenCorrect() throws IOException { public void whenReadLargeFileJava7_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final Path path = Paths.get("src/test/resources/test_read.txt"); + final Path path = Paths.get("src/test/resources/test_read.in"); final BufferedReader reader = Files.newBufferedReader(path); final String line = reader.readLine(); assertEquals(expected_value, line); diff --git a/core-java/src/test/resources/test_read.in b/core-java/src/test/resources/test_read.in new file mode 100644 index 000000000000..70c379b63ffa --- /dev/null +++ b/core-java/src/test/resources/test_read.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/core-java/src/test/resources/test_read1.in b/core-java/src/test/resources/test_read1.in new file mode 100644 index 000000000000..1e462429938a --- /dev/null +++ b/core-java/src/test/resources/test_read1.in @@ -0,0 +1 @@ +Hello world 1 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read2.in b/core-java/src/test/resources/test_read2.in new file mode 100644 index 000000000000..fe47dc003bc6 --- /dev/null +++ b/core-java/src/test/resources/test_read2.in @@ -0,0 +1 @@ +2,3 4 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read3.in b/core-java/src/test/resources/test_read3.in new file mode 100644 index 000000000000..db9f25a672f5 --- /dev/null +++ b/core-java/src/test/resources/test_read3.in @@ -0,0 +1 @@ +Hello 1 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read4.in b/core-java/src/test/resources/test_read4.in new file mode 100644 index 0000000000000000000000000000000000000000..5727d54bfcb2046f4989fd13cf5dcf408201fa2a GIT binary patch literal 7 OcmZQz^+?Uh$p-)htO5D} literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/test_read7.in b/core-java/src/test/resources/test_read7.in new file mode 100644 index 000000000000..28d4d45d4341 --- /dev/null +++ b/core-java/src/test/resources/test_read7.in @@ -0,0 +1 @@ +é’空 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read8.in b/core-java/src/test/resources/test_read8.in new file mode 100644 index 000000000000..10fc1aac8ab2 --- /dev/null +++ b/core-java/src/test/resources/test_read8.in @@ -0,0 +1,2 @@ +Hello world + Test line From e243d2aed26503d0a2613990a462773598008082 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 8 Oct 2014 23:29:58 +0200 Subject: [PATCH 661/796] add class GuavaClassTest --- .../org/baeldung/guava/GuavaCacheTest.java | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java new file mode 100644 index 000000000000..df006498f479 --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java @@ -0,0 +1,238 @@ +package org.baeldung.guava; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; + +import com.google.common.base.Optional; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.cache.RemovalCause; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.cache.Weigher; + +public class GuavaCacheTest { + + @Test + public void whenCacheMiss_thenAutoLoad() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().build(loader); + assertEquals(0, cache.size()); + assertEquals("HELLO", cache.getUnchecked("hello")); + assertEquals(1, cache.size()); + + } + + @Test + public void whenCacheReachMaxSize_thenEviction() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().maximumSize(3).build(loader); + assertEquals(0, cache.size()); + cache.getUnchecked("first"); + cache.getUnchecked("second"); + cache.getUnchecked("third"); + cache.getUnchecked("forth"); + assertEquals(3, cache.size()); + } + + @Test + public void whenCacheReachMaxWeight_thenEviction() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final Weigher weighByLength = new Weigher() { + @Override + public int weigh(final String key, final String value) { + return value.length(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().maximumWeight(16).weigher(weighByLength).build(loader); + assertEquals(0, cache.size()); + cache.getUnchecked("first"); + cache.getUnchecked("second"); + cache.getUnchecked("third"); + cache.getUnchecked("last"); + assertEquals(3, cache.size()); + } + + @Test + public void whenEntryIdle_thenEviction() throws InterruptedException { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().expireAfterAccess(2, TimeUnit.MILLISECONDS).build(loader); + cache.getUnchecked("hello"); + assertEquals(1, cache.size()); + cache.getUnchecked("hello"); + Thread.sleep(300); + cache.getUnchecked("test"); + assertEquals(1, cache.size()); + } + + @Test + public void whenEntryLiveTimeExpire_thenEviction() throws InterruptedException { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.MILLISECONDS).build(loader); + cache.getUnchecked("hello"); + assertEquals(1, cache.size()); + Thread.sleep(300); + cache.getUnchecked("test"); + assertEquals(1, cache.size()); + } + + @Test + public void whenWeekKeyHasNoRef_thenRemoveFromCache() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().weakKeys().build(loader); + assertEquals(0, cache.size()); + + } + + @Test + public void whenSoftValue_thenRemoveFromCache() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().softValues().build(loader); + assertEquals(0, cache.size()); + + } + + @Test + public void whenNullValue_thenOptional() { + + final CacheLoader> loader = new CacheLoader>() { + @Override + public Optional load(final String key) { + + return Optional.fromNullable(getSuffix(key)); + } + }; + + final LoadingCache> cache = CacheBuilder.newBuilder().build(loader); + + assertEquals("txt", cache.getUnchecked("text.txt").get()); + + assertFalse(cache.getUnchecked("hello").isPresent()); + + } + + @Test + public void whenLiveTimeEnd_thenRefresh() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().refreshAfterWrite(1, TimeUnit.MINUTES).build(loader); + assertEquals(0, cache.size()); + } + + + @Test + public void whenPreloadCache_thenUsePutAll() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().build(loader); + assertEquals(0, cache.size()); + final Map map = new HashMap(); + map.put("first", "FIRST"); + map.put("second", "SECOND"); + cache.putAll(map); + + assertEquals(2, cache.size()); + + } + + @Test + public void whenEntryRemovedFromCache_thenNotify() { + final CacheLoader loader = new CacheLoader() { + @Override + public String load(final String key) { + return key.toUpperCase(); + } + }; + + final RemovalListener listener = new RemovalListener() { + + @Override + public void onRemoval(final RemovalNotification n) { + if (n.wasEvicted()) { + final String cause = n.getCause().name(); + assertEquals(RemovalCause.SIZE.toString(), cause); + } + + } + }; + + final LoadingCache cache = CacheBuilder.newBuilder().maximumSize(3).removalListener(listener).build(loader); + cache.getUnchecked("first"); + cache.getUnchecked("second"); + cache.getUnchecked("third"); + cache.getUnchecked("last"); + + assertEquals(3, cache.size()); + } + + private String getSuffix(final String str) { + final int lastIndex = str.lastIndexOf('.'); + if (lastIndex == -1) + return null; + return str.substring(lastIndex + 1); + } + +} + + + From 5a97c3428a50e6fef19aeeca3158c0032c617f7a Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 9 Oct 2014 11:46:58 +0200 Subject: [PATCH 662/796] Modify GuavaCacheTest --- .../org/baeldung/guava/GuavaCacheTest.java | 61 ++++++------------- 1 file changed, 18 insertions(+), 43 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java index df006498f479..aae2cf18f512 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import java.util.HashMap; import java.util.Map; @@ -24,70 +25,66 @@ public class GuavaCacheTest { public void whenCacheMiss_thenAutoLoad() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().build(loader); assertEquals(0, cache.size()); assertEquals("HELLO", cache.getUnchecked("hello")); assertEquals(1, cache.size()); - } @Test public void whenCacheReachMaxSize_thenEviction() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().maximumSize(3).build(loader); - assertEquals(0, cache.size()); cache.getUnchecked("first"); cache.getUnchecked("second"); cache.getUnchecked("third"); cache.getUnchecked("forth"); assertEquals(3, cache.size()); + assertNull(cache.getIfPresent("first")); + assertEquals("FORTH", cache.getIfPresent("forth")); } @Test public void whenCacheReachMaxWeight_thenEviction() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final Weigher weighByLength = new Weigher() { @Override public int weigh(final String key, final String value) { return value.length(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().maximumWeight(16).weigher(weighByLength).build(loader); - assertEquals(0, cache.size()); cache.getUnchecked("first"); cache.getUnchecked("second"); cache.getUnchecked("third"); cache.getUnchecked("last"); assertEquals(3, cache.size()); + assertNull(cache.getIfPresent("first")); + assertEquals("LAST", cache.getIfPresent("last")); } @Test public void whenEntryIdle_thenEviction() throws InterruptedException { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().expireAfterAccess(2, TimeUnit.MILLISECONDS).build(loader); cache.getUnchecked("hello"); assertEquals(1, cache.size()); @@ -95,83 +92,70 @@ public String load(final String key) { Thread.sleep(300); cache.getUnchecked("test"); assertEquals(1, cache.size()); + assertNull(cache.getIfPresent("hello")); } @Test public void whenEntryLiveTimeExpire_thenEviction() throws InterruptedException { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.MILLISECONDS).build(loader); cache.getUnchecked("hello"); assertEquals(1, cache.size()); Thread.sleep(300); cache.getUnchecked("test"); assertEquals(1, cache.size()); + assertNull(cache.getIfPresent("hello")); } @Test public void whenWeekKeyHasNoRef_thenRemoveFromCache() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().weakKeys().build(loader); - assertEquals(0, cache.size()); - } @Test public void whenSoftValue_thenRemoveFromCache() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().softValues().build(loader); - assertEquals(0, cache.size()); - } @Test public void whenNullValue_thenOptional() { - final CacheLoader> loader = new CacheLoader>() { @Override - public Optional load(final String key) { - + public final Optional load(final String key) { return Optional.fromNullable(getSuffix(key)); } }; - final LoadingCache> cache = CacheBuilder.newBuilder().build(loader); - assertEquals("txt", cache.getUnchecked("text.txt").get()); - assertFalse(cache.getUnchecked("hello").isPresent()); - } @Test public void whenLiveTimeEnd_thenRefresh() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().refreshAfterWrite(1, TimeUnit.MINUTES).build(loader); - assertEquals(0, cache.size()); } @@ -179,49 +163,40 @@ public String load(final String key) { public void whenPreloadCache_thenUsePutAll() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final LoadingCache cache = CacheBuilder.newBuilder().build(loader); - assertEquals(0, cache.size()); final Map map = new HashMap(); map.put("first", "FIRST"); map.put("second", "SECOND"); cache.putAll(map); - assertEquals(2, cache.size()); - } @Test public void whenEntryRemovedFromCache_thenNotify() { final CacheLoader loader = new CacheLoader() { @Override - public String load(final String key) { + public final String load(final String key) { return key.toUpperCase(); } }; - final RemovalListener listener = new RemovalListener() { - @Override public void onRemoval(final RemovalNotification n) { if (n.wasEvicted()) { final String cause = n.getCause().name(); assertEquals(RemovalCause.SIZE.toString(), cause); } - } }; - final LoadingCache cache = CacheBuilder.newBuilder().maximumSize(3).removalListener(listener).build(loader); cache.getUnchecked("first"); cache.getUnchecked("second"); cache.getUnchecked("third"); cache.getUnchecked("last"); - assertEquals(3, cache.size()); } From 184feb8e2b9576888acaccf9976fa8d578b99346 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 9 Oct 2014 16:13:15 +0300 Subject: [PATCH 663/796] guava cleanup --- guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java index aae2cf18f512..87aba20ec32d 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java @@ -158,7 +158,6 @@ public final String load(final String key) { final LoadingCache cache = CacheBuilder.newBuilder().refreshAfterWrite(1, TimeUnit.MINUTES).build(loader); } - @Test public void whenPreloadCache_thenUsePutAll() { final CacheLoader loader = new CacheLoader() { @@ -200,6 +199,8 @@ public void onRemoval(final RemovalNotification n) { assertEquals(3, cache.size()); } + // UTIL + private String getSuffix(final String str) { final int lastIndex = str.lastIndexOf('.'); if (lastIndex == -1) From a04e03042b242677effcec333933ef4bde4f9ff2 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 12 Oct 2014 23:00:16 +0200 Subject: [PATCH 664/796] add class GuavaFilterCollectionsTest Test Example for article Guava - Predicates and Collections --- .../guava/GuavaFilterCollectionsTest.java | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java new file mode 100644 index 000000000000..060d61c887e6 --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java @@ -0,0 +1,157 @@ +package org.baeldung.guava; + +import static org.junit.Assert.assertEquals; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Collections2; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Ordering; + +public class GuavaFilterCollectionsTest { + + @Test + public void whenFilterCollection_thenFiltered() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.filter(names, Predicates.containsPattern("a")); + + assertEquals(2, result.size()); + assertEquals("[Jane, Adam]", result.toString()); + } + + @Test + public void whenFilterCollectionWithCustomPredicate_thenFiltered() { + final Predicate predicate = new Predicate() { + @Override + public final boolean apply(final String input) { + return input.startsWith("A") || input.startsWith("J"); + } + }; + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.filter(names, predicate); + + assertEquals(3, result.size()); + assertEquals("[John, Jane, Adam]", result.toString()); + } + + @Test + public void whenFilterUsingMultiplePredicates_thenFiltered() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.filter(names, Predicates.or(Predicates.containsPattern("J"), Predicates.not(Predicates.containsPattern("a")))); + + assertEquals(3, result.size()); + assertEquals("[John, Jane, Tom]", result.toString()); + } + + @Test + public void whenTransformCollection_thenTransformed() { + final Function function = new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }; + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.transform(names, function); + + assertEquals(4, result.size()); + assertEquals("[4, 4, 4, 3]", result.toString()); + } + + @Test + public void whenTransformUsingComposedFunction_thenTransformed() { + final Function f1 = new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }; + + final Function f2 = new Function() { + @Override + public final Boolean apply(final Integer input) { + return input % 2 == 0; + } + }; + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.transform(names, Functions.compose(f2, f1)); + + assertEquals(4, result.size()); + assertEquals("[true, true, true, false]", result.toString()); + } + + @Test + public void whenFilterAndTransformCollection_thenCorrect() { + final Predicate predicate = new Predicate() { + @Override + public final boolean apply(final String input) { + return input.startsWith("A") || input.startsWith("T"); + } + }; + + final Function func = new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }; + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = FluentIterable.from(names).filter(predicate).transform(func).toList(); + + assertEquals(2, result.size()); + assertEquals("[4, 3]", result.toString()); + } + + @Test + public void whenSortCollection_thenSorted() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + Collections.sort(names, Ordering.natural()); + assertEquals("[Adam, Jane, John, Tom]", names.toString()); + } + + @Test + public void whenSortCollectionUsingCustomOrdering_thenSorted() { + final Ordering ordering = Ordering.natural().onResultOf(new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }); + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + Collections.sort(names, ordering); + assertEquals("[Tom, John, Jane, Adam]", names.toString()); + } + + @Test + public void whenGroupCollection_thenGrouped() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final ListMultimap groups = Multimaps.index(names, new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }); + + assertEquals(2, groups.keySet().size()); + assertEquals(3, groups.get(4).size()); + assertEquals("[Tom]", groups.get(3).toString()); + } + +} + From 1cd3d2e61784503345bf1d4fd632311bc7bf2be3 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 13 Oct 2014 21:27:39 +0200 Subject: [PATCH 665/796] Modify class GuavaFilterCollectionsTest Change class name, add new methods --- ... GuavaFilterTransformCollectionsTest.java} | 123 +++++++++++------- 1 file changed, 76 insertions(+), 47 deletions(-) rename guava/src/test/java/org/baeldung/guava/{GuavaFilterCollectionsTest.java => GuavaFilterTransformCollectionsTest.java} (61%) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java similarity index 61% rename from guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java rename to guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java index 060d61c887e6..d44edc962cfc 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFilterCollectionsTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java @@ -1,9 +1,13 @@ package org.baeldung.guava; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.util.Collection; -import java.util.Collections; import java.util.List; import org.junit.Test; @@ -14,20 +18,32 @@ import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.FluentIterable; -import com.google.common.collect.ListMultimap; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Multimaps; -import com.google.common.collect.Ordering; -public class GuavaFilterCollectionsTest { + +public class GuavaFilterTransformCollectionsTest { @Test - public void whenFilterCollection_thenFiltered() { + public void whenFilterWithCollections2_thenFiltered() { final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); final Collection result = Collections2.filter(names, Predicates.containsPattern("a")); assertEquals(2, result.size()); - assertEquals("[Jane, Adam]", result.toString()); + assertThat(result, containsInAnyOrder("Jane", "Adam")); + + result.add("anna"); + assertEquals(5, names.size()); + result.remove("Adam"); + assertEquals(4, names.size()); + } + + @Test + public void whenFilterWithIterables_thenFiltered() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Iterable result = Iterables.filter(names, Predicates.containsPattern("a")); + + assertThat(result, containsInAnyOrder("Jane", "Adam")); } @Test @@ -43,7 +59,7 @@ public final boolean apply(final String input) { final Collection result = Collections2.filter(names, predicate); assertEquals(3, result.size()); - assertEquals("[John, Jane, Adam]", result.toString()); + assertThat(result, containsInAnyOrder("John", "Jane", "Adam")); } @Test @@ -52,11 +68,46 @@ public void whenFilterUsingMultiplePredicates_thenFiltered() { final Collection result = Collections2.filter(names, Predicates.or(Predicates.containsPattern("J"), Predicates.not(Predicates.containsPattern("a")))); assertEquals(3, result.size()); - assertEquals("[John, Jane, Tom]", result.toString()); + assertThat(result, containsInAnyOrder("John", "Jane", "Tom")); } @Test - public void whenTransformCollection_thenTransformed() { + public void whenRemoveNullFromCollection_thenRemoved() { + final List names = Lists.newArrayList("John", null, "Jane", null, "Adam", "Tom"); + final Collection result = Collections2.filter(names, Predicates.notNull()); + + assertEquals(4, result.size()); + assertThat(result, containsInAnyOrder("John", "Jane", "Adam", "Tom")); + } + + @Test + public void whenCheckAllElementsForCondition_thenChecked() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + + boolean result = Iterables.all(names, Predicates.containsPattern("n|m")); + assertTrue(result); + + result = Iterables.all(names, Predicates.containsPattern("a")); + assertFalse(result); + } + + @Test + public void whenTransformWithIterables_thenTransformed() { + final Function function = new Function() { + @Override + public final Integer apply(final String input) { + return input.length(); + } + }; + + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Iterable result = Iterables.transform(names, function); + + assertThat(result, contains(4, 4, 4, 3)); + } + + @Test + public void whenTransformWithCollections2_thenTransformed() { final Function function = new Function() { @Override public final Integer apply(final String input) { @@ -68,7 +119,10 @@ public final Integer apply(final String input) { final Collection result = Collections2.transform(names, function); assertEquals(4, result.size()); - assertEquals("[4, 4, 4, 3]", result.toString()); + assertThat(result, contains(4, 4, 4, 3)); + + result.remove(3); + assertEquals(3, names.size()); } @Test @@ -91,7 +145,16 @@ public final Boolean apply(final Integer input) { final Collection result = Collections2.transform(names, Functions.compose(f2, f1)); assertEquals(4, result.size()); - assertEquals("[true, true, true, false]", result.toString()); + assertThat(result, contains(true, true, true, false)); + } + + @Test + public void whenCreateFunctionFromPredicate_thenCreated() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.transform(names, Functions.forPredicate(Predicates.containsPattern("m"))); + + assertEquals(4, result.size()); + assertThat(result, contains(false, false, true, true)); } @Test @@ -114,44 +177,10 @@ public final Integer apply(final String input) { final Collection result = FluentIterable.from(names).filter(predicate).transform(func).toList(); assertEquals(2, result.size()); - assertEquals("[4, 3]", result.toString()); - } - - @Test - public void whenSortCollection_thenSorted() { - final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - Collections.sort(names, Ordering.natural()); - assertEquals("[Adam, Jane, John, Tom]", names.toString()); - } - - @Test - public void whenSortCollectionUsingCustomOrdering_thenSorted() { - final Ordering ordering = Ordering.natural().onResultOf(new Function() { - @Override - public final Integer apply(final String input) { - return input.length(); - } - }); - - final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - Collections.sort(names, ordering); - assertEquals("[Tom, John, Jane, Adam]", names.toString()); + assertThat(result, containsInAnyOrder(4, 3)); } - @Test - public void whenGroupCollection_thenGrouped() { - final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - final ListMultimap groups = Multimaps.index(names, new Function() { - @Override - public final Integer apply(final String input) { - return input.length(); - } - }); - assertEquals(2, groups.keySet().size()); - assertEquals(3, groups.get(4).size()); - assertEquals("[Tom]", groups.get(3).toString()); - } } From 4cad6d1485a8a375546893898243bf21b5c1c09e Mon Sep 17 00:00:00 2001 From: eugenp Date: Tue, 14 Oct 2014 11:24:06 +0300 Subject: [PATCH 666/796] changing base directory of a project --- .../.classpath | 0 .../.project | 0 .../.springBeans | 0 .../pom.xml | 0 .../main/java/org/baeldung/persistence/dao/UserRepository.java | 0 .../src/main/java/org/baeldung/persistence/model/Role.java | 0 .../src/main/java/org/baeldung/persistence/model/User.java | 0 .../main/java/org/baeldung/persistence/service/IUserService.java | 0 .../src/main/java/org/baeldung/persistence/service/UserDto.java | 0 .../main/java/org/baeldung/persistence/service/UserService.java | 0 .../security/MySimpleUrlAuthenticationSuccessHandler.java | 0 .../src/main/java/org/baeldung/security/MyUserDetailsService.java | 0 .../src/main/java/org/baeldung/spring/AppConfig.java | 0 .../src/main/java/org/baeldung/spring/MvcConfig.java | 0 .../src/main/java/org/baeldung/spring/PersistenceJPAConfig.java | 0 .../src/main/java/org/baeldung/spring/SecSecurityConfig.java | 0 .../org/baeldung/validation/service/EmailExistsException.java | 0 .../main/java/org/baeldung/validation/service/EmailValidator.java | 0 .../java/org/baeldung/validation/service/PasswordMatches.java | 0 .../org/baeldung/validation/service/PasswordMatchesValidator.java | 0 .../main/java/org/baeldung/validation/service/UserValidator.java | 0 .../src/main/java/org/baeldung/validation/service/ValidEmail.java | 0 .../java/org/baeldung/web/controller/RegistrationController.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/messages_en.properties | 0 .../src/main/resources/messages_es_ES.properties | 0 .../src/main/resources/webSecurityConfig.xml | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/admin.jsp | 0 .../src/main/webapp/WEB-INF/view/console.jsp | 0 .../src/main/webapp/WEB-INF/view/home.jsp | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/view/invalidSession.jsp | 0 .../src/main/webapp/WEB-INF/view/login.jsp | 0 .../src/main/webapp/WEB-INF/view/logout.jsp | 0 .../src/main/webapp/WEB-INF/view/registration.jsp | 0 .../src/main/webapp/WEB-INF/view/successRegister.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/main/webapp/resources/bootstrap.css | 0 40 files changed, 0 insertions(+), 0 deletions(-) rename {spring-security-login-error-handling => spring-security-login-and-registration}/.classpath (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/.project (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/.springBeans (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/pom.xml (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/dao/UserRepository.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/model/Role.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/model/User.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/service/IUserService.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/service/UserDto.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/persistence/service/UserService.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/security/MyUserDetailsService.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/spring/AppConfig.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/spring/MvcConfig.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/spring/SecSecurityConfig.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/EmailExistsException.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/EmailValidator.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/PasswordMatches.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/UserValidator.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/validation/service/ValidEmail.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/java/org/baeldung/web/controller/RegistrationController.java (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/resources/application.properties (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/resources/logback.xml (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/resources/messages_en.properties (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/resources/messages_es_ES.properties (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/resources/webSecurityConfig.xml (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/admin.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/console.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/home.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/invalidSession.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/login.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/logout.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/registration.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/view/successRegister.jsp (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-security-login-error-handling => spring-security-login-and-registration}/src/main/webapp/resources/bootstrap.css (100%) diff --git a/spring-security-login-error-handling/.classpath b/spring-security-login-and-registration/.classpath similarity index 100% rename from spring-security-login-error-handling/.classpath rename to spring-security-login-and-registration/.classpath diff --git a/spring-security-login-error-handling/.project b/spring-security-login-and-registration/.project similarity index 100% rename from spring-security-login-error-handling/.project rename to spring-security-login-and-registration/.project diff --git a/spring-security-login-error-handling/.springBeans b/spring-security-login-and-registration/.springBeans similarity index 100% rename from spring-security-login-error-handling/.springBeans rename to spring-security-login-and-registration/.springBeans diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-and-registration/pom.xml similarity index 100% rename from spring-security-login-error-handling/pom.xml rename to spring-security-login-and-registration/pom.xml diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/UserRepository.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/UserRepository.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/Role.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/Role.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/User.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/User.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/IUserService.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/IUserService.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/IUserService.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/UserDto.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/UserDto.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/UserService.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/persistence/service/UserService.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/AppConfig.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/spring/AppConfig.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailExistsException.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/EmailExistsException.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailExistsException.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/EmailExistsException.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailValidator.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/EmailValidator.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/EmailValidator.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/EmailValidator.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/PasswordMatches.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatches.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/PasswordMatches.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/PasswordMatchesValidator.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/UserValidator.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/UserValidator.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/UserValidator.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/UserValidator.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/ValidEmail.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/ValidEmail.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/validation/service/ValidEmail.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/validation/service/ValidEmail.java diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java similarity index 100% rename from spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java rename to spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-and-registration/src/main/resources/application.properties similarity index 100% rename from spring-security-login-error-handling/src/main/resources/application.properties rename to spring-security-login-and-registration/src/main/resources/application.properties diff --git a/spring-security-login-error-handling/src/main/resources/logback.xml b/spring-security-login-and-registration/src/main/resources/logback.xml similarity index 100% rename from spring-security-login-error-handling/src/main/resources/logback.xml rename to spring-security-login-and-registration/src/main/resources/logback.xml diff --git a/spring-security-login-error-handling/src/main/resources/messages_en.properties b/spring-security-login-and-registration/src/main/resources/messages_en.properties similarity index 100% rename from spring-security-login-error-handling/src/main/resources/messages_en.properties rename to spring-security-login-and-registration/src/main/resources/messages_en.properties diff --git a/spring-security-login-error-handling/src/main/resources/messages_es_ES.properties b/spring-security-login-and-registration/src/main/resources/messages_es_ES.properties similarity index 100% rename from spring-security-login-error-handling/src/main/resources/messages_es_ES.properties rename to spring-security-login-and-registration/src/main/resources/messages_es_ES.properties diff --git a/spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml similarity index 100% rename from spring-security-login-error-handling/src/main/resources/webSecurityConfig.xml rename to spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-and-registration/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/admin.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/console.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/home.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/invalidSession.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/invalidSession.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/invalidSession.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/login.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/logout.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/logout.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/logout.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/registration.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/registration.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/registration.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/successRegister.jsp similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/view/successRegister.jsp rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/view/successRegister.jsp diff --git a/spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml b/spring-security-login-and-registration/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/WEB-INF/web.xml rename to spring-security-login-and-registration/src/main/webapp/WEB-INF/web.xml diff --git a/spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css b/spring-security-login-and-registration/src/main/webapp/resources/bootstrap.css similarity index 100% rename from spring-security-login-error-handling/src/main/webapp/resources/bootstrap.css rename to spring-security-login-and-registration/src/main/webapp/resources/bootstrap.css From 149bdeb11d4a08116a20aad44920a22b7edd3747 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 15 Oct 2014 01:05:41 +0300 Subject: [PATCH 667/796] formatting work --- guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java | 3 --- .../baeldung/guava/GuavaFilterTransformCollectionsTest.java | 4 ---- 2 files changed, 7 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java index 87aba20ec32d..3c3b97690395 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCacheTest.java @@ -209,6 +209,3 @@ private String getSuffix(final String str) { } } - - - diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java index d44edc962cfc..30bee83893f6 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java @@ -21,7 +21,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - public class GuavaFilterTransformCollectionsTest { @Test @@ -180,7 +179,4 @@ public final Integer apply(final String input) { assertThat(result, containsInAnyOrder(4, 3)); } - - } - From 5742f310526bb3ac31751e392231af8de878e09b Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 16 Oct 2014 12:05:37 +0300 Subject: [PATCH 668/796] quava testing cleanup --- .../GuavaFilterTransformCollectionsTest.java | 76 ++++++++++++------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java index 30bee83893f6..1ecf8fdb0a14 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaFilterTransformCollectionsTest.java @@ -23,6 +23,14 @@ public class GuavaFilterTransformCollectionsTest { + @Test + public void whenFilterWithIterables_thenFiltered() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Iterable result = Iterables.filter(names, Predicates.containsPattern("a")); + + assertThat(result, containsInAnyOrder("Jane", "Adam")); + } + @Test public void whenFilterWithCollections2_thenFiltered() { final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); @@ -33,18 +41,18 @@ public void whenFilterWithCollections2_thenFiltered() { result.add("anna"); assertEquals(5, names.size()); - result.remove("Adam"); - assertEquals(4, names.size()); } - @Test - public void whenFilterWithIterables_thenFiltered() { + @Test(expected = IllegalArgumentException.class) + public void givenFilteredCollection_whenAddingInvalidElement_thenException() { final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - final Iterable result = Iterables.filter(names, Predicates.containsPattern("a")); + final Collection result = Collections2.filter(names, Predicates.containsPattern("a")); - assertThat(result, containsInAnyOrder("Jane", "Adam")); + result.add("elvis"); } + // + @Test public void whenFilterCollectionWithCustomPredicate_thenFiltered() { final Predicate predicate = new Predicate() { @@ -61,14 +69,7 @@ public final boolean apply(final String input) { assertThat(result, containsInAnyOrder("John", "Jane", "Adam")); } - @Test - public void whenFilterUsingMultiplePredicates_thenFiltered() { - final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - final Collection result = Collections2.filter(names, Predicates.or(Predicates.containsPattern("J"), Predicates.not(Predicates.containsPattern("a")))); - - assertEquals(3, result.size()); - assertThat(result, containsInAnyOrder("John", "Jane", "Tom")); - } + // @Test public void whenRemoveNullFromCollection_thenRemoved() { @@ -79,8 +80,10 @@ public void whenRemoveNullFromCollection_thenRemoved() { assertThat(result, containsInAnyOrder("John", "Jane", "Adam", "Tom")); } + // + @Test - public void whenCheckAllElementsForCondition_thenChecked() { + public void whenCheckingIfAllElementsMatchACondition_thenCorrect() { final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); boolean result = Iterables.all(names, Predicates.containsPattern("n|m")); @@ -90,8 +93,10 @@ public void whenCheckAllElementsForCondition_thenChecked() { assertFalse(result); } + // + @Test - public void whenTransformWithIterables_thenTransformed() { + public void whenTransformingWithIterables_thenTransformed() { final Function function = new Function() { @Override public final Integer apply(final String input) { @@ -105,6 +110,8 @@ public final Integer apply(final String input) { assertThat(result, contains(4, 4, 4, 3)); } + // + @Test public void whenTransformWithCollections2_thenTransformed() { final Function function = new Function() { @@ -124,8 +131,21 @@ public final Integer apply(final String input) { assertEquals(3, names.size()); } + // + + @Test + public void whenCreatingAFunctionFromAPredicate_thenCorrect() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.transform(names, Functions.forPredicate(Predicates.containsPattern("m"))); + + assertEquals(4, result.size()); + assertThat(result, contains(false, false, true, true)); + } + + // + @Test - public void whenTransformUsingComposedFunction_thenTransformed() { + public void whenTransformingUsingComposedFunction_thenTransformed() { final Function f1 = new Function() { @Override public final Integer apply(final String input) { @@ -147,17 +167,10 @@ public final Boolean apply(final Integer input) { assertThat(result, contains(true, true, true, false)); } - @Test - public void whenCreateFunctionFromPredicate_thenCreated() { - final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); - final Collection result = Collections2.transform(names, Functions.forPredicate(Predicates.containsPattern("m"))); - - assertEquals(4, result.size()); - assertThat(result, contains(false, false, true, true)); - } + // @Test - public void whenFilterAndTransformCollection_thenCorrect() { + public void whenFilteringAndTransformingCollection_thenCorrect() { final Predicate predicate = new Predicate() { @Override public final boolean apply(final String input) { @@ -179,4 +192,15 @@ public final Integer apply(final String input) { assertThat(result, containsInAnyOrder(4, 3)); } + // + + @Test + public void whenFilterUsingMultiplePredicates_thenFiltered() { + final List names = Lists.newArrayList("John", "Jane", "Adam", "Tom"); + final Collection result = Collections2.filter(names, Predicates.or(Predicates.containsPattern("J"), Predicates.not(Predicates.containsPattern("a")))); + + assertEquals(3, result.size()); + assertThat(result, containsInAnyOrder("John", "Jane", "Tom")); + } + } From 77130d2d8cc0e095aa0cfb22ee0f93e0e69c8c3a Mon Sep 17 00:00:00 2001 From: egmp777 Date: Thu, 16 Oct 2014 20:53:24 -0500 Subject: [PATCH 669/796] handling static resources --- .metadata/.lock | 0 .metadata/.log | 253 + .metadata/.mylyn/.taskListIndex/segments.gen | Bin 0 -> 20 bytes .metadata/.mylyn/.taskListIndex/segments_1 | Bin 0 -> 32 bytes .metadata/.mylyn/repositories.xml.zip | Bin 0 -> 358 bytes .../RemoteSystemsTempFiles/.markers.snap | Bin 0 -> 16 bytes .../RemoteSystemsTempFiles/.syncinfo.snap | Bin 0 -> 16 bytes .../org.eclipse.jdt.core/state.dat | Bin 0 -> 193784 bytes .../org.eclipse.wst.jsdt.core/state.dat | Bin 0 -> 302775 bytes .../.root/.indexes/history.version | 1 + .../.root/.indexes/properties.index | Bin 0 -> 230 bytes .../.root/.indexes/properties.version | 1 + .../.root/.markers.snap | Bin 0 -> 16 bytes .../org.eclipse.core.resources/.root/1.tree | Bin 0 -> 228 bytes .../.safetable/org.eclipse.core.resources | Bin 0 -> 882 bytes .../.plugins/org.eclipse.core.resources/.snap | Bin 0 -> 113 bytes .../org.eclipse.e4.workbench/workbench.xmi | 3889 ++ .../org.eclipse.jdt.core/externalFilesCache | Bin 0 -> 6503 bytes .../externalLibsTimeStamps | Bin 0 -> 5404 bytes .../org.eclipse.jdt.core/indexNamesMap.txt | 1 + .../org.eclipse.jdt.core/invalidArchivesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/javaLikeNames.txt | 2 + .../org.eclipse.jdt.core/nonChainingJarsCache | Bin 0 -> 4948 bytes .../org.eclipse.jdt.core/savedIndexNames.txt | 23 + .../variablesAndContainers.dat | Bin 0 -> 149 bytes .../org.eclipse.jdt.launching/.install.xml | 6 + .../org.eclipse.jdt.ui/OpenTypeHistory.xml | 2 + .../QualifiedTypeNameHistory.xml | 2 + .../org.eclipse.jdt.ui/dialog_settings.xml | 13 + .../taglibindex/2996324989.dat | Bin 0 -> 15826 bytes .../dialog_settings.xml | 7 + .../org.eclipse.m2e.core/workspaceState.ser | Bin 0 -> 545 bytes .../.cache/clean-cache.properties | 2 + .metadata/.plugins/org.eclipse.rse.core/.log | 0 ...al.core.RSELocalConnectionInitializer.mark | 0 .../FP.local.files_0/node.properties | 57 + .../H.local_16/node.properties | 25 + .../node.properties | 7 + .metadata/.plugins/org.eclipse.rse.ui/.log | 0 .../org.eclipse.search/dialog_settings.xml | 70 + .../dialog_settings.xml | 5 + .../org.eclipse.ui.ide/dialog_settings.xml | 30 + .../dialog_settings.xml | 23 + .../dialog_settings.xml | 33 + .../org.eclipse.ui.workbench/workingsets.xml | 4 + .../org.eclipse.ui/dialog_settings.xml | 3 + .../org.eclipse.wst.internet.cache/cache.xml | 1 + .../externalLibsTimeStamps | Bin 0 -> 503 bytes .../variablesAndContainers.dat | Bin 0 -> 840 bytes .../OpenTypeHistory.xml | 2 + .../QualifiedTypeNameHistory.xml | 2 + .../org.eclipse.wst.server.core/monitors.xml | 2 + .../task-tags.properties | 3 + .../dialog_settings.xml | 5 + .../dialog_settings.xml | 8 + .../.state | 2 + .../metadata/.state | Bin 0 -> 8765 bytes .../properties/.state | Bin 0 -> 1002 bytes .../dashboard.feeds.blogs/-549550714.xml | 816 + .../dashboard.feeds.update/623127801.xml | 291 + .metadata/version.ini | 1 + RemoteSystemsTempFiles/.project | 12 + handling-spring-static-resources/.classpath | 30 + handling-spring-static-resources/.project | 53 + handling-spring-static-resources/.springBeans | 16 + handling-spring-static-resources/pom.xml | 163 + ...SimpleUrlAuthenticationSuccessHandler.java | 62 + .../java/org/baeldung/spring/AppConfig.java | 20 + .../java/org/baeldung/spring/MvcConfig.java | 109 + .../baeldung/spring/SecSecurityConfig.java | 14 + .../web/controller/HomeController.java | 35 + .../src/main/resources/application.properties | 6 + .../src/main/resources/logback.xml | 20 + .../src/main/resources/messages_en.properties | 42 + .../main/resources/messages_es_ES.properties | 42 + .../src/main/resources/webSecurityConfig.xml | 45 + .../classes/other-resources/Hello.html | 10 + .../classes/other-resources/bootstrap.css | 6167 ++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 7 + .../src/main/webapp/WEB-INF/view/home.jsp | 17 + .../src/main/webapp/WEB-INF/view/login.jsp | 65 + .../src/main/webapp/WEB-INF/web.xml | 49 + .../src/main/webapp/js/app.js | 4 + .../src/main/webapp/js/bootstrap.css | 6167 ++ .../src/main/webapp/js/ember-data.js | 10548 ++++ .../src/main/webapp/js/ember.js | 47755 ++++++++++++++++ .../src/main/webapp/js/foo.js | 3 + .../src/main/webapp/js/handlebars-3133af2.js | 3079 + .../src/main/webapp/js/helpers/utils.js | 6 + .../src/main/webapp/js/jquery-1.11.1.min.js | 4 + .../src/main/webapp/js/main.js | 10 + .../src/main/webapp/js/require.gz | Bin 0 -> 6374 bytes .../src/main/webapp/js/require.js | 36 + .../src/main/webapp/js/router.js | 6 + .../main/webapp/other-resources/Hello.html | 10 + .../main/webapp/other-resources/bootstrap.css | 6167 ++ .../src/main/webapp/other-resources/foo.js | 3 + .../src/main/webapp/resources/bootstrap.css | 6167 ++ .../src/main/webapp/resources/myCss.css | 6167 ++ spring-security-mvc-ldap/.project | 6 + 100 files changed, 98714 insertions(+) create mode 100644 .metadata/.lock create mode 100644 .metadata/.log create mode 100644 .metadata/.mylyn/.taskListIndex/segments.gen create mode 100644 .metadata/.mylyn/.taskListIndex/segments_1 create mode 100644 .metadata/.mylyn/repositories.xml.zip create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.root/1.tree create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources create mode 100644 .metadata/.plugins/org.eclipse.core.resources/.snap create mode 100644 .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/externalFilesCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt create mode 100644 .metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat create mode 100644 .metadata/.plugins/org.eclipse.jdt.launching/.install.xml create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat create mode 100644 .metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser create mode 100644 .metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties create mode 100644 .metadata/.plugins/org.eclipse.rse.core/.log create mode 100644 .metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark create mode 100644 .metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/FP.local.files_0/node.properties create mode 100644 .metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/H.local_16/node.properties create mode 100644 .metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/node.properties create mode 100644 .metadata/.plugins/org.eclipse.rse.ui/.log create mode 100644 .metadata/.plugins/org.eclipse.search/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml create mode 100644 .metadata/.plugins/org.eclipse.ui/dialog_settings.xml create mode 100644 .metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml create mode 100644 .metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps create mode 100644 .metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat create mode 100644 .metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml create mode 100644 .metadata/.plugins/org.eclipse.wst.server.core/monitors.xml create mode 100644 .metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties create mode 100644 .metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml create mode 100644 .metadata/.plugins/org.jboss.tools.central/dialog_settings.xml create mode 100644 .metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state create mode 100644 .metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state create mode 100644 .metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/properties/.state create mode 100644 .metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml create mode 100644 .metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml create mode 100644 .metadata/version.ini create mode 100644 RemoteSystemsTempFiles/.project create mode 100644 handling-spring-static-resources/.classpath create mode 100644 handling-spring-static-resources/.project create mode 100644 handling-spring-static-resources/.springBeans create mode 100644 handling-spring-static-resources/pom.xml create mode 100644 handling-spring-static-resources/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java create mode 100644 handling-spring-static-resources/src/main/java/org/baeldung/spring/AppConfig.java create mode 100644 handling-spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java create mode 100644 handling-spring-static-resources/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 handling-spring-static-resources/src/main/java/org/baeldung/web/controller/HomeController.java create mode 100644 handling-spring-static-resources/src/main/resources/application.properties create mode 100644 handling-spring-static-resources/src/main/resources/logback.xml create mode 100644 handling-spring-static-resources/src/main/resources/messages_en.properties create mode 100644 handling-spring-static-resources/src/main/resources/messages_es_ES.properties create mode 100644 handling-spring-static-resources/src/main/resources/webSecurityConfig.xml create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/Hello.html create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/bootstrap.css create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/view/home.jsp create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp create mode 100644 handling-spring-static-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 handling-spring-static-resources/src/main/webapp/js/app.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/bootstrap.css create mode 100644 handling-spring-static-resources/src/main/webapp/js/ember-data.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/ember.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/foo.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/handlebars-3133af2.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/helpers/utils.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/jquery-1.11.1.min.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/main.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/require.gz create mode 100644 handling-spring-static-resources/src/main/webapp/js/require.js create mode 100644 handling-spring-static-resources/src/main/webapp/js/router.js create mode 100644 handling-spring-static-resources/src/main/webapp/other-resources/Hello.html create mode 100644 handling-spring-static-resources/src/main/webapp/other-resources/bootstrap.css create mode 100644 handling-spring-static-resources/src/main/webapp/other-resources/foo.js create mode 100644 handling-spring-static-resources/src/main/webapp/resources/bootstrap.css create mode 100644 handling-spring-static-resources/src/main/webapp/resources/myCss.css diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 000000000000..93d3e86a61e6 --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,253 @@ + +!ENTRY org.eclipse.core.resources 4 2 2014-10-16 20:42:46.953 +!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources". +!STACK 0 +java.lang.IllegalStateException: Registry Directory not available: /Users/Elena/tutorials/.metadata/.plugins/org.eclipse.pde.core/.p2/org.eclipse.equinox.p2.engine/profileRegistry. + at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.restore(SimpleProfileRegistry.java:480) + at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfileMap(SimpleProfileRegistry.java:338) + at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfiles(SimpleProfileRegistry.java:320) + at org.eclipse.pde.internal.core.target.P2TargetUtils.cleanOrphanedTargetDefinitionProfiles(P2TargetUtils.java:168) + at org.eclipse.pde.internal.core.PDECore$1.saving(PDECore.java:274) + at org.eclipse.core.internal.resources.SaveManager.executeLifecycle(SaveManager.java:383) + at org.eclipse.core.internal.resources.SaveManager$1.run(SaveManager.java:192) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.core.internal.resources.SaveManager.broadcastLifecycle(SaveManager.java:195) + at org.eclipse.core.internal.resources.SaveManager.save(SaveManager.java:1130) + at org.eclipse.core.internal.resources.Workspace.save(Workspace.java:2376) + at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor$5.run(IDEWorkbenchAdvisor.java:508) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) + +!ENTRY org.eclipse.ui.ide 4 4 2014-10-16 20:42:55.472 +!MESSAGE Problems saving workspace + +!ENTRY org.eclipse.ui.ide 4 1 2014-10-16 20:42:55.472 +!MESSAGE Problems occurred while trying to save the state of the workbench. +!SUBENTRY 1 org.eclipse.core.resources 4 568 2014-10-16 20:42:55.472 +!MESSAGE Could not write workspace metadata '/Users/Elena/tutorials/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree'. +!STACK 0 +java.io.FileNotFoundException: /Users/Elena/tutorials/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree (No such file or directory) + at java.io.FileOutputStream.open(Native Method) + at java.io.FileOutputStream.(FileOutputStream.java:213) + at java.io.FileOutputStream.(FileOutputStream.java:162) + at org.eclipse.core.internal.localstore.SafeFileOutputStream.(SafeFileOutputStream.java:51) + at org.eclipse.core.internal.resources.SaveManager.saveTree(SaveManager.java:1352) + at org.eclipse.core.internal.resources.SaveManager.save(SaveManager.java:1134) + at org.eclipse.core.internal.resources.Workspace.save(Workspace.java:2376) + at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor$5.run(IDEWorkbenchAdvisor.java:508) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) +!SESSION 2014-10-16 20:43:17.092 ----------------------------------------------- +eclipse.buildId=4.3.2.M20140221-1700 +java.version=1.8.0_20 +java.vendor=Oracle Corporation +BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=es_ES +Framework arguments: -product org.eclipse.epp.package.standard.product -keyring /Users/Elena/.eclipse_keyring -showlocation +Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.standard.product -keyring /Users/Elena/.eclipse_keyring -showlocation + +!ENTRY org.eclipse.core.net 1 0 2014-10-16 20:43:52.743 +!MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external source. This value will be overwritten using the values from the preferences + +!ENTRY org.eclipse.jface 2 0 2014-10-16 20:43:53.942 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2014-10-16 20:43:53.943 +!MESSAGE A conflict occurred for COMMAND+SHIFT+F10: +Binding(COMMAND+SHIFT+F10, + ParameterizedCommand(Command(org.jboss.tools.common.ui.RegisterAsService,Register As Service, + Adds class name to META-INF/services/%serviceType% file after service type is selected in the dialog from types extended and implemented by the class., + Category(org.eclipse.ui.category.file,File,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2df3545d, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(COMMAND+SHIFT+F10, + ParameterizedCommand(Command(org.eclipse.ui.window.showSystemMenu,Show System Menu, + Show the system menu, + Category(org.eclipse.ui.category.window,Window,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@75ad30c1, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,cocoa,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2014-10-16 20:43:53.943 +!MESSAGE A conflict occurred for ALT+COMMAND+Z: +Binding(ALT+COMMAND+Z, + ParameterizedCommand(Command(org.jboss.tools.cdi.ui.open.namedBean,Open CDI Named Bean, + Open CDI Named Bean, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@fe8aaeb, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+COMMAND+Z, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.surround.with.quickMenu,Surround With Quick Menu, + Shows the Surround With quick menu, + Category(org.eclipse.jdt.ui.category.source,Source,Java Source Actions,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6b9697ae, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,cocoa,system) + +!ENTRY com.android.ide.eclipse.adt 1 0 2014-10-16 20:44:03.016 +!MESSAGE No valid Android XML Editor Delegate found for file /handling-spring-static-resources/pom.xml [Res null, type null] + +!ENTRY org.eclipse.e4.ui.workbench 4 0 2014-10-16 20:44:06.875 +!MESSAGE +!STACK 0 +org.eclipse.core.runtime.AssertionFailedException: assertion failed: + at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110) + at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96) + at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1081) + at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:607) + at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:362) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:483) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) + at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877) + at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857) + at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119) + at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333) + at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1147) + at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$6.run(PartRenderingEngine.java:526) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:511) + at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:61) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer.processContents(PerspectiveRenderer.java:59) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:103) + at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96) + at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.postProcess(PerspectiveStackRenderer.java:77) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) + at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.processContents(WBWRenderer.java:581) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1042) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140) + at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:483) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) + at org.eclipse.equinox.launcher.Main.run(Main.java:1450) + +!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.029 +!MESSAGE Could not load repository template extension contributed by org.eclipse.mylyn.bugzilla.ide with connectorKind bugzilla + +!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.029 +!MESSAGE Could not load repository template extension contributed by org.springsource.ide.eclipse.dashboard.ui with connectorKind jira + +!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.030 +!MESSAGE Could not load repository template extension contributed by org.springsource.ide.eclipse.dashboard.ui with connectorKind jira + +!ENTRY org.eclipse.ui.workbench 4 2 2014-10-16 20:44:30.651 +!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". +!STACK 0 +java.lang.NullPointerException + at org.springframework.ide.eclipse.maven.internal.legacyconversion.LegacyProjectChecker.earlyStartup(LegacyProjectChecker.java:36) + at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87) + at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2555) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) + +!ENTRY org.eclipse.ui 4 4 2014-10-16 20:44:30.663 +!MESSAGE Unhandled Exception + +!ENTRY org.springframework.ide.eclipse.maven 4 0 2014-10-16 20:44:30.663 +!MESSAGE Unable to execute early startup code for an extension +!STACK 0 +java.lang.NullPointerException + at org.springframework.ide.eclipse.maven.internal.legacyconversion.LegacyProjectChecker.earlyStartup(LegacyProjectChecker.java:36) + at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87) + at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2555) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) diff --git a/.metadata/.mylyn/.taskListIndex/segments.gen b/.metadata/.mylyn/.taskListIndex/segments.gen new file mode 100644 index 0000000000000000000000000000000000000000..63a7ec9a3ce3e4c844ffb7c8dd88e6eb3ff32ef5 GIT binary patch literal 20 QcmezW|NlP*2w;TK07=6G{r~^~ literal 0 HcmV?d00001 diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000000000000000000000000000000000000..6b350b10f4c8cd3449df560f843ad0cd8b790c7c GIT binary patch literal 32 acmezW|NmD821ZZmV-L(2&_KNM4j}-qCI^53 literal 0 HcmV?d00001 diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000000000000000000000000000000000000..0f05d185fc98c73779e1c4d4bab8662414cb97f6 GIT binary patch literal 358 zcmWIWW@Zs#;Nak3=vx}#%76p}fb62wg8bsllKi5~)MCAg+?=Ho?fnls@EqNL>ZG;! z4T++a5i_(J15W1&O^(`IZ}t0Do4>z{tD`P+$Jt4L@13v96K{WTwy&$8i!bkusYF+; zltmxkwbj2@M@N*re;IE>augr`lOvMEO-#yFXyBCFQopUUZ9)h zh3Kv)5A*^a%FR|~XPJB|W99cbtvNIPh^#$laemRZn%k$JP2!up)`@v<($`lG-b?Sl zW-b5Hq4YbXZGV>eD#_J(|5A%=9;mbT>zgd!VYBSU;!76K-#obVbMyB`fs9?-Eb9}# z^96XbbL^Nrec2VDe}6JEFa&rrGKnxC!US0k6eg$uJ%j?hS=m4;7=h3ZNDBc?WMBXQ DG24ga literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap new file mode 100644 index 0000000000000000000000000000000000000000..91d6c541512db06197e1b732473d567ce4b92d6a GIT binary patch literal 16 YcmZ?R*xjhShe1S2b=vdAllRF105-b@zW@LL literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap new file mode 100644 index 0000000000000000000000000000000000000000..91d6c541512db06197e1b732473d567ce4b92d6a GIT binary patch literal 16 YcmZ?R*xjhShe1S2b=vdAllRF105-b@zW@LL literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000000000000000000000000000000000000..1b30d3ec254208f116d5eb57c94573b4ebf90ab2 GIT binary patch literal 193784 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 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat new file mode 100644 index 0000000000000000000000000000000000000000..ec854838416e0482e73bcfcc30c226182668a6e4 GIT binary patch literal 302775 zcmcG%`;%S8k?*?&2)$cxfxv+6@ywZfZ@6t91`{`K#1WDJc|c%E;5+k6hmaacMlW}_ zz?wM!&iOx2e%5zqSJhgpGMAXKWu#quXI5q9yRxd*T3vjyb8mC|&cg>!cegix+TGjy z>+apX%{xzawpRyl-nw+_>VfmCU*5m{`0m38kMI3<_vy~?&))652X}tEv%UM|+0LEq z-PLM!!2W;j&Hw$oxAfWmuKstxe%=4yvDLrq?%es^quUQ2|L&*l?`}VR`nxB4_qTUS zcfb4o$rGbv_0|~fue-n7+5X$J2RqyRd~xPy>y4lOb>^pG5;oq>?r-0J_x<;8fBznk zZ_GeKT5o_gY5z2Xc7OZf)9szz-#y!V@NgIWH)nvhAAPsI!;k-C=EuMO?b-Iu^WVO^ z`L6wc^O30dNo);_qpy?VIXwr}>V_0sBpu0FGW&#tzHKer7EyyvS&_V2UR?&_n} zA6D<%Z~Xg#L7wkIzGo00uimxa-&=jS`lDe)(C=Gs?;8A;_5Q)odkp+Ky zPY(UzK6FgU2S)FEL*IP*$Ua4VGd6Hr_V*ub27gGQKQe9r%`7uYJ{b5W=s()$jFOLS zd_jL~qr}jESp9xIOFqRM)ZE~=J}rSpmO#H}y=RoXXOIq^agZLp@Ant<{r*1m2MeH) ziztEijBYq5Xk?#3f4JuN$M!GK2Uh=);CyTvq7nEMj{q$n4RhtwAML-09_WQ1TQ*BR zWqp5WFv$N8rdRxl`u@PEz;58o$41F}Av80@Kj2e-Z}2fC^!xjPZa%%2LPIY;2!Hia zN(nF@?L%Xo7p%pfsVBr9p=HbZN5}DA5m!Do7`V7K%n|q)`d#ZCJ%=Ni=6-Ax;0J-m zIJ z9_D4fW%TeeD9}J)3-tlICG`gWjHkt8NQ0S{;;A^89ylo8D+Pxu5MWW_f}W!cX~TDz}>gec2{4meliNawlSaBZ_0q5 z8_b2(CHrp2V4kmOdNTC9XKmn^-BX+G1Iw$S{a^*ZTAj3B$*u2NuRj?q|K1t+xNYC= z8T_jaM3if9jUdlh54Tr84!pZP(6lp9_|U%HGp;@{s^R&O8Mr8tZOy_T+~><}>+?(? z0p}lZudJ>N)WDe|Yi|8u6hAdRxov+Vt6lqkZ*|MQePo|lSHPFUGra1rF1BW%kJ$Wc zuk}|O3B7H7hYZ4!nXB?bsjg#VS~2^NalUrM#d*F>Ya2{K^z$m#!rM&p}Z>zB3YQ~Unb+P<(5=yiK@`tKMvv`KsD6DTbCxs7&b=u=W*rdY&wHG{*$ zc&)@vRNuLjuNx*>xmumDzv+L^{@k|y@7s)!qOABr@GG>BJ<-N67JRvBefgZfFgS7l zW|r2}v{I!t=p*keM$zwrCZ_J14c9STV=!0O z6iI@S3zlj{`mT=U!gjc4`?4m&x0V#eXL5@JCLipW$Pb@yo3_JoMm}bAqm5V@y6kZQ zENW2)Y~FDO!0!i!zK#r5G@kGAfs3vG`_jHsMlhAaSe7Sd@QXGaFz-xefmUJPH*8+J z_6dHGAru=wHuO{5l~ZwS;0(1kA~>4zVD+Ddi{>g@f>Q@98sPUH4qPnW_0^$YxGK+e zz-&3@7{4DdUi0^5`}^q7=l3@H6YJxajjV|GigC4MZ$BEObGVgZB!9RpO&WWRQv==Y zw_^`+zrZww^DepOfz{{x-(oKhh8c?MtxkMuzcOoNk35Lfw@rdb&cDZB z64OfU^w5yo0*{9)6d*Bq&X?@pEIJF~!0OL7Qp7iYS2q3BsJl0er##u`Ci^*KBNl6h zLsLCMd&DjLqx`XE&kP^hAEcms<)z^>G5_u`mjkAWF{S)|(6BcLoyW%>Fdf1sh@g00 zMa^An)&5z2XAFae<6$Igycz2mK^3k0#D0HZbl)}o9nav5eM{yuUd8^&cv$eD@(b%b zk^#RT7@}DOMYKCO*gqPCRlQ;|D0V{z6yfvx0pmJ<|7rLe-BP6WDD9r&fO&X+V}`9x z6Jamew{0XlJjkWhn3Ds4k%`s}c&RpSuokRi_pzDrWJA)(cFZF~|E*m^v!qJKzzRzm zEv+oM-b)6RS&&1Z_pGh(gwn8EhD* z#=`Mq8^av1FZB4D{e5}xnDPlo;0J?lxpCOqI3-wt6>iP)epa)8#Jc2)2lXre5ucs`9Zbk;H*sAOuzm{nQ!X_ z>fe=r)xX2X8xx)#uI;{JC#1c&`(K zKKx`o!JnJ#rV7^_I3uqH0R3aVLhEiIS;y zy=1*+91_IFKwW>$qH*BN+zRQy>fddKk>BI@le1%7t)z0=vSzPBZJOtJYJXIHsbe!M z9*2sn6*b)ProysmQ47m{GDz=qP$fXysR|*%o5oEf)$XhID;LyCwPUDH?^`bsG*vok zz0}aDHAc|vqiG+2PgMBuyH_on!^gAA_WDDAL~7C6|J0`s!V#%gvxC6S5PK}|4bYz( zPdrm24zOy!YTr=1f_INiR_=-Wlu(~%##`1upWu@PU{ zRr$TmPWvm!BZj7G%dQg@S!5kos;R=dM(|l&jB4BLGlN6@oP8(l$YmJpmI(uiF^32P z=y#1TVCZv>K~>%{_?%&|%cI&gGT?Kz7eysq`@dj(ILtks2eM_Ci+Nxj+Ifp+&JK+4 zUZF?%jtu-~w}&zG8LN)QfdA~-34_nrYJ|Z~5;g{gK4%!rRXf5+!uN!uF`$EeIL6Rt z>>|d1x6&*2fZn%183wy>J_et&y&v|Fv2Cc*=a?#N74L`V@Xz>;fDhMyV%gOfn97Z(&3E_vWD z@n!KmfMT~9Z_H_#3`0-_L-|lN1{gX+qA{3BOcfZ=C9252vYBI3K65_jGZ&Q41Fg!( zKu^S7%_Qd)Gx0H?FP}M3K66gFWO}8uFnCdDB3kD2AddPx@NfA%fbx03smunUgtH@} zN_ki&bI*jC2f1)g6;MtUkv7NBDG5=9b>;E^%H@IA&Swsk&m11)5(LU6NY;`|P$x2& z2hlCJT0x0de9kpdP?|ZiV3in4P*93d^4U2CUbkTU(LQHm;5!v-k-bj3M&1V~BqCn< zN;k$}#U%Ss#+pe`P?8{@vkV=n;dOlsG@sRaOchW%MZ{``^+}GQQ*VsNT4Tu=*s6Gi zWO59k97DNxMwQkV8iTwvp9j&>C8+gvHU?0l3J&l&#t;-M4Xk~MwhKzSi^Pcy*%&}c zcU3RRX0A1oX3l3;r`Z@ddao9F56k4wTCrKcCMWD4#j^6!Mt^mpnT>;tbFD``OJw}naq`mNalRb?Oafj zIcxJghZB_ZYDo?UhUakd>{;$3C}jYA)-9VT;t0yALYBD%S@*jHk!5DJs!X^9SqbM7 z)OuN3qN-`8C8~OY0ew{IVhr6b_-N2XR&9BO1#Xf}s+Pg$Sg*(sq*-9#7qT2qP|5)G zIhUZ;^O^^Kfhui0bD*FLUhz54Uh#p%KXF%@9FGA8k<2mhsTl@1iUv@$gev@ktQOCc z=T|`aie8^HPfZ>}Bx4?YrhXUC1B(Dk82FwX15J_*Y9*3c6nZ61#5d|LOGFj^5W1iW zf5>_@)?IucJ`_7A3#IlE^9l^S8WPm!kL}->DtL-jfB_Ew#Tbfe#3<#*_^%iP+VN_d z2eXQ~i^oNmkhyZcOs|B&41_^_I9^TAuY8m+w96CC0}L!13F>pESAtUf(C5qs1*Mt{ zpZP;Hc-2nDYtN3|@r+7*3KFG<+#3N!6#?JkpJRIgiiqN4;3s0OAvz;dbeYepbHwwI zuSaXRy@Myqw1yQuQWXZDV?WHSWtU*+Gu%GBf3AY_OgYEVZLqb^iFU`44P zu?>L%zwxyCO!X?_pP-a?>oa*}jDglTRp@yZE3q+jM^xd}@oMoH=r+=19{L>nG<*|s z#25JII6ndkO+a(_OjQCsIAnWGoC!gmoKNFS!k_FDr;zIt;C`lNiR_s_`%uh>&x{)T z9k}E?)8{P83d%VEc2)}pLmm;T_?)e1fkK){(m&_(fV+4@Fv#EHSOX2{ig-or$TD`$ zO`t8vp3jQ7k$x#E%QNvAUlVH!P+CLjY=G8K@fgZ;m(Sw})}G(_*s`+~^(pT2 zT}UWb?x{~$Yy^$9;#1N0tfC<6M$YWoViy^2$fEEA_$mJ!TPs=$M}?u!u^uTKkk{ce zl*K-T6&YHgIIPdHjM0DcA|$5I=tU%B^-rdwSR(6)F^Fz(Rk4IjA+`tfj`tSB=pa_0yEnZsaRfa``hsVOgTNC5o7|tSd(`3`mb}v6ubaFUl#0jl= zJm~q#`u?l+%+oP+_i%jAZ+eU8l${sQ+0RWoH^5mY?k(WMAKE$8NA@dc0(DkUXT--R zKQGvMc1~eEG)zt(as!I9rQ5?PEuHP#wQv2L*1-xsKG#@F@Tmyrc>mC<^16IH{q7~oeSvWW({Yby*Ex+ zKDPh%s_!l=z}MM2-3i#3P*m%~YIQp3k8{RQ02I9Atg^l#kJuc}ojx46i{_yZb5Jb@ zfGaYUKA^?$4S%0YujD3EZgUd0rl^cG{)JnJ;~B-bQs>}L4RqJKFrDq85lnp3z11JI z&GmoU^ULesxZBY4f?NAAXN)u4A-QI9>mf(b@ycK6V6$Wt=%(E#^5g8*G7q`LBpqd0i^onoIWsbuO%}+gX%XOipS4KQoVk^-v!?ZTOClaQ&q{aJ9j>*dYx+e=O!Juh3*fU_~qbNbc>95!L4a@HqO^v3mvu}1zLK!{t5o~Hs}OIXDf`}=zvfv4!~nI^S4^)&0o zX5ldY2Ywy3nYEeH_XeT3?vWU8J+{eHgY_%6KQ@cTYmD>uQ|9e_WhUN3bL;zg?t;TW z8@b`%2fE7lWxY%mQoi^6l}dQ|mX#_|YML3z!{0Yb8R?F3?Ab8he;5XLi{{pgjzi8c z=2RII-E+MqQV@~g?=>5T^{XsSt2xC&{=Q>$Qn?`SSmITFIlxA}zrJb0e_wz#?U7Se>+dzG~5@G{WLuwy%7(f}5kH zz?@zr(YFU_%$-6fF643M)Fk#ym% z#?h}=&FhSBIv!sCR^l;QDEKXnA^Nk#6F6wR?HT0;JldsG0 z8vKG++Oezw-*UpnrbU#Q=1x2#MNi_`H4f;>KZ=xZ7(BA_8@PCIe3s^dyuq8U%ug@C zBYs4^OTJJ&w;CiS@a&s$%sI2BNqHpJde3;P%=BBEzp__i#Bc1+7~3lfWfg*NzP`pU z6$gHQWPh}lD8HXHZ%swwhK=--Jq>~wk1w1;d^zH4fp8jH>nOh;Uym_YQ8}^yTd8Ce zO#iih@?QDX$8Dd(SAIXX?i)?ysVL=_GwWZ*6f37GaNffe>j8}_zZ_ZjaLuGzzCFIL zdDG_}a67y_d3r3zLqmUhCKFW%EP$H0^my9a;Rb$dzz{#Y55D914eS!|1PHtmmhjLr zD~-+*pU81fRNwRTFz$_$P41c>NAIxAF}>tq_%vTHO>K0;en*?}ADgxZGVbBnVBySg z`U_Zd`I&s=bS-z>=AkDpPU$#fBgm_hU+eh+bM#=_(eKCus^HnC&A!er;VpJV&cnZ+ z5sts72c&_=t$U-Eurt&|dEU{bN>A{SHDsBm))Ivx<)ZkQQVlL13CTlu>8toy|4r7Q zmb67S`PAw>L_|HIq+bzo57xpf=CLDyXWXuQ4B0GsqP%lku~Ouj!+B#N&et|toj)Bn zuHxO8-&o_$Hoq|{u@@rw{Ls z_Jz$x-<=6CYf8s(eJ;++p_Vu+lloac>Pz%u*W+KyGlR|<_sh)iRLGCnYR8zIf>kiG zI^Vz+s^+0DG|=$hef&K9u?D{86tSq#h*xqwAJ2HwslSPW%G#atKl8!b$;dMFfR>J z)N4`mu*6x((rF>S>08yH=J@m8F!r*I?fC`km0#3@z$#?ko9A}qKEjfIA~cOoV`8d}XzXKmvw*!AyY zFVg-x_8{#4DQiLJdTYwV6DYDOuf35CaFzjU^E^$hF+a`@kgO_oMn#yVeck$DW#_$= zU#MPc?Sn1Jwo5N)3|^I)kR6;FL3qFQ^VK#+FwDO8&l_tGK(F*&qL%XBQxi#S8f4kc z!4q=ogjKrJ3xE8(B4g_0f-73d)3aL4F)zIzs>`f!@F8AJn0j#k1wFkv%*?$tr<$}T zbosZGwZEcm?Kkc0Sb-@Xz@;(II8#ubJdZR=3;SfX#%gSH{}bBZYUplLMaPHLzq2aT zb9uE3SXbPqeYG5xKde_nn^r%-XYf4vx+ml~tzY+GzcTEHYaj1x+M35_Em9-HmRoa` zlf(OvMN^LMe}~4nrei@hU!;MmL1{%)tiD*5uS&5es)v3)tiMuHrZI-^@8eA&u`V(d zKdth$`H`~Pxo)4~6*kgBB28jWStBZDLpSz-+2G5piH{fd ze_M9KyT6aX3DE!gK7#j>*M-lnDW9HCfhR}-uA;}{V)MXwMKG%#m?K`T<-%bvzyPW3KUfpRmr`la`KI82(eXObUb^i8^i@x z+VyD%D(yUR_Ivw7_Jq9^NJddS;%|Ju+n9VTe5dZMh~~Mb$1i@ZqpRCG-&3b{EO`x1 z1o$sycd?Firwyn6MRR?)&T-r)jG=0eam{AK>KG3xE1c?8*&XnFixm#5YN~7cZp>X) z@eWbqul5(~Umn|>l^5t-WNoFMv9-FxDa+C`y6zSa4a(M#Sr3Y6#Lhe`>cVF-S+v0= z&3Z;B(Z)05`Jc%1(FmVvW9zeAp4W^^$Z_hm9O9P65TZ6vWbX6*T;A6`av@-qo7aA_ z)~M<`pO1~qgc3314);#0zN%94Jy0D1>P%ybI`uB zMN+jU`-zzd2iX)H&e0QBB8>S6jelX+ZQP&l#?52By2kR=t?!ymXL5cGxh!rTSwnw4 z$jbTc`+GH4scjRxR3j(jZr_0LYV*6V{O96>o*1lkOaHUnGL`8^iqjK?13}tlXr5KILU|qjT>{cjLJ66+vp$5cT#kVSfA)Of~H5R8oJ@hEzKBOHwOLY4>9u-(;xQyzBB#UG25)|c5c?( zyw=?_eS(|k)@OFW#b4cRb}`C3N${+y&dl|!`%c{CV?M|!djb&8E#S76F!ZDacyQ3( zCs5vl(jO5%aBC1La^DJGz8BI66t|figZsES2HJ^~z~*KgH%|L{g?Hj@bN(Keh<-i$ z>BFIKxW%2wh{t|QUG#G^i*JbB_#-l}a>If=mn=rLE@Crr{GQ30w>gp7M3nJ_0p`lA z^*O$03*|^dbJ6Gc{+jMubH|dW4In-4ibYgm(cFb}@59|R^rb%!ZaxCT82&jMgIlS3 zk|h$+z3zAn`3GbIZD=7@)u#%I^xOk(yy@UAZh}LnpT=%whM>wKN&wr85>IS@Q`(@Mk zOT*iD`rHycJjKhSWmtSPnlQM5%pFqQNiKr43 zI_ntBCdS~_EHMEL-I4xy0fz3Kf&oqMrx@6_r~)Hn=A|V;`rR+vHM=!M$=( zb!dqGI=RehCDt3}1qbLupJR*RsbS;~&m>rS!jcRUtz zA;0#qXvwQZ6e=gfmx@C456pNhEC)Ts`k)lsV{CG{%eGRbena*cjjY^8`T?CpEc{u9 z#kkUCu=E_J>~1$+7`?|AgN3H(PJc`xwx*{HfQ9YI14LN(M`VuP!y8(R7|%;^%&cJP z=@s!<%5WXa^WAJL_@-yPL!nwZg~&?r7A#umDeva_)c$_m>LLCXlg|gs)7#Gc9U7c4 zuUGavhI8I#J8!3)A|6BkIvruzTKt`0)MY(HG9gFT(;1MYTFP`|EXhIEODsfdGOq+2 zdP!EoSV#p4#q!5)(KlIxT8g(3h0UjEJQrNhSZd)PmSB<5X)O9s436dnO?m=~uq1OLcZ|iXh*V&aSuijB=Fv*GdGf&n zi^o6N_pel+dB@W@p5@~aJ;-2~m7c&}wjG`7Tv@^37VUbt(yjV9Z;UO_mTBSayQRO^DBR;Oi0yoDZaysXU zJ$b~TU$CT$YN4IkSjw5?amd!lII{RFIIUBVGFW;Na4co!p>>3?h}pSD3CriD7Hgb* zEGUzd#lc*ofOG!~Hmxj@0*5Y?vB*r8j0INVJleZtUSxOmSmbUwH&}rejlv`5dWe*; zFy|q>SfWwrg4-8;s6L#@OY3kS%U4c0md7yUz~_8kL}Fky7JR|~XFLQ;&y@pLt(+Uc zVNpI7tz4tPA|@9ssKstt*_V&>3Y!8~R>o&lXfjR; zPwOUqR>a81A}hjE35z^B_5*?=gT*VVr8-D9mg+UqMlv0wpN~b3A#cxE=w)Wnz!6EX zPEkmFK(Av8nLGI%J_o+575g0EuuFd)9a@QfX7++-(^_9+sg>!lDu~)?V`Nqk$UK`D z>wK3NSo)J;!9Uh*qEM}j8+bD;K%7@Arx2?lk`P(o3N7?9rjTduAyvuCTN#CT9AKsM z@;_t{@mTmM=_?efm1P}*BOYm9U@7BakBWTttArPju4^ zRQt<#Oz%Z9wBR{B=2;_go#QjBt3I(A>ip?dTeWcphm%dcUn1|y`Vh+|KSJhsZ)_l* zHE^m0I2Ilx(-CHj?n_71g2&ld%Gl)p@jzq*ab}8-!D65j3e{3QDdGnDOO7o&qlLX> z^O6^IPXIPKaprZvBI3%C z!;ybDRv!JR7r_bTV&1~CVhWY7(7$$l<+tN(k=}tLXLKy0U##zUiJ*cx{A{g#g33g?`tKlwsW z)R@P;G@S9^3145EPvVR=&oX&ve|BwDo_fZ)GV1l51JTK3{1*2To*Tp=J8{A}0`98n zRzTl6C0pi)?w3|3ZB-VPNf1G0bFp{vfXJKz6P+W#CcIlW87l&zc1`&q*Ji36{xgj-S}}o?*u{vu;4cuqLt{ zTCqRFN{Bi5JDN(Eq0fb;<5HezQK&8;v14Exf=4TkzhL2wRY57OIFbUVjGXveTFbDI zLct;e$J`*UlQWWYGL~97H-J;reo-vdyd4YvWE8?_&m1I7P**oL#^Ce zsr`9I2R<$QMMj}2jpVmrk?E4j$5>?BNLCbji?NPcgyWV0@rfvYGxhjb9Ue?Mc4@`A znru~d3Mj{NX`wSOn7&vwOTR-anrHl|kE zJ2OwXjXWdThxSXiyhTmvppE&!PTi9~#CCp`34<{6ahqS?Yy zEhLi{``^sdvDC`3&uYgr{nCS~X56f3?Zh z-dz<^G+EN1E&D!Ltre+d@eT^zW8v)J&LW?qQyq8=diPc~6X38iX(KJg?TBmgRMVB$0=cKaG7)^ZuxJshG71HU2l779jb&KqP{E3M2prNc6solhiwLE$ zz{>JKjm1dlP-(^4qu^xujzuiZx#4wl$D)e1WGt<39E%oMuUQ1s6D4`;0Z;ha9O5b~ z5pLVa{+F!;nG?K&B8{V1AKN=vvN|#>TEu+fOr{r9P{=+U3oXuc5MQWu30UYOnwwdP zV0>O`W%&!e^Plo)ZxIROd4Z++jwnQ_!`TLS<{JBY{J_B^%?UnXja?9p2g!YWm9p4H)b`d`cf{Ye8m#;KEb z(y@GV_l5F!**GK0$07+bgv_fTBchqSrCQmZm8^vkg@x^qiDc3yU!&$A-KPb$aW>6Z zlyNsKS3U9Wji7Tjx4#fGOI&7h;Py}tVcDIj6&pqBs3N+ zRo*Y!H}e%lXd(xccA}~HusmvkMSV&!fff-n)@k*Q?4ZzF$S;}~aO^~}x)l~JJbZ?Q z2NH$&9_XW|7>gK#jcY7##rj3>%!w5j6snb-h83K4yBrIOV{ZbMRuST%x6mkmrpOOg zi+$2Ofhe9cJI2Tz4~mu0%1(v>r(6n4EUh>);M0^#h*N6i8Zd{2JmYzRg{|YwG&24r z_GZ8lCGqmYqLq1Tu#k#;pjudLZ0EpXcd9~pi*Mq2$^U7mfIJF|B7e!S7=izom$Jv) zVu91XuCVY7_`!HAu;dSXELyQ|hbF8+Ub?j6EKG2m#*mch1HFvnKUk^w74~Pv%|^NUw+SS*^@cq!&atxS^egCG&!RTCXq?ExbZ3FYE$46gSjj{0xgo zPdpQav~mvsO(ka2!e?hz2?q0!9?CPKQ!$0gJX{Z1XCU>A^XQKx&Aimg)_g8g^g&qY zZ_Yz#(jTy}NMxPK3pgxUoQLN~In#Mz(Yud@Br?v^JN~+iMGGIr4f~t+H2GKtq7%+* zRC+>wITo}@-t<8$=L`Pc{V5uQN6yDm1eEqGW5wPw3WaDFt^D*f z5_a_S-tfspIQ2~{j&O{s{G7FFX~pvej)(@2g@rAV)x;E{S<*GIq-WS*hNV0nTLMe1 zINl=zRywMg(1O0q_X!TKjz21`SZ5qgHFj^|;p2Hh6LyCMIaaPSV4+{wg0QgF*n$K{ z)RAt`2U;Cl>pT`2Wi~H)e{7sS)XFIY4)}tF6=q{8a+5QGODprv4ks^ES~-REjvp># zVF5XXSff0HR}eGpMW*s!jODEy3(u{U3|Opvu$Y)a;I!h=Sk(T|%N$Fi6|BrBLlb(( zc*0UE^ES#Cm4&MhB%RL-JoMGaA{J)a3(gpecE$~|ANS<+pzJflg40M>6w=CSTg;z2 z9bV9}Xl2@qUZ~zCEVbg?03U`XASJN8m2rby+Rtu*rB=py;PBd-m$$Nc;mOEzMIjyo z4(3=|M=O3|)#Ma8H{^R29fXBXh@}i18X?c-tvG{(YhaOmit}pa^MW3K_QhDr z#C$A8nRs4kp)?UJwUA$ih4pJqqKqle_yvbX$oJyYXl1?^TOq5G@AXzDW#GtdT+={Ibdz261O6-RDW*k9x z(R{}uPQ_kJJitoPUvDXkLx;GVp&JNGcAOanDw+ zRwhf;He3T}Ay+d0Uz@MsL?-Xo*-lUIUo*aNBLw~czmz|$09cEPX0ZUzx`MBDeyWx86F8_5ZE9t*g9AEo0TwMq>6k*`@U$AsTRHdSqsgPt8hP6| zkD{innaD0^VTGB0(b|cbF%}w0W*)CAfunzAUy4D>Ibv=Qt5jpuSZZb5Ab(|jC<|4d zo@KDm#A*RAsIk;qG8R1Wv6Sm%+#vTPN0Ag>6{(s zY|kz1Bd#JcGv(PtI?vnW+4}JjI3xz&g{4+puK-JHH)IVDi2=l`$jX4DYAnb>>KJHA35m=>9k#yV~h_NLu|``S*I%D#AK zCa0-0I?!$S3iWsgX;O?ugz@^Fyakal(@|uHWbn>l(aNfs1x}oDtc+7yY4W$m;u9Q> z=Orw+BDILc85X*RWEhM25tlQ~R+N#)1dAA#?NI{8%PGLm3m0 z!c^YHYCgk+6L@JdFM9HJJ|?|GtB;9a!~QZ>Lu6CA>w~@O6%< zy2ui0@sUW-G4c24aXwExylN`qt=c)Ya1k%&9?aYMn1WQSWK3`88jmc|Bi6^lR93KL zOuRbuIwtbPVlxgA@07zAOxn5cBPOd->zHT|qvm6RNn|gWv~%raOhtr(Nt^tIH-r20 z&^h7C`_y=LhMuJo+XMaydo2{Hol`{4=@lVlrtDMel6XuwMgA>&02d1QCgvZI_zU;r z!a~oGc6+ziZzsRJe`heFNj)j!hQFmvR61wU>eZfkhxLthUHN88Ke-GsL2*c#6tluA zk60a9cfRW9?i@DypV>;d)T=qqtWz(%qlvm-{o6*>n(Oau_&YbE{mg&NFMJ<)pF9)( zUJ)aU7lI^;)|hyT%p0Pk$}{AdN;~rsg2c+4@2b;K)5tUqN`X^`L{G#StpH*U;Y+j& zB#oj?tjVc`tMHcG98IK+&S$9r6quKDV;= zcJ2#-#FrF_shvxVOorIucH}uwu3tnhw4%&YZMYYC$#MPRg2}DtQT=(a-6o;kpLYP4cfWXyk8KnG zO-@?qP&?x>I_}{y<}541uS4JO>my$F!xLD+DiRz5u&lkxBXjtN)Ej&gY_N_Ye$M`5i_ zB+AFcXQ--)4zcPI&z4}4`8aQdNxq$9vTpSpK^YbPI+rKD2L8%=kuLcH^k!q?o8gDD zMY1+LAl%L{HHO!G7?bQC+siSv4)8I-^a^^ceS(C$(jjI|e8)aF_TTKnDGr^o;XR%C zQ#~0Se+?Jh+bBE3hvc(COVCiKN$p%a<>|fhik#tIUhQ>AR-qcxV@B?$kTxDd5rUqW zJ@e1z2_(`kn93z{y(XteLtSdBEFrsmOrW69=Sgf|5(8LKFgy3;$|mysL32Wy?&0vS z@_HGyKq3?85T4RwK$HdEvU6Nt+P>8nwqE7)&6F>ye7feqT~&rMdsqGq|HPNl&g2gy zyvIW!3$>|WX7LzE_zou=QyFDWE#ts@A5-lmW6Gk@9*wCsIvh(8UxMd^N5b@Wj>(Ew z9!i+X0P+9Xn1Uq2)R;uMC78rtX{+KLnxEMgkXQ%w`j~hgG(R6x^)J~oJ*iEF;f(dx zTkZU4zL>Xg?Hb(00FIg-wHeN9adPYS@O0gslrFp)8HICEZG3Y!Bl%DKqIf|Y8-t6{ zjC8h)XFJDFXw_*->Rx^Vtvp?o{Mu*Co2AM0@7Z&bz@gtLB2xb#R(qAu+vqP5@rpeM z8UC>w{^C8OMP9$7XEGAJF;6QK#d=EFi%_eG`)=?3dyPRow@aB!bX zdeSmy>h2iiJ%fF)`cG@|4NpaRXnaG*GR~p3_%z8JFGD-`NhEhOL`ycj_ru>WbG%ZT!`oRI?uhl zoog=srmXZ?|Eity4$q{#U0nAzygRc#IX<4pr#3rQPCT#g`GQ%IRY8%DKo&u)$n;d2 zR=kI|vz-d&kB%1ap*GUZ$7Cf?GG}}$J|VXau5cba> zk5Otvd#3q<#M{Yxly>Gl1gV@IYD=3jU$YtXvb&v0JkBByeJjHdXS|JnjO7RjdJHdn#{3?dwKI&!7IyRx;#OylIHMi&fmN;hdWFQRE=3nDaFwvz4sNT-07N z7p*~DPqZq`>lCWd;vckTD(zfPz(G$Gca`~LzqwX}iN|oC>h0X80*RHohP?J`uA7X9#k#NYc5e4Ts^%=MrmZz9JJsKqPE2F--Qi6wU)Y+vy!RxIZTJ!VnbYU( zoIXKfqoU8-xg3BbV|RV?cJ7x1NzPWrM9Y_qDe0GaqUA*P%txSW(Ca$x?Oex!BuW)( z)m}CxS(-;;^#reTYSD3DkKqN?&Us5jB-3)KsI7B|r)Ry>B|Fu{Y61^+H>Hfe$?csR zw9$gxKM9iDP*V5yQp}>=!pyUK_ziXZTaT&AOl(p3H1dMNN7_XEOm<-6TRe_=JIBN$ z;$_^k(bj*gYl}DFX7pc&jD9brhS;X6k2s(#^l9RIsJR6LiS%5v z@%HG}l38f|ROU}xJ0Ys|>{_MdMf4DS);S)z)W)(i$qG_yB&1O=GusvvcbStJ7zPvE}0v@tMBzwu~Yur*jHqvbBaL6W`kLnoi zX;lFvm&szCAj$k?XKKSyZ2L8{m-+0S@s#JwqOeou5n~WXT?hFL&ms)swXcU2yRni8 zLp4NMh(43O^)c{%(1b?mb2bkmsMcp-@EJ{t#~_la(h3Ilj;=>kL6Kwvm+=p1W*>um z2%EyI=(A3^^fAysyf|5)J~NkSj5&;W=4ca<6M5(}T!_aYuO+g8!DsDPwf6z8Smfl% zFa6nJqpG3v985kdW9(zF?jzs8I`vt;tiO*dA4X0qi^dnzLgQjA>=Mn!c4VbwR~Z(1 z12=`GsDYJ6W07eRjXaon zsReF47Ar30iNd0l+cI`bt}Y&`rKr{CA$|f6$jVL86yHX@C!!DtWJNY0ELyBnGAwBa z8bu$pGT*D63)QQ@(x}9>cr54h#YYPEc~@{3$+ygVl3!`;~L9b@mM;yB0rDc z(cFl&(OAk#SO+kcT3Xk?D3+phhJ|L}=QS4VyEuL^A2JAXCa}~((($~=obZ7kud!%h z0~r>v0NON`S{a3S3gjgo(jtqt3f0Q86z!%? zvEt}}Rv=+zv!#`JHt`H=gd1uR(_h=`9vYO6OV=M!vi!5ELvF(Aj=~D;Mu$d#qn75 zFK#;)DIZyNlB&{XRk7qeOZ^Ma%50xisR|A|Xf@pYo1V`#FnW7(@14nQe_QJ( zGIA&Vx>db-i}aZ4`h8;;nvwD+bhh&^Z_?!)X+5t`EHmYd5`W(_3feVd{?0~eFzZ6e z8+}GgVygyA>oB~qx3aj-Y6u-vF6*t_W{7;)2%ZrvT4-~uTSOsp6k(~g1dHkf{9r7` zA%DrZ0UUhuvAmU0i0+elX)Ic~RpUun4>*Oiu%m1&MnYy9ORd-oqYJ8v3Cmjl@f z*Th=%gqG%Y*iM{r>g>K*%csL$QA{;jiJz6@(`i#bGN z0Y_#=v=$aEMy5Vr+v&gAH^-ZAsA=vF{%y~GqmEwu9iC%nT??(h$IEz5PNI(eVXjp!r`Vy3h*3&OgI_p0!E3;x7oq0fvVKB|SEh_Q%; zL@4qz{DN9>gaeM~uFTk5*%}g`K(yBCy|iLmkS9^S6AGm%S?;b1660xJXd%3bGZL_< zY85P6OR&&bVmA~@f6?lg^YRN?y@Q4C!UJYlR0i+~8jBV@iLvngL#weSlW7XG4O z(aQA@cq(G7-ib`!ipK&@TIE=@Vn0Ri;#T1&=ahtmBad9^%N zJQk~BE29t%R2~k6-pVXRc{|yMu!#70x{N}oLKlTaE7L>#3>prc_D*P#Wkq9w z<$5nHT1&>FXXyrg(88MIv9wmlGim1qoy_tp`C8(Lu&^^cYRp5hBw4iATbXCW6KX9; z2IwtTqVc?dq-IZL2i`%UcEJ0!Cst<63Rtkz;@@~I@trXo3n^rr$0rd}#6z_*ABC<; zs+yNtI?EN!3!hFLaV&4e^HQdV?lCX5@QE1~oFKOq7OiY2iQdWCA~T8U(5R~WV(-w9>kYn=b%e(9RyJq6 zDwZk@P%HC9vT;!br?3dJ$4r)*i&j2hF|%yt1DrB5{Ia)@Y0N{kgh-`%NoTUi!ARgJ zYxhK=-;e*J0 z$Srs;l3IADXkPd#G9RKTSl)_#3UKHG{#aOQ#j9dr!8soborK zeG5yitj0{#mDP(vZ)Fq$M~;a%S08!3OgSmsz*m-5CNHcPEtHhi!jr^2Br@rIiN>PE z+AzbykMWmAdIOPTN}C)pZ@T z%w4s6RY&V@=kfIX!M_hTcd7Xcul~00FPR^*Q61h}nRb&$%JZRd-oi^noCOYB)e7BP znKuGXD_88#TUi{yUa@n0I9O_-<1vL;xxA*ZR5gn2kH|(gp}fdj`Mi|3XeFx}3>kVH z2Y}P67pwIa8XC`wc!<3@7OgB&sj9)cP&_23pr6<`3ri6c3c->M#S}u3*XSez#r_Nn zpQ=-3V9`R0Gb}WM7y^aNh(6+cMAV?W#xil9aubNf|h_mH4Ew zXkn+(yznbfsEo;5Su6#Pj7hfaEp#Ls3){e=p^&^4yNNju95yK_msXAi|Ik;BrJOg` zUU~n+tZH9>srp3pJXmcNSb z@nAFP3gc=_wLQn{t=FKA(V!IxmbN@=JSLdff{&>-GRfwN^-vol9x|rd+UttP6eOz$ z$3%;;+-yu%1fC@@rrKD4hRK*#IV}>b? zIlFYk-GEN+xUqb zlQCFLXiTzqnWm|Al8~D|5m#y54A)kyw;ds8xQ! zln+~iskMmv9@gxv7qW;z|B7FQE3~0Mrxts_LrR9!3Y1M}n4a^yeR$TN*$1`=#j4cc z{nX~)cua?cBT(z@+&crw`dX_YVXB?+7EE#qkMO0v1QQR36rEby(2&nlo<}~GF==Dn z8K%4&LmRZTlTocsJ z?GsF9iI3BmY9pC!p2(oZR6Eyr;FwhzlQy|UHm0yV!jn_bOCI3`iC<8b=xxKqela7ow)h0v z#Ohq0_$tQqd8*C0nI=%#SJV`>YUe9ts1y62mjhl3v+R0gm|86`hA_RIONFRHJCF8SKjA5*L*6F4j^_!a zkIR^}g`H^v62aG^tHM+pP0GeZYsoFeTY936Z&>n10-m#$kAR1ys^YZK&Z`taK!1xRVfsIz*LnYmpdLEeU>$XNgEHHQ%j`u zj0;TKP`m_FwN>X3R+i^Y=m4X5MbF!0UD=pK5P3I^sW!FD43kk9(=9{oyj~?+uc@VG zNj8yX1z-Z{xth0^XrJO#;gH&R=WL!@iLfFThtx)<87BIJH+3CSTW1y`@2YyI{G`T2 z^Jr%tU9~)PMtQKeiN86u#AA&kd~S|OOf9@6pP`*o>ySQAwaMM`G0}EkZ9*+=G%3SGlH>s% zxzx_H0#?O%b+{tE^>#i_XcK*oDb6mT7C+=w5}nP!^JUrxXOJe^z?fqv1)vl zW75v62lx(Rfv=6dEg%2N@cbb?4e!Ko_uZf0`M-uY=ajdkzt+_L+NU&rH#}$af7#7- zp4_Ng_N&z^cBkE+-+11B<5|?4uhW^g_G$UtG%Zh}KD&O-a1QzA?DLa0?OA5LcYM>{ zHuB7F#qwq--4ZT$>ol^mQQm}p)ZohJSR?iOL#_N+| zUVC<0j`xvo4!8BcAAVo0-u_v5Us?ZmtcTU=ofp98zVDvRlcz~-8&%J&#oga4Cdn^N zUOfG@yc4Re-dt+iv6-nQ@bRwnY*CAj`HblpW}K74|g&&@iZ zchmabvNogoE#-}&Ro?ovIdF<69_$Uzg*;}O3*BfAH=+H#CfvDZ9#02OkFnkw#+#!A z?+qpG%-bil|Kew0L+!5d`AipAdzg%U$>27O<9eIgrv1A+)bDw|^0R^SF5|fw5Zmd+ z-{bRoFe1JUSl({4vwxP9r&%!ny)_@68qcvWbpB${8+kOnp$$AU4IS4reb1X^&RM9Q zfsf|8&w)q3>5k#j!EfCgZ@;h^Kd~7jxA~b0d$l^>rN_B<+xmgySn`D~G!b9CuC3)|i~O)1F%{lErUHi(WUM_h9w+L4un$+o_)>8nwOl zIY(s!UX(r~&bfWGe&%c^I^kW=W!_pRZ`(eFMNbFRv(M4D*PGbe{<=9k2G4b=pT>=b z)iQl+7Hf0$C*$Ui_TSC5^q!gw=BO2Si-q9Z&{n+u;Wh8eudbn6gC^lwpWFP2SG&gJ zabKKVziW_0jm>?JwOXAv4Cv9jd3Wu%IjED?`#751HP}L5tx5Gexythz<%{R3EvNG5 zaeLz{zVg)JLqn!P&V?7|$@YhHD>UfyEI&$Z+xz;4nP-yV=tB zp-eo6Tp8vn&Z4VmV&pfdqfI^TJNq{0(QX_`=KUL5fc~sjzwC0)J(XK^Z-mwApn2hE zCJTHNT1&kCPqW<5hEa%0vPUejJcsAD>6S3gRKJfkYj5>$*2{C#i}8(^s}{AtwH|Mp zhq`9ocguX=OMm4`(G0d+ml73}v{`+@p=`G29%PQHD-+-xa z&b$bo0+}%H064U1P(>_!8%Rxg~Z(@H>&AXN->b?`q zwDcDB(D#+pdL_>-(_GnNp&`n1Ys{aFW_+NY9~b#4RnsLKR;@gVi3r@+pLvY0Y&4In zdABJ9YQgvu~eaHfN2F!Rr2&t?9Om4|ui9 zHcsC^IhNiSk1s?&)dO#P>dD*jN?cho7xdn>f645X8x)K_kH_?|g4T*Xr%TxqIjL;q zLON@&?#ijBX>! z){lob(Ed0?jd%_2V`+ZZ46|V6Iw!0#FV3ahcQ5E`hsYZ0)ordl1zKytB^K~(-#_*B zKowTJv8p7!Cx0&KVY-H?bFsc&6dJbHR1_OI+vT}-x1gLnB=X+{l1$~UQJ$lniZq$Tp7;`6>it?O5-e+uUB zYszuW09(V)dKDiFjOujSFGAzTJu#EJqkf_}IYrWDd^h;p>mC$!q8zqRvb_GdghSHG z@w&0*54sZBiO-B!M!bNhZGY5~>7}24adu_P{%l&FQfh)_WgKzVG2!O-##QpgcKkT1 zmerhM&`rZ9JC3OJ{QWDFBje(!?pl5&%!pdYRMy_}{gLPXc+II|+gc;X6gw8HrYUA$ zQ_4#6d$Sw7>3!p_v<6<^8)@*8o@&1?O{1s3nD!_mQiSMx)k0IjzHV^>Nko3F;7L!2 zN%u$eN29t|Ec`1`v%i+n-a5M7^1k5qb4*S>$S%s5k(>)Wb1NK`q@rE0g4t5J3LG7i#GUGmA0#rAy+r>ew-yc*TFoYKo3)0K9QXc-ne2=z0hBbmFMEB_fkEk4## z$9*!?U$F)Qnjics8EvxEH92e5A{sDBt6H(SxXh<~`MV5OcmC z@pM)cA9l^6+?Jg^xHi;I`J1=FMfUU2+IFFXJ=X{8Xc?^^%6QuACkNKb|Nh|TmyI~K zpD5ESBeHKsC4;vcsOmJ9VO0An{X`OsDoUk?M@E76DVM?5dyxGq0_R2LOLc||iS7_6WL z-JcO>SWExxBaoTGvkSxbbKbAuu!eQ`{usXB!W#9l)oMy5`v2~ZQC64ZIw^6I{da1u ztatF(pBg{?gi4$dx3k4&kwmo4E!F=|2kYLp9iXzq6Up7@{pqj=^B=ZGy>9cpYAyC; zZrG^(l_qBhC70Vas;Xh*3}LnUmoEPbeyNL%@uw?^cY^+EpWAyvTof~PVje$xWAH$n zDPoP-<||X0&Qz5>{mP!AS0>AD>6@knnt%wyRfg>n34)_ecZC|{dDA(QCPocXm|LX>~T3p z9rNj(x%9E?nv0Kitb)gvu<8>>qbyRExop*VY^WXRtOGpRSyv@n?U>iqU6a*=!A{uE zo=TJ$&Iu9f-_LE8g67_}IKgi8)Jrnr@;*4}r~NFQ7TC0Y8I2Y@)}^&M%n;p_H@;?E z#1hB{FD`-`+u7MpkK>WZvu+uc)Mj>#Q<>#cnYuUdpEC*PJ12l{T7R5ny=ncG(^tnQ zyu%*xCivmPDV?*?nF3CBmS1QsY~D)8;Uiza^-Bj&}_g#ca<_UMxNyGTzGDeroif*ZtiCuaxCc zx1W)g{gpN<95U&$LM$Fjabo@q*%-EcJ6nmG<99r}fD7&QrR_BbH-ZC7)QWPFBBaXJ>r+ zzO|m(OSI#h87M=FL^3=^?LDpxzjDIsT$NqT$4|~m6M3Qisr831siPyg6!q}4gC0E} zxI<-Vb6CwY>*vEN4c&QUn8XZZ{8JcpSlgl#P*^-N-kNpy{Ou1`AT4Zr9{O{mU_Qbg zw6TiKow0G56BLsPm-`E>Hp@I-8+m!S!pRk#C&g>an&7^8^!B>fairZE&ZiQ6b?U7* z;%TGPb*|6fex=mc!M@+G9f>`gJJh00RN}~OqZPbow9^|A{gK@-FB$plu(qGxnZXN^ z6X2oAhk4r^I`YtL2y61#xMP~7yDV57*;5R2)uh8IYOI!%6U_dE{q21q*EX*`Y9k`U z@%QyuKCkKo5tPYy-URQ0l*otzv zcGNM%twHNOo0#UmZGUYYu0ACVWoS4SL{12|InQ#{`~uZ5yneAzKS#Z3>nzs$H!V7R zWvhSYT`)E+Mto%zA)X@DLiO__*F~Sv;r%tBR>FU`F^(CJbkl6i&;E@fZhc^%^7Lo- z*AMlrCA`1KUf-$iM@P4`{wd8;sZO(O!(_DB#;tO_)9xaIi&t9%U&H?0L!%!X#yh>Sa4usnp=@ZXO=BK# zLlT`YYvgnL{LyVnDtw#v-6i7!v;W#YU0(CybfDYH!!Ow!`Z=)Miff_HDE4=23U`q> zyn=3NN}m?r;enQ;Hdnvz`h#&=n!~C5@_n(Ivo?yyZtRdK492$c0_)ap4|2LV*eUB; zsyDan-D{9_Nv@OU(|fHv=q2Ax^QUs}mHZHWZInS0vl<&IIE@J1Yw!@+&sx zp3$py_k2_wYwByA=;?Qu=>?gw|ABQxw(T`YJaWBmh<3Id$1}Wg2LE&G#ce9u-Si%i zbRA23J@xk^>z<15b`C^q%6ZH-@9(cjeP^qU8SVW0*gp1sla#MhJPZ2FctSMmdp^fj zR&&*4Esst#i%yO?-u8ZE)|&Pkqv1Q#6*BF+rdzcP&vpHdbD-=5_N6q2W!)}+pv6(_I5g2r8;>V@mMutb*eH@ z7mPI4>k^UH)OQ8xHOilSjp*5No=4*;q4Cg=x#3%Uccp$W64p1?YHHC%uUMNDz3Era zJbx!otViqbo_fs=9}8#wwp!%Rc>1VfC}Z?b4n|t)yli)A@bG6z`dRRLM~hk~BbO6N?{t0F zd~eep`ny`Chb3pDB2VR3-8&x^&BFOOCsWrDDjenB^LX!zsvEX~@9~`p*0y*izQcR^ zxdCo);(N#~bQ5_jzrJsDyNrC-85^tJg{^&tuO*;ZRW|6Qk_M%C6lIO91EBnx&6+jg zJS=OUd;9q}mCAXzvgYye$tF)%d?*lOZv0|#pDiXMT$mlfX^7#8HCkt|!-8C=@IBg= z;P$G;0X7zg-1H=hHm1 z0c-xWQrXe=b+2p(-E?bee`%#f1TXgcqtQo2z3f?+niH|cfB$M^N#p#!>}~aoc1lLkDoUGFz&^(9lQs*Ds)Yu>Y60}wD|ry zUt*V-tXI3D=qj}x^n#uIZ)`7(a}|ee_wZ@ML3-pn)mAwZM+@D1YtV1j@9hb(di*-7 z>3Q?4Y{eHei_BN259)lEUErzA#`K)3=;`HM&d1#$7W1T{SJ!-01thZAl8@jeF4<^M zinhBfc1;K2n|A)*=;(xYw8v*gzA_!q(+~Qw&npsMXE?j2z4(jXyx&<@cNEdt%_t`~ zmgz-5YPx?NN6q@2A$|;99@`hY7*wdr41mNQ$lIwULaEg>THG-ZYw8y>l+sD`<8X-GZ=H z?F=eocx-)9Pib=}c$a$xcwa1$Oez`&fAG|(Cz=!AOPP{UI@GEok{#8ZK zG}~&mf&9no`)&O1uSq@6Q+&a*&E3sEKKQ(zHQ@>28uYo&wKA30Bq}LChI?q!G{2%B z;=AWaXJ%lal2Z~l?LV?a`cmbu%zoZ`jdOyMHx^9jDmnn=^@&2K>+B3&tu8s_c+7dI zV?(UGJVXSt`jYugfAO`Y@<+Vu@7M62Q}W%r``@VthpTe{?`i+o`{S|aamEqE<5$VX zolAxD(%QvH;htMc*i!2|E*&dtBw-cRb4K+=rK(7lp8ie*-OWlpIv9b<692J zm#BK~HO;x6TMABfdn}e6<;))q)r34}_O;LV=1-9}wGz)$@2u+tWcuVUz1kE{;O93+ z<7~+?SgIhbnV0m7yvaV6!ZHih8Stm$T3Ssn-jW^Le%z>`sR>*$y7gq93kx_RP5orZ z|NC`|GKS#4UdsZH&KfO>par)+ZNs^oTwXPXXnf}dv8I$R;X5^{2j*$x6IrfRf~J-e zRagoi&?~JA$hC-c%9nXc?`6|venr=P-wwY<&cX^-rx5!2im$E4tC$=EZ&znHZS9PD zSgBdzeGi%?A%DDlq|LrJUsr}pC6Kv|dp^Ez>-?%53Z5|PMpfb2v^%g@EmycTWC1#F zc+B8RjKSjJ8$PfvchA~u3j6lv(C~{jaCr*Cp`n(7WZ?<*to|C|7yG%xJi zw`Xgt@Hs_BwnmhK=IK3O>e%et!fh&S=v`eiDfvDSy4BJC-rr~UePj3D?lD-)PRHqc zpi;HaKKmDjPkcnW;&uNM|%b(o~7uk~_JDt+e-_z&Q~m1m-E)>6-!FEvP{*93sLyA|`nh~|{63%i+Um?)aTe<`bPq_MEu3i=TfUd9JsquJ`#@)&{b(n3BG49QQM&fz`Fn zYfk0cw?&V%Q~m4D$#r&F7SvzAx%8KCrr%4Cnz@Xq?+sg8rrhmYqhl`Dx7@SVeNAcM zSt*{`t47-I(Y<`UzZ0!7J?hV`O`<4T@OVz#+;ih1ZTA&X@xpCZ-_O*_)1t>dJ*wNd z7WrE0+}e|Ig5oQ)EM=~KB8hrDH3~gV-b#T6sdx`Nl z1;SJYPukUR{kY(HFHuWx2T(Qjr6C{C-lD2> zI$=8Xc&FAYUp*;>lNQenmpz&5_L-Fkbh-xvU-DF?l+OjOty|W8kvT+tM0IA@@HSsP zWa}nY%TTCF!_oa+=JF0buv)Lm8Wdff?rpC3x6*R+A_Ce;#TPzt@ZgS zquWp0vsUn3tuj}3Y&fs=e8f#<>5Nov1)~S>vG81HLb&a~I}`qSq#&`dGwG>CLer8iLrg3(Of10CjT&Fs1bK~78=yjRJ7%GZH z9s{S5Xrt0$e#O@7^DgJiuaHa23;5_|U$=(s@12!ch%Sl`bI%Bm=HU6wG(+s$tXLX8r?z{`pqi|ol@5q2%QGeEMxj(dN@+<2TKZ}C@ znUj~QR_u1G&H>bqYkwA5U(sh-I(vz#sVPqMrQtb#>qYzU9(~&<$kkqV-hQHrUb*=_ z)uZTX>%RW-D2qpB9`pN5ktMi4i7lbO>M8H07}GMh(&%%yaH6h?)!daoz;@av0G_vR zh*Bj-@!Mj4*QI_w#)+BdsTMtpGJaq4m&%Z@yMvGzY@eSc7I8O}tkF4*H0r4J?S4!lkI@{Ne-G+p12vbE zoT$d~QH!MMQ`XqG0h+?Sw zm*Uy*4duxM{W^+cj%C#1Ul=4%KYhMdJa1NsZhX>P2JeTB?vVR)`}DOst`DB)#!|Cq0r#%E2h85a4uc*NP4pB6%&F-)NARVHiK zv82ve@6gb~jp<-DJlEe8ZhTUd5w%)Dewz2mH6Q$Zs$gXGg6L7@{->N@ou_IFC(hR+ z&Pil`+$q;KW@aEA(n`N~V~2BoegYUxAp(zY7wHt6^bVcTS+3f4-0sG;DxMO^yIc20 z(j3>LTJE4*ryK7vr}IGdvtX}UNiNKZyy4F_SEN3E&hVW4+uUMf&=r5??NrM+3yycw zGjVHwH`Z@G^LY-E8pxdXxXlqu+Wo)_v$oQQ=ZUOS+bZy59~e{9LZ2IHAXU9@j3e9; z7}L$OGsd2yC*!^+b{W^6xL>PvXuM@#vdk zA5~1A4ox=VaASLXW#Ae*gf2iObJnR^-Ra;xD!lcY=k0IXAI@2y59t$Cy0J&U^}TR1 z+jcgpP?u4;MVMtsSB#GO1l=W@r^og`4_*#W2Um`o?D>UEZqvSlBRmCTqxl}IAnKD- zxdduFe!p)0dbOCn4V`nS@8CVQCk6Rlzn*o`K933Sb=CeO*End9ejf|@z*{mtsJmrU z$f~)EEvy3j>hK%uX{3$rkgfQ=9;68O=J$14$XC{Qia32N^$yelqY~|dTJ34fKVcl| zh^?$=h$Lh>XecW`&C}X!8J<`;NZ_|yK@#z)rx*x^EE)RcV{)1v6 z5xL}Is$0+d_&NBOZB|4O`qL-;8PqF3c)N+`Uz#kg*f(F;*q>U)a@ish?-2ZVYxAbk zKiO}5r}qrpv|fMR;PdXmZ;d-I-p@(XCM2g7sxpI8mx2B{2;bdiWkZx{`yd;V=SJ(> z->5MoU;G+%=02qIM*JH0PHM>Wqdq-iTr+ujZP0y7d3wIju%+OZQNbyedED{bIdNB8 z-*kRkHaGS7)d;dY(WUHBj`>~BGJl(cxL@uS)cw{nI6a~oO_T@6w;&5LOuaK<%)ha3 zIx}FlP@D^BpP!EpXM{1Fui>!>_ynAq28LE zBebxVAz!;^b~vWM_ifL0u&3j*TQ>a`Evh9DTjrY!dYI?P$zdkiUz&&b&4`jYsHI$) z>Q%dYJTISOy{zmwFU)R0|6HJFaLPKrFd0$F_bM*3ZP&LqOrEWmZ`YT~jQnk)Q|Nxx z;}51Ss;HCM;aNpHwQ^P!dVl3Or(p!GF0nVV^sD9}SkDlFHY~SdJ?LI*?34O?%Dy|% z@_bn>fvf|`Q&0TCC}Mp%r?sr2kk0&Dbsi6M;MOa3a=njY-sfRstaw-vlMk~Fm>ZA2 zpoiS3^$+t_)y7fQT1aU8E#I*wY`<4sp{45F1g1~XnGr0b&vArjfz%o~4>cXRKaRm_#ZB)(TlxZzm%DH2zW4o5MQQf|0-xZj7?0U_> z9-(3)QKwXMsry6}Y93e3s&p&;%&4CpO>wW#ONC2oPxQWCpN*~WxXs(&sWkrW!V6H3 zmpVD3A0D_zf3zZEwCOY9R?a2-zyH9|u_k~13lXdx`NZILs0+e}u{ZhRzlko^ z;a+#vo58*?J>lC=Oba=^^n>M2#fCVKROoO4{~?#vs`=cVLjrH;wmd={=YB<{kk{&G_oD<-|T-i2d6P z^QzIxE{(6;maG(~QpCeDUd~$|r{zX2`)R!h?P1*UsTj|mSe0wHhe~L9QbtW9Rj@f7 zFSgZFgr@Co+$|}t3J8ffh@9FZLm7 z+NW^$jB@e?>TNAOPW2^&z{67|s{8WaKQ*a985XPh^jzhq=jk^FyY2gNMZUQnvG+dS zhRLb5nwBs1Z8zV^f#b-)YdD-~_;HvWHye0kX8oH#g>`;!dJKEmY9M3z>SV|~{uCP8 zKr28l6R(%U6m@& zYa>0vqeSb5Ij!`Ji=6|;W@njy(|f1U5Do1XLxkjCD^mswE2zfbB^Eh`H-LK^|KjmHYZD(>#g;JE!MG-mn^xZEGF-- zVDR+s;vu88^gCURT-w9yW>sFD`+VW3I&C{QqZjW>Cy1Bq8}#RjT$c23c!-g8tp%3tv&+hd+ra9VQq?e6hhxfVN zULr@EzQgJ44A<*hzvNP^De*{CPS=o6ZRX0Qk6VV(^Ell5sLwt5ZYMX4seKR;>lM@3 zL)4am&Y*Fep46%LFRk}-#`n$1SnRvsv43SAwISq~ny$bZx3`icE}-FAWb`!oAq-h7^u^B58>VBjBE0;#kBm>Rn~WKSH8z>h*CuzYNW0hbvYn#_Tj4*X z$S0}-b7L>*|J=|=U5nn^e}CP0uZElaZQZ)Sdfj+lju9SjN}@JRykY0_;gEl|G3AhP zO?faogk-VG{>S}tgV(bq?JMd{Y})sapq~xChn1qD;v8&w9tGTIeNW!U{d02MayPnP z34eFxcdYuJwLi0h?YigIGe@oSfsyLfLsU2YaL9f(J6U0WpP{?~aCr@7NpDO2R`lG_ z@}B#tjgWCF*7d9M1wYCOW57<-2Jb$88Y#a^C*( z%DzWp?Zv8NF6StkgPujJyEa1ivzQm@rJrwMQRVz$JND82nYG{dS1CTr79PLf-+}7W z7Ga$nVs-@4&s~Z35oUjW^E+9G&4Z42s`@9Mrm)%xo6{O7o!`yc*q6;E)28WeReu%k zGMdLL@pbO^E2b?(c&Z9mu&VOWDoU|>d0)r&=QXaQ_g9}jqcH|=8-PkGF3`cLRXj!g z?78}R9Xu;Wxh%4%-*JpI=km8t_VwB`8h^gmd^}#>%Q@@0&GU&TJW~q4+1l6P{qGAE zie~dvcrOK-^R51@o@Lof-zSf28t3*U>f@1l<3W{6)qI{-TV1w9+%ZR5X-)HU-lAFd z2R<2efK206(*d6Fz&;-tvT8;1ylNqjnVmm2Z5oeEMQ#3=}7gEWmBwc z@9w`l=2r`PM6co2xW^)+CA08e@CNyu9eO-w$&#k4e&>_2^YO})m0{5@EMpq;SZ$A? z+NelwQ}Xjy)|C+Pc3idRCbr+U;;qofhVjYP#}=UHY4o%BgM-$?@9Wl2zmDq}y;mAe z4OTh6d)sJHI#`Tv?qyJ0eIv!K&+j@p zbD6Y}h~+!N67jh)OmJ@Cpp*&7(^`l3N|z1Ol1c6;Gb=-1He_3_**q#UE@ShE`B)b8*BV-m_IUofYEN{6^d!E!d+9HE{t9k~D&h6d3G?1(Rj(xdoaV|eCHdsFUG4hV{2lpq zQ4yR=l4?kWvORTlsjeZsK*uTGNOV-f=9#(YBsZ9?^o{R6^|N7Wx7(NlnYX(@)jD1Q>g>|59J@q_qjlWovl1HfJDrQpJ^DXK!+@4Fyl~2H^$G|z- zcGhDMx`NnTiHUN)zQ%C=a#a|H=IRo2Z17-JVwUn{J$@T=4;M5prM|CMr4x^-b@??( z5_lRbscz-<=JiFJMK3PB5)*AG-}$I@%1kq4%S1X?aN*)a}wze{ax;?39B_$^^ERcsqxBOCf+&YiA3n# zlTx?HYfo4c?zu!(QD{C2u zeYDI|WA;_?Jbd?6_1Rbk1DvH*j$#c{@^#MlC1E>Olpz^wPB3PX7hi44t|fbJZ`NY< z`6qR+a<01X)RbG~KDBzPE~))WFLP_!uTYDvUt)m7A84i%0QQNR%v#^p@-O8S@@<5NjO|(`me`)-qNecviqx8JC_ArZCZ1LEk|P5| z3v5#|Cr+-ql$LJlStLBcHj&(mYA(6Y=)=S8hb;fvNi!Lq?WgiLBZv4U~P%z zNNUXk$c6sSmD+~=qWJlWtb3no+SW`dIVxP&jHQMSX(a|Q$OzAQwY_|$_)@n7xF;l~ zktRO9y_7WA{BiS24d+(mlj>@|B{D%29R8&QpY|EiNuS<1UWpj->bcGw$0L4{KKq;Im`ccdVySd zIqfAV_3TqAZ$M-|GRRWs(1#uF0%)KL81yPe)-4zG2}Rn6mElGeE{nRrzz<%t2n=RMvaVn9U6bH}|LZ3Jn& zn-e=UM~ucLLQTk)h!Blu3S;K4wf^Z%PdY_3HzKs-Rq&rl7}-wL06o;!+iZqBAWP}B zgda=LfM2tKS_>=A`hHri{hV4~@36V5F|4)mI3Kq|;D@rloD-MPsG;eP>o+&;VR_t? zhgw?Vww{mZyGPJcf%OOYwM0Gh8t(Xp%%o)_`m1Xn)68;id{iRs?pq-T#T8f8lFumu za#{F0r~hM?vp-MQ%RkoKF*iGpCyh0CPe*nN3BhI(I$7jZKO)(qBZIbvmWjK~3}j+@SxD|-$lZdl4d?tA5S``q&u zTUf=OSt>mOxGKL#;xOw1m!!Pt~jx)u)Kn}c0mp9LI!8b@!(md@j;7hz*jdyFr%v6-(JWt8+hE9rYQes#RB_4j)EU};U3t^3Gr zmRZlb*m`>CHp>bM+uHi@ZIxg@&$Jz~@l-*#Gj2ix?;WS%A9F{BWjY?ESCBvl?3D2P zyhef>7&glbN8!=LdIsbPvn0%`@P!$OT-I7%PM;0V&XU1W&N^i8{a^a5*xhxknN<#+ z(dc~(3?A>mmHZGlMD*qOyyfhj!9u7bAKrEtOEtrZJE7d|HR*6&%mXGQJ=>uy@(lH{<-syi!^bEep>L?M?d}i9EKz z-?m_LEYi2MmH71zfLm3>k}*| z*HkZBdf6W1gfgLHxE4v0BNy;oJ1WmAC%m;B$Ga9aggoetZ5@BDDHFP?-)tw`5()P@ zg5K9QUhh$j)?(ZGO!hjqg4Xo-fgXeSdeJ%;|%mO>l=nX4m@Th!xVYJ}=JF^wb zZ`;oJB`^x#Rg^_+ZIZjL2hg~gw7lzU44+)sRW-%KX|Ao zha=9CHT7(cBXU!232{OrhrNG6yiiK|((?1F<63&qyG?9bpU@RCi&-rX4KaqS-K2!m zm8a3-tn3kI)0_7_+wFFtKaQm`-Wr|@6OodbYc(W0Ut7#t6pgT@|_I#PT#^?#Nh zSh8CjI47(ND29Z$!Ph4LSG09U3D38~3UO<&LSQ z&h2~JW0dP}9ju2b$Z9z5IuY^2_;;{i*Eo zjYnbB-kK+Jt25o1LK)xo-CcUeU*@r~8Oq)G%iMQrY@iPAm-AdYz7w7qGXm|HGPfNw z-9%mBCgPvu!x92--;iDczNEGucZMtu88nM@MBcqbIs(S?MNcL?y^x}LSkU9BO294G zpdL$jDpz9qpSEe{SC>i>^ z(sODFd+63<7QOt3gaOtSwG!{7>W)*3$Da7vh99B+b5pDy-R)zK&JPIZoHI|v!M?Ij z1c-N`V`mzo-ZAk|8lidq`7Vl6sgKO^=N(blDDBLJWmB6kR&YVv&;O3> zDP%p(niXOiSVguruwZWNXv+h;UmO?Wtas+toSSuAZ|eR~;!S)xR(yF!d0v$6CF&X9 z4;A0vP&?y2r-?*~Z|=UerQYLMT8{QAceDAd@wVr4DY(piSh%C?2EHdupin>ayqq zI_O1Foo5?*aZTFR%LNU_8c;aVYm7F@d0s6A8tRC;v1hURd+^A~D~s9=?BqqtILe8f zF+BH7&?ZhWv#w{wSg&ki_V$zNsE|)Sqn$oY!Ldu9^$5)!+0o-(1x@@UYlC}K6DO+> zd8V&O2X;wvt0218-U<{OI*gd+In@ugr-Ysf8BTtu{>$)BDwk)$|a7oP1L=MJ-GMG1hCSkCx z=fuux3+pxKZfiW)$pbC9L{>krrsIP8k$23s^_<+TzlZslw|Zcu%o*&1w*d>yv8pZX zi=HOwjn-^^q_HxyZD)8x2OwkK5tZZ!QJlnO>E8Pu=gvb9XncjVXRHcT-g30 zWw;F@b~?EBzV_%tFsl*p%sl5@SPR|_<<1oOJz}*y%{^nDBbPnT+xGK-+JH?P z*ra91p7`A>4O$~U7(1(xv`A7;q_DJNg&T75?v;|-{3X_VHG6F!ZLBGvZvV+NbM-?S zg-hw_g4))bC#2o=j-hc}cA1yx4jN#&qiAe5k03ZNvt98#Zp$(+r@*c6OY#{?Jt@2i zG-nQvcYMtx@*HmL^LVvyy{c*C~*M`Q=I)N3}cto7C#mbf7ouxN>dbeiQ-gsRjZS$_Cvi+l$Mr3?v z8*#tt#)5P%V6s2aVmG%k_UmzeglEfIY*EtT%8CMCvHJJGLK=jJ+}AkFdY7_;vWXI~ z1{I&bTwj3>$zPE1xqr~m@@u9VVyZ}$JTHVz0#)WctLM~@W&D`_`c{aL!u4oSGg!9P ziWS#EC)i_*CNl<^;#wWRtTA3Gw&#+LPpI^K4t}2wJqJQNsF{B7Z#nCj_ch59ViP>e#Pww>T3E>|O zCHFGdSX;V(b7-_$JwEgNA4-(i!{*+~A-+=AyX@I`E@vGU+ompm)-NQL_nm&HJ){I-30LA5(N&j}fLm8=jvrFWtE*maJlS?9!JAYa?AZNatkM7{P$Ig=R%QI>TGoXyXWsSvGG$vOy7T3~Z_#FxIS_K%ZE}ROs%$ zU$%y4=nOd;ywBK;cmdCoHk+f6(%wPJI{USHdU!v(=aD+LLX+*Pg?Vq7v#zDf+{az! z9>=Rg2QTB*;~j1R(_aNK=GXAtmKuwQYRrY14o!2RU+r0r;q$7jQ^FNC0`kS@zA?wL z++jMl@HT^QZxQXEFE{3?wibF2yCH4G%{-vF#N$?`O;4w@AKH`No0oA)wP7)}y6${o zlOp}bINuDOTVS%4Th|uxv9b5F4qNUZjrd*J2fX5zF7s;dKAlCIy~3lP=PqFni z@5)Nb_Ihi@fyHBmZ1dWvx{Y^F+SsEqqD5fUE$rtg+t+K8ZSVd$7GW&#CZ!m+8oo}uPCH@Cr#F>bp#Xt!VHCh%Tij4q1! zUz9xa!_as=7*-|QQe?)*=OCQk(T~0l>KlosIK8Ll6XJvQnevW|qf1}Y$h4BBXRjXH zsT*ou&R);tmfJjn8=spKRxxpVtY%_=Xc10=zb5Mnjfd?%wvgs#CWPf3B+D8O1GgA4^d6$taxWk1hU`N^?}QPivkvDbG|XArH!)WL6BX>$>)qT$EiO z^Yi`kdihTX!@ehC?A4AfiqO(a%sC3yN>F0PVadOhYF^XbzBhF*<@BT)_pW)j0~~fs zRye29K_`8#;TAMjJqF*7{i8bHn5tbb65TVO;b*o{3;fs{8cTF+_+|akEc3C`g{V3a z4kSFX5pNnkIk5XJuiMG*Vt$C0MH$RGvGaf%n>ZH&Ifk7b-YXVfP-72m6t`R_Z+W4Qlu73EG5n6E5jr zqCZi}*4D>v3vN5jMhA}Qg-zg~D(+@2>8c#PF})xQ;(kL$nkY_;|MJ_2>d<9KKJMH#pX5@O z-;VCq057r=q&#`p>0$L+*twyDnpwp5Ax`Wt=4=*CvbGVgfY;}j4$y|=>5 zwo9*nz1#E#|{$+fq2?i0;qS!XM)Z!MMijw|{a_twM+m9l}pEOX3l z>t235<+u?GT=gQchxMLYEwG*5R%F?0z|m?mUvUJ(&H^w+ZJdU`S!pAfdsU9-xkk~~ z-n`An5+C<$(YU78FFl2 z=RP67(9sz$AuYz--p|h--M|#9s{3aV&pfWWAG4f{ZLW>j6O?Bg!1vsoP8jW3zim#= zuDQ8$QcuL_kTy$tHP7|6#4>lePN3u%F#fE(R_st#WpLs&r%}bK%zpWOh?Cut+6ZGl z!4-X9x5Y7caN-r^F@iw_HLPW6>>jb**W>v|cj(#Q7%glhw4YZ*6N|kj30L2dJeCJh z9vXeGu%Fp!i}$q<`MI@my^rm{V)ZeDN9?O^^BKkCU9xR8`igb;dYaXO7qJJ}Jq|su ziHt*~P z(>Y(39#|c9t~%~@K~Q-|sBOhMKauzs^_NjKMYJUnv-WNZVydS)H3scL@lYq_9MyA% zqi6XS7HRpLlNvlz1Vz?g>ekqnYkL4+K$%M`i*+2!)`c%eYaJ;*JIGhpzO6ctF02C_ zm0UwG3pX13IG+M)Hr~pdGirKa$a7e_HFnzHL1By$p2IA+S4+)ulo(l-W{){z`Pibq zJUX-|&f58^sJ*4j)5#WO7iR3b4z6iw{FKHg%cPp}N=iFA$w$v;rIa+v{DfzdXq%%} z%>JQ+Y?0Bou?_#(UA=KbEBJf^RoEmwofo>|RY`j|aubO+lbB<>@8R7U)woT))=9IP zLsrjZ?O4+1d%KtLp}WS`aS0td^IVc)jKoJZTFl~ko+N9|EWNfDbein}OAMew=I^yM zINS4_M8I?XoMxEkCfbYS6gyGx8R(|Bsu4wh6PYzt`m`8Zge6^KotfVywY#*wzvkKECCuH0PU`bvDQ%$0tiy<4-4u1%DtuXM3Gs$_ z3x)Npg50ZCJ{~X1&D57^5)XJeZZi*fnHx!Ge=XBZzpnc_IXA)1JsaqZ*4lY+1DMwS z%J$`0yM?{b*U7dsdX#s$>us^$GJ9dQejiiu80M&?6>>6GA#gfr*{ktauM)eG-ixe)wT zwue~e4fUS68e&pdOkfOKm>5C7%o>U{MPy4wSy1*+B#o-65Ug(hp}Kr{oU14nX_We!?M)+rh?GO zj5%|HmbIR>ulMKOj+CxXm)xWT#xT#sZdXy-3!)xwwk+pr%N%%(r9F;iyyQD#-B*~yx9d*uFl@ImzEi0)1n=1Pm(FP}PjPun#&4C1koM2qB zFTiKm6R{$q^_zP+fFUl*88<{6mu1*`H@C8yspM zAnc)tr1FK8vSG#aY%$hVLs4jYtR$#8%a{99^7wnU+NhDy1J)Ekl%td_L~mGI!nvKC zfPGSRwmCea$Q$tR`XCn`I6VsqPgJ{C7WH9yVYjiu08K#z5X+YuScT;tFW)?)98eQc z#5L$L(ukfnjkI*fYI{f1Ipy~01zj%Vv~~X8*nx4cHO;mMJQ8b~p#K<4TMo8DyleQT zum-n#Jq9JUZQd_iANfaQ%2I*7x4^+M^wju6gKr{fTZ{Um!tH2nF(soJOi|~ByOxvM z($-_S@JeW@m~ZWQ2@h|5GPMlJ?3o|0l^oCD=a?*~CfJkljz9czdfBfhtmcRs$4oZ& zTv7_N#XurmYZ-fFNAAL7mSQ1mk-y8gHFQ5mDPP&!*p}SN$&)*_ct6?^YeT%oq}Tt) zcd+a=UKe-jn`10SCNOqNl#%61)`*@{h-fCVwWpaG;jD>+i=d5u?zbdISQ*V6a`yFD zZ}@@4-%%ejn-Y+BaK_tOVX@q)98`@QM^fFhVHr=W#23>1q<3M2Wq}XCs9{ybt`qCZ zx-A!X=Qfuy+i}j;+gR4r%8%2+)a#<(!0T8#a;Cav6Eqh74PMXkPUxcvpGZggiwq}j z@It~fmKxZOujmP=m^tX$R>n$=v0)ZBV8~a>wlPH!r^u8?>#c>+(~R}Yg?(01V_*ZC zT(2qT_Iy_Mcc3x)mL)tT!e@DI`CRe6rda60an-(OvX^p>R`xTx8=JxUpHep@JPrFWGBdM|BtI4J6h$Y{HMf;`lizt{fA)ijRKi6g6}?^b&TPinkh z(cf?H=549!NsamCtshn!pVjDG)GvNtQM>CpFQid2)!~(vb#hBktPkgm5@brW?V_}x z?G`kn+uOFGhB%ifn-jm$(q+llR6;~eN;D;3lTeOq@zMFh)#@lihEBH*+C&q`JkXS%L8#%AN>GnOE5u66y zEWgtq-`WEHdf#8z@ma>-@u^HrOL*c5wpA^odO7eFE~p*8)yOzp=ChslL>le86J|zv zJW@Fx>^)Sy-rH2uG|X`I_WINPuOz&Vij6RI$v%IC@nF zG>7cOlPtO7s@@^hJ*QIBYUU-k8_Ev6c|XT?HCtTfswukUw^}Yo|Drtl09DuXLhN_T zG6Efe79j4I+Zgm5CABiA?Kzl3D>7@`$`tRnjIU2A*PGI*$m2RGm@eMf8RcjJ{K<*MqjeEt4{`WUNH zQn#FLUjj>-WG{=kCb%40#tQgi`j@@uM6PSv+I!h>k-g=z+)sSR<$7m98J!^_@q)%- zq_gZt_GTt#P(B%<2emn7kXF9)d+Cwp({7MK&IQh1sz&m%M#%An@tVw-(R#Dc?a*aD zgL8b!L%@31b-4qmv=k_9YwIK8++{zQ=ZjKkf9wL7m*rU*_y?VcmCe7D6<%ughr_cS z!{k+|t#A8&VKZAi^dqF2y+GF3VZmpqAJ&oke9tO;TRyhuwM2`KIdUUe(5BC+EOk2MONC|20XJ01y3^)tZr%B*Y>|117_-?z4N|s>Llywk%{>5^O~0NuA_<8 zZ6V;1TOQFKBGR1eP84%KdOiHWb8C=bW<3}23Z%+%B#A(50zb#@{!~VmLfkeNrG7o( zG=7y-*^VGmJg|0J@LyGnBW`_ZhZ2_9N9II?iFs{cv%z_^txQ*V95mK=Um?>D`M<Ctv1pNV%4GxAlgTV`@p^2wiDol=`i;$e9sj4zrb3HNE<*G-77G z+_8hbw&U={u%7zSKYH8dk7#9B=bQp@Wsxszqca;z45Ulgq>LClYC`(2Q{0(d*srZp z=YgFOiBh51@$5vb>RMWGBdasd8)XfOZY+Hj*0+t}W9RFf+TNRFG}hGY{4vM0-mBUj zof_wj9OQ+vX5~hXeW~2Hvh*bv(E{cd#-lfe!sp1dIK+DHpOh1nTJvn2s`jBhLvm_Av+MTx zX+LY}M^x30LY|%b;D+PIOkk^9b4=ylNhzgX%n>ZOhIvxB@uvJ=R(E*@Z7dhsoF5Qe zjwWB+`f`c}aDxEnk1~VBJpysc$W_%9XQ9O0BXmK(@;x4tQkwq>sCAieL*?$ zY%I~Yk?xNOD>svSg7P1}#uQm5>6O6PgbWUsZ@~lsfHe@5zqRu6 z_^st!j>CPcZ5WN;T3!9|TZ8J4-#x3XT&|Q_?^%D$4_C8e+i7K`R}0)H3V{<#N#pSi z`DD$}`d#BSTX7b}jU7&JS1N>*XlKyk{Ze||Uq}zP4I3NVt?w%%Pq3$$dmCA%y_E{) zjGiq#UbV13BgE>aTWNI@`x`FkS1Iqt5&DR#6Ychz(0W{$>(6!@T5f#iPn2aHzE;jy zj^(I5bcR*+igXAP3H|m~qNEs`b4liSjoz4A9^RGMAwiDr#`}FLKXQ+l8(5rqqvg)+ ztm$HR0UTe(6wnpff5obSqQ1I=Q(I}+Ya?y+So-32A)WK8kC|kSap>RvI+n}NIeLsfDzBav~|KE}nVDH3ycJOGF0=6*R^I8}djBnLZZhKZ z?Pk(XKHF$)Lqzm|(}c?VoBMJE96RQQ$A3D}CGRfF!jH3fnQv%!`rbRp>Asbc_8E<2 z+!X%3w*iGU#d+=U2$-~ISg&aRaAmt^!$Y6(-n=$(~_&_l1KfNo-XSQnyYHlooZRV>Ixp}*=TjXIJ>^LBFnn0 zSH^f1*Fj;}E5FLMU9%a2Uj93GOR@I0AKUlV13vuvc83o3ir0i=hn4mRBh1V&qxwem z<+SGgW7j9JM0Jq7L@>@P=T-f^s4*a}{H#Xf8U4yPso0wCw|1HPzHVKS@2YC$TtDi( zE*kiX{=JlHKC>f{XdCO+u_Isalm+G6!sxfil)XtQCwBWfZk6}8_iI}3Q@u+y@@LE* z(MVakGiIefi3W*pjQDc=;6!MJ^@eDMI1S)(vJ7e&;8^t=yH*GGYfqb;DBfq;Qn%}f zXzPU}1+OjIe6ZWj8MpNM#U1muU6)@O{gbL<~w;mNm0(WB<|hq-*ld z(%DY`Y2k#?r>zptVTT{9wu$%ApI%P5+wb{K#OOhB+uov> zrM%x?L7!83N5!*!S%iH2{-0D7l$NBqsKcc<|M_kf~mA7vYpUYI`70~B* zbmG&ZHTJMv7u8)9%`qduI%@CN>{Hv`OS^l~0&ZS=O0_}juAdg2Pw(P3`ps&emvnZ6 zn(LlBj&-|r*JZW+Uc>r_Cp=zbeXS(otL2z;x3O2ib7u)_&f77+uKjmgTOZ%J1)G+5 zJ1zOtcfBQ)i05g~$a)4l8-FHFeD%I;WOn%-4+|beM`2Aczw)Z!u6Ig9m!DnD)9OfU zCN!b71$Iwv)BaRT`R2gRo3dR;7bTQm?@XheSIf?9b?BnZIbKbSj>5*iqWsu)*ihbI zPQ;e3%RnWU@hzoa(wb8#*s5%O})SFe3#t!LG9&O6W6${Gac>0p0-^)~8Z-SfPrOo#WR zmaRjSz1b9oaWoFcGb!hi6_e*->%EA1#^s07{g0H`Le%?<9EHbYaMV9afG$}Ta9UIy zbHK!An76kWK6U=4Fpl*qnIq=;iU$d^1zz*~5Vc$W7xdZ!Qe zQI<`}np_U8WECPku)ldh|HmD<%$p*ej_yKu#>FR?`J4)BjPmFy{Vm&VPi1+c1|@mF z2PbWi>yY+qfTLE@mAHyI3}gJ9;?S&JBWmPRYp9*F%Gr2kLrg7k#x)jetXKtyj1Rj@ znKR?YB<5N!2_y9vTUXeN(Tdms5^?o926K<7iSdHx%MtLpC|cxQOr8mM+mK6rn80n& z+Fiodw%QWsDdWr1u9tR7C6?-%+1q}6B{yp+>hkcHs4F7<^_ZSd*eXvEXh-ctLE*M* zZ|%gm@xQ?_Gj`YXKVug0@A%fAkw8xLqQiTgA+_FQR^$FXwje`tpB{9=%9@}scq?1f zSCR$5IB-5JoCZbt?bGTB`i@9b3lXu!zBRebU3;bjwUQ(HIL&t30n59sF; zy;>gJy?fGYehd8t-*`smDdF}R#WlgovJ|gJ8r=s_M~u!3SKu#7Y4_B|d)mN=m{;1} zq&XLy0VTa6Tcpfi@4=y9DEDlJIHEt}kv*Dp2fIg+745jQuPJ=m9CvCZ#i2A} ztgoS$H}nh6qK9xBvf`pjf$q&gSc;+FGL42xh7Q^{b>a%Jynu8vGGWF8G^Ey3fdL4SxIzBb1<6gC)#$~^a zvC~h+(LKDj>nWXFl+vRab{d6GV0_hW!H(uEv9C#bdNm_{`*J?!U~)MBX5y#AzqvBz>rLp@n=RPiV@5A{MRSaxA$LCtY1 zuKi7~KX2s#G}KZ(@(phWt;N|YVT&Ep`_c}B>+#`Ym(|hgJGcQ;@%2dcm9~x`(Jq`c zACQMD$aj*ofuCnG{gLE7So?lXWih)#ozLlCbNfRnN8ip3OLx8p`E=T$gHP(!%(27z zW%*5bCvPaKbXg-rJ7>BR&C31F5nJ#~Y20{tYSPZn?DUdI{BhA(*7BC`Pe_AsQVR3| zRni}(i2i^26fbv^D+wPQXmzbN`F8q{MhSVny zUsVh2|6s4gNj4Y68&}oRC!`Y{!9S-_W!~nx-f~9F*4Fokiz9|Q^1i{fOAp`3`p`Q{ zknPB}u+upkAeV{!gwOh3ZJFkwk#;px%vEu{`V*`{zkYxRMRp)GZcJ64^rLVMGiUl45~ov=IZ z-x$i4OvF2}*EX#$)A6+=750MN=poW%FW5y-Tu~oGA0PofuyKoRPjGTdTgK7E$;fzo z;#PyP4kx%Jr0-JBd*>dj9N}E*g14`V4zUE{{PVBr>-n8;XpUnk=LibhWz&*4ohG6Y zz53~!W8iHYIAfq~?Kn3+Uz^+fX5HcW(7+RMf+g;VB;;9)B`yyYUo8dgxnSut>+**F z#e!TymgRb-7;*?ZAHJZcWvn)9(>5<-b83>C9%EnPv(EB`9HYEL;^;b7;N2tK*A;SO z*^ZVPIl*F_8;UBwxA>y9mf1w%z@O(;mN!+MN;rN=b)ol|3%ZniIo1{1UStF)kMHaG z4ySsF$F)6TEmB(o6k-YEm{|*h4UuUKdd%bOu`9pl(ZWUmd+eFU;$=1{my`1$m9FgK z`N~fFSkV@7hQ19&Y>TM>F_r2S1mO5(Jv;8nOcCwlrq%r2ZSV{cH?+22uwo5&ROMq; zv^fmBzxfIlU!3NzzvA2V%g-%1J}5EgII$>W+5Z!ZQkHp+COMPGHOG#@pl>iMzt&U$ zw?kL(KBpN$M_ymZdRyj!%k!Bj4}YyZIlHB~vz_vwd-%XI?&8ifbcAj?S@2@^%-VA6 zh$#G#IhdZ7DhD%i=dVk*4rlUbVwGmDFJkfF|=OS|T8Yj#N-}iKAPN zo>ZO03-NK-_3{n19eu)R(2~;)_gqr@+3$vbP(see>Ql*|3rW`-D@UbzV-<18C9X%& zn1G0J8`EjzhiP1WNar~zd;06j1^c|Pwsy~$KEzDX|1aqQ~+ z&KUBGo}wpa;}y_j-Wu<74A_u@nX|?)kM7WiN9>$9*t40lNK(M``D?tVat4=cw%qlK z$sSck#1D;*CGfgzVql)q_+(uYyaE@Ma=YiBVhy439~3;1!(P8eR@P;~_;iUgsVy%T zai9?l(xR4D*@9t4yw-xz6RZ&CCF`%qTCAT~HPFYx(#k%QT7YzWt-;(f?|sS}_A0uI zl}&C1RQ>XhM;_=}rag`bZ^!Ec(Qtc#1(&5i$$knjf;~e*f^RDi`&iNQl)tn+T1kJr z>9y~{xSFs{DWR3xdOWg3Mp#4EYYD5+?Y;Bw<#mXT8`!R?;Z!X6zhl~(lz$Gc&3i1?7PWJVLeJ|ciEn@e^J`+ z*g@!~R>!*rFp6EboqPqX5@zq$a)YO=|2O5P2c(g)&9FZE8l#j!*t2=&K5k#LXYZ4; z?-b_{vHXT|GTU%y=QnX^teLnqf|bogE9!P;D;pZMOdIF8YmkGQuBiS}#$r9udTy?v zzspEV#1{D0&oQ<)Vn*Xld8yEOM9IgxAS}_gopoop*ogZ7#7L&&bBdRJdu?g!^^C_Qu(|2D+&9p1#6HUmcWq9j*qg$hBW!(r#@q(BP(<8gXIT$Bw^N$;F%rwkUd$MmOR0TW zEi0vTE@iw5V+3(f{Nfeg?-s4GZ`;M0u}*Q0tE!n* z2v|?}ALAauuhwqkJVI?nnMdD@!CG8FnDwgtA>kvo<&*gLT@Ys?4ain-|6cRbEr zQU#U?BlTXj#J6RQM<8;{`<1OL<~v5CNv*M)g0&GPEsn8K=3*rlG#k`?u=>57zG2Uo zxp?bd&bWs*w|g*VQJRNSFGF6mRA5=!i?0M+&<|E7b#Icltz|t9+@leX&#XR61&{bV z-==tFMCx8TS1(Hcp)_0cM+Hh6TMlCnfw?@7r^ zA6TV3pF2Wi;FeaQzP>b`$hnx#t3Sv7%qGysQXSmDOLXIWsweMK zixKO!pVG&0W6koUqDoI|j4$b5R@Yt7D2#1Mc1nL<>AZYP=N*sFbIQT~d!OrpEmL~} z%=0o=f2~YoC+0orbh&BZ6UF&O6lQvW#A`P#$Y8t z@yqvM80*xQ_^ck!o0d6SjBvVMTUM;5Aim036JHT+aW2I*{ri-jS>x|Jaciojy**ia zK(xpVC%o>H1hA;*C5IgAdm?MFhb1SFUqn;uHhxU~Kn~ZIO3aTk7aJ=x0%;4S?>P+@ zyjb(RU(^ZQJNgY(m%B~!y~R<>$4Y2+hsgLQB!NfoJ?9DDOJnJT4s%Hz>sk>XioesZ$bAOn2{8&CEhEtwr+?I*~x+I zy#11vvXe7FH*Xi(8QBI^?*;CarVb(zWn+shOZ~X4Nyjm3Suv6WQ0v?p``{i+?9u~v1FWjV7ApM`zS}a$`wcjinYV`o z7hGMgBsf~Vujj-g4n1o#bYEH*XVUJru|J$C2fzANwF!C-ibiAbi`iLoQ0Z&4<1YIs zWl0AFv-I2?>*uyT_x)MXr7gQQZ#&Ogmd(m*<_yLj@5h_-b%OqHpW^S|V~JU3ePoZ2 zHI>&|_+#HuSxb&-v79Ngo%aHBZ;GxQvqI-uYHbv18pFp@CzyIkFF#iUhM9j2N76&ht5x z_NmXL(eK+B=!r5fr@6eMzb~toSM-0DuXyJNim%V=D;gtPiF>^@DRfn)%2PX%*YWqU z)O#THs29;KZJ&PpkCO`K{-EbOdZn*H9#G`g{BB+YKjV4Ens0mcp^@ry7|=s8n_tf; z-=n&(iXIp>BD)b|AuhwYIp_61t8`e8;+-yG7xXCO(^?sfKga)%s27$({hW_%J)Uxs zcb@Yx<)F;RQkm?=X6FHVION6*{xdsm^8d4F&S$j4g*H8`dLB)u)jF2nYyZP)&%^0n zBtJc-KFo7}TBTC7@a#rVK3@`$1VC4@Q9!uNj-R2^?fqY!#c!c%4Zq_`^4MU>UeCID!~%mGKYYp zqK-#Z1LrQULojYozHzY*LF)tJ(L|$bb--T%!Kkd)@%U~X^kco}kERi!4(Qb~Xx1un z`Cc`6=W)>%yf%X%*JqWBIy~l|S%DyzX%Pro_32dz#=+782>K31zO_n`(670Kx;~xS zI`0pB5?Fpru%A-BGYCcjDaqL9=Q#xY_qd>d_*B9gQfG{1azP(pz|T*DWq4P&~ z#sf)ddtwejE{}&H)>;M6dpwZ$9-CP|$Yox-u0F@}9D@GRdm#LGJ|1W+Ah1~cyrvr> zmmz2ud^v9wEwN7L$z%305WFkJxwZ_QF6867+y59h*Wb*qep`FOxljC1b! z99N99M*&Lo^IYzd%RFTWKhIhP1eP+|AfD$sidp?t=XD?h!6^_tqf6Ex$ZzQbjnK0-2&9Rn4?2pz&me4%8^X_< zK!B<6rFovy73DrEe9`lGUgIciUnCn4Jg><_a)BL2FrFE~{mCQG5r#P~9ufQ}cXVJV5_h0i(fIeZ8Q&?;L8Yhy~T zka;{qpYuBKlN~#7FKFc&1k`N0f%D!}bj3tL;$j`GnkO|N@Tx&^!c3Fpj`hakJVcv7s zLFoa3{8_65J`D&Y`&!SD?C4O}LHpL~px?H#Eghlwd8?4kw&bCxbv;Ke`s!9e!~CAt zL7s?Df&=8@It0`~&w)nDtwA86perC~A6$Ef?zfvqDxEv(q6FxTwLU=h=X`TyeQd?k zU#wZA0v0@;+gh)IKzC+{xqU{tP^-rRDGlY%@kB0LjX>k)0^u2zUL^OrV!hu=_+Tc# zpM%*uPQ+TP8NK5%<^Oe#K_k#gky`r!`Ew{U;v zj3S^(^3ys$&-FIev$Zu4eqQSjng}@zgf+%G1Uk_eu(n*2OXNasxDKS$T0ejY+2`jq zxnv#ZR@qls;~sRJJt*Wo&uhHkT<(XX1?v#Dg_t`bas?I7$DHVxy-ixh^L#ug7pjF% zY(uZ{G!STR#@x?qew}kcg8{*q%=%#n+s@G{AWo}C-LktnYD^s_VQc@cE@_Fpm0+n7VVn!#8-g&Jmx&F*MT1MY6GC*skQOI4hkwk z=aS|H9PNV2)*+B>;0o!pCZWj%c8x1!5cIxQ2b!aVSd+JwZCH+uF+=(DI^a1* z-Vn^%t>KE?_DJZ>Cb9%sYg-Tq;OFuRy-&+&ReqlJgIrKJk|CbwJ&#;q*U#|$yp9}4 zLmJw*T7z&rlRC(c#k2-NJJ6Uw@I2>1=K`Yvu@-p%0=hD;{Je%MtZY*WQj5`_^M`Zc z1JEiUpv-yC$wk|Mz~flsD9XhbLAJ;9oOYcH8zdkYleJcXTaO2t8X8-Jz`ix@BInm; z>u41e=$`YuHhXG_7;_{dT)5UMtU`~uEsiw^azTOM$~|A>TD)iI$q+oR(Jm0^seo9s z_Gk&T7Z5zpWuhS%1J?l$&aI4q$aSCz=h#JB*;)dcc+*_AlM8A`f5h_|1bl7FnEu0$ zYa@upvD`)TpxxKT!zFvn!5LgQ?>SWE*&#~jc@0-+1A1~@`8{_!mp;)B#)D@^IcBXg zM6LsD&AAo`v|6;v_R?A%V3ZMzR?TH1xyTO>+FQe7n%9ARg0~G}&A>j2yfTt=owy@u zUJm>VZ&41?1?{y4LET77M+Md~NV#w`5MXj`^$X={0dJKi+=e0Uoi23M&P5eC95zq5F;9IDQR>kui0*Z(c zjOTR-Gy`=2!SfnKcnd)Id2bMF++^Kp`zb%q>Of*)#~~H+^BltC2VJ2j82z~p%DDo9 zS%bAY!ea;8&vOVU#C9OE&ChcP+gnfxBaiJhm-gghlmo)gvpS$bu!~&J&ub7+6LbZH zX>krgZeqhg#Pb{iuCVSv^ZI#j5YWmT!d^F08lJ@ipYu7nu*IRo{Jd5NT!dr*g6Fk5 z&`oe35b->(BXR`<@M{prf2f2y{Jd9)Ie*wvG@s|^wK{CmxK%vQWjk^cZGbM%&$Bvm zu7JR6nnS=Fj!zMx!D3!(mE%i{V8oi{V-DrPvy4Z6p0^4JW+wvzPiYMT+X_CX4nMC! zfLmi1-r#u-fi8z%sUx1(AZ+Iu!p}1Zq>ZEEM4RGy4FaBp2Z8YOULocqNQ+`FD?iWc zK$;V;pjGiahd_o#EH9qt5cWr02hVGkD;^%>3?;_%oUZH>+Ar|)dZd(5pe5A7^P0_0 zE<9bg%FlBiw4Ao}nxE&mLW(*Pgq-&C41)F`+2Qkep0~=SqHTeohV}Rqm~}sp(|(?} zic!E;pboSecIF%cNsCVmgr)AB+U=`iY2d8@$@8oZ`+wFr`FXDpXq=B}|2&@R?X zur`GA9oXCZw)Tm(xO>lP`D^w6i0V0_dckcz{q5PEw$L`le%ZGD!nx0hBE~^2&dF&m zoJ*BYs^QG+7|ndQ3FqGOmJ_o$hm2SW3#Tyw>m9wE&CRJGKBo>G#60tP zFYNtMe<1#b!R&YfRD)%(-$k{39AW=ZGfwi#s{NcFONJ)fd> zMBEL|Xpwg zdrdhwzxq(x@5xAWwo9C@#(TIRC@{|BfYaC?3T|%h$R^~NX`;N_`HRZo9q*=?C@J$9 zCoVxrHFvdb-j~kvK(;V)r_wKI|K(z5_wx30ZXbXek(!JKCnd!`aLytyZ^X&}xp$m} z9&q3{?ki`k?oQu)KSABfo9X5p_LrCUU*D7ZH_m@P?K_7PbNy}^Tw~djZ}h%9wV88_ zIQ!D~D&#wFdp)6#z5Lw5LNE8$vePTQ$$hYnaOvDAbV*}{HiK$=+AeqSOUR4MKc zH)m|C)C(&0&gv~A8@afJ5FUw~2NqwTCUE37olCS*j(PBD=*m($-aYJ1pB5~4mppK2 zw^i=dHCY6oQ@`$6DZfWM)+da(%Q~;KcF#!?UsZXh(&*W8KszEoN`2w;FOic_#y3S_ zXkE_6Dy1>!TVUt#_8pb*qGXcKmJE4Kj<#%09&kBtZhbqQENI!@&&!z>+e*)<1+#po zcgpnH6tkS1_1gAg*+y=OMj9d4d>RxSh(1N{<<=kpzp0$H6g`kAt$ufJY9VED->dgp#25up)Ey*HJ**EZgpsB^DS#}bA) zAqA~}L3j<>Y|G+EYD-`WO`kdN*shiWs>Nc~V%c&qt)A{;E$g+cjZW>yX?GW0Dy>#w&&1FvYD;A8mDG{d`Fvdt(5 zeETNq1A1!ZOx#7?ACtq0ZnE`|v3qCwf|cO$u_cTBZ%@xBfcbtipGCvq)ghe#S2> z>Ckd?{1qublCtLNjFG!j-+MN8-zwdgH~A*vxRLvZcL$D^INFJR7LG?CHU~tTnc=jzrn-YL;7a&Uf&i?BeUO8 zDV!?0eE(&Av9GZy#8(92C?7XZJEml-&~${ImN^M4fOd2CGn|V(5g4%Svpjz*Ne1Fm zCwFLU?&Y771VBOv5(sk(HZXbnPI-AO?Xd|AwXjj!9!0Z?4eVh)h|n)r$r6# zs&t=beP_bzxAmKT;sJr>woixkjdt31C#vc@DFTz0!@x(B747F(mvL>23p;9GqAvOh zZP<^%q9DS-Tgre7p|vQ(F_D0|Q@NoT=#V-OCn=osU(E;-clx6BcAwk++=R2uP`TPg|fkJ95eJqarqtMH&)1DUxM+@wE=` zvxJ4m(9dX-y6s?zJ4fG5bvo+lQve+YdqUr!X><~F$+w8dVkgq>)?$HDiAv@cTTf@+ zvmWN=)oryWM-HGz$5wMZ?MUJ@Q`{|4m-RXHOFPDqedzx^$*P*=!s?oR|51HEka|cOOKY^`MHq-WcV9s6vhD=k2JYMJ_3|HYn5}{ zk!B<3InSlC?vNL=R;F{@A*r>N(>ZMM=kYw6dcpbnaA`hW8fi$cF0PjA97ob<+4uU< zW`;GWAR-&#dtmQH#02W|Z)_U&0b6>9q=n{y3vKKfp!OYf$Xy3;hAkP}{g$`zZGDTY zrLkw4uu#Z>G@=~Jh90jf5wAwi!ZZG6|0RCMS@is-#pQ2!to-dBxsB*2tbo=>gsa@c zGG-K|g9YQzdO6$fw$8G?HpX)t(q-0kY&*7XK}dsICz*4z_Cl_>&T`KCo`j=1S7~2b zAJ+5aj+BgHVpRH3ACC&XHQiW}Avy6qJWm}Spy#+QEANwP=j#dg^cL$53512@D1%F> zN5D4e`2<7gg#DBtNRCor-yBj~v$w>^1wMFRx58Em@2us6 z_G~$o?~S?q=1YR0WcmzGK*d*za_&@*&~xD}old!2ZharfQz{9LXY}x}k0i)k(^b{t zNG2zz*n`^xPM2_XMVEH9V;Ckm8FUVxFI+wfpUGnyEX3l zBvY~tcOvDWwHdC>;~KK{mviE2P(ux$`4R67TJ$I}-u23Yh{y%4)N?{ue~z43&LUC2 zstx)&t{} z%dkh3Y2mQGLdiW(%@HNzI%Yo5-1HskACXZc5AWbwYy~t1>*BBv;RAHzwTg1+D_@rN z`sNL4;XAeD+t2*YF&f7mk&;kWO_#JM`11)-#*6xkl%ZDMk1=d5<<_H(m)7CY)Kf}$ zReg<_gILAn5iI8dO3N`MuO-v#lF!jn-`k!`jCGyMmf99WcOhlyjlGr&3Cq+RJh$Y_ znqITUSiV1|a%Q7*SpDyPXT*UlOZ0lx(2&`8^Q_jALJy|0%M!4PJaWE82)zkSmA$q0 zZ}C-1h6AZ(HT76xF142PS`MQ%q2(j06KpdAwu7J57iwe_`DVEnGv`EZJO{S)PL3%r z_>1^5?L>ZsXXI$Ett!Vbt@m%L?w91%Ld~T$XWJvw24%NafLA$`{U7zlwms#OJ8mfR zJWuU?d4}U1jW<58R|>+nJkuKbWenMiW=4`5hU2X{y2i70C$=jVW!qQR$S5EIn8^tL z9KYM+!duUB)xDkZ^~p3MYZkFRl+p@;4_FICYq5@>RvTVT+!^*{{~K^GDSx!Nh3kJ? z_LZ3#b7R?xYibR;@388q+n2wzEy!PhDeI3fHSVd|elPq$gcJHDrkCk3G{7yjrya>y zCuWT2c4w&9)#%IjkRuCBH4`FDCf7PZ>>H>Zr0@ujqp=v&4Na<&L!Ps*~^Mp*q&xNP1Ca%Kv4k>R59(7-++7)ZM!g{Bjj4kvJ#$$HI5*z>F zhQ^NZs5PHgKtw5*)Dqf)#PYa}%C%1sW036#=GALCkCe9M?OV?925(iZK;zicU_ zb{}5?1LcVGzSYZjh=!o?gTe-q-}78Sm4~ah%!*;DL;3g{eH6H6*f&T@L+Zf(?)f7$Q9m0H4Bqmj!QfTJprR`&hZ=-twKJ1jh5_byBH z7w7_BJgi@j3fwvh@ zVRL%T+IZ}!qes!FlJsFcAbR?Setk(#aByBp0j{id?YBW0qZJ~d^+!9a?7wBro%fLJ zPt^C0S`jfludYG*->71J@t$2sWem`9%d&*`i{hwp7Aa)}u|c3RC>;$SanCzbo3Phy z6XWjVjK#;E)Zr|FUUhW9< z4hJMzM0JT}5N8W1eM7h-a>fi4+=!;awsfR`FOJ%kIJ4D?^k$D3>lYb6X2*{Sc00|Y ze_PbG{O(o!UsCC@>!6qGaB4-beD1NtX2|_%v9`a-ffwGwl=O3Y@%0U1i1`%ybVdKZ zCJM1PkESW>F3UNY%3qdn=_hfC_>EtKB*A7Vzn9d5#G!On zTKT=t5qEoU2%dF}F5h#R@QQuMsIM38@LX@sfyWf``B{}pAK9fe!WeDodG2>_2$6ke z#v3blTdRdGsm?nzB5SK1oWpaD=QOtHiPGDPnQ(AsPKj94a;2S13H)L`;rBrkXDZC+ zFFhLY>|D9>&9N`ZVJTp#W7V2U?Uhk)SZVMf{qjBn&q$S}d&J>fQ;>Tc z8Z-7jpbhGhyecTemDB~a*T7l!7$><*WKX6=+DDJx-m#lPVg)80TY?(PI&#gHE%|rU znP)IqtrrmzbRzs!?(?*^G|yg5`0d%Qo*Sc{up#UZVvk{UK<#fQ`aue@7l2WSm3*;( z;&PH8jwpk1tQd1oUejb4WDW1a5|3G8#xi6aHI!vtNF!Z-b*sU#*9jvdunn*r(I;BCJlbVju%2!R8vcG(WfA3o3VCmMM~Eyz%E&Buxg=O1za^OE$`WJlF7>`2 zImJ$FvEVthw&n0g>ESNp#IEa@N~|SOtFLGK~mpH!d0*FC9J&sVdSvNmczQT)v_EThpQJ_V*dGjRU^pKh0> zi2sE?kQ*@{6;v3!3j{LYTB1Q@i(AmcL&@>Btztw1ukkx$56x*Sv*zuR?(a)EdioNa zjp3|KmUS+nqF0gE6omayOBRn)Pcm9Nd|oo@vba3#i})SfNozAM(Eq%NT+s0a!9OFt z9N&mxI@;L#V(W133x<|3{;1Dqvmg(>Mv1X>WQ%B;Wi(o`{W`nv`+6t$9h#}ZuGpW} za+YQ9ldOTa*eyV>S<_8iv^;-ee|n3y!)5~y_W5GI?%J-rxA)Y(x8-i{juN0^W>1j< zNcqqQ9&;kp&H*;OdKcJwK0MZVpcmU%lJ!TqUdH+cNsu`%x7xExqp#L%<;ooTsGOs!%=J^`cN*ob*pIayNQ;gjIc4h%9xSG9!BnLvWDhZ%3XRywH8=P5$mDs zx80Q_RF=)u9BYAzAre>2dr4xQLTG_HH*;&X)~UZEq0xe@W3m3ZZ%01%Pkq@I1%%cQ z&hUB&+m7ZWG&!0K>6PU=w>z!b(#~O@ZFKU?wlo;LNDZc8c!1IN?|_4f8993fOB%P= zf__6!dcLfr2JcTLMh`XRe)v5-rObB{2U=56o7?uJFpBiGjxz+2Ei9Z&=j>3&x?na5 zUS?chk&J8e*&`!Xy5ud#kdaK#J?B8cqqgp?X|S+tm!H|G?}qA%{AecU$8x|D!G=Y~ z(YE;NeZa@kJ7Cer@GiK?`p^4>sM~9XV;5!DWoS*HfQQy|Y%a9{`N|oZou?WJF`nq;l!!CitQ}@}e6U3#1SB2^`l- zj%f4O)qh~{yIptCqq!#}H=2&}<9E;yRBtOGmvlbiGOrk>9qubNnbsI1^NgeEb7-tR zFxAdyEcJC>d1yH}qZQg@3k7L$c12D>nec^a73_MJwAJw7XcqsCd4Oz@VS%(~cI;Cr z$U5_lqwmN^$Avvo@pYdtlk@IVJM%A(Vurjkea*j3xiJsuJw?dtQhzYQcto=qkCTZr z*Lr?7m17^3SSv9av=2N_bT`&FTv0x+{63l}7+D9@S7d>`s=shOJY{=#10~PF3{#Xye%+Yv-MVZfjEs`Fc z_`1qPep~afmXUZmEp$xrxY~n+r$(Qx*p7u~tn#i#_sn#ReQ-{7pkYp=KA~q{)sxo* zq8rG`iYFw?0sUXko(G1rZnIaDf1BcMGlIV?34Ko1yhh7`GUgGxtjl(meTtZa>7mT^ zMfEGrW;rO0OAhE3F8AvBYQ79T_tk1{3liJco!4r4*Q-xPN3z9Gh)Z3(+Z!z z>!l@@?8yIVwdkx$;4iibw$;1h5+uM)P9-b?{8P*6QGlUQR;>f)m3ZTY+GF zIRzOA&U)w9ybewT=9FF_Jd$e=+=NB~f{_H*^E$X|04@Q7TOii%D&TwOE>0=t*Q^eD z%3r9QXY$WmMGj6n2UoNX8hK=;4s!W)Y9Nf?d8^39xVa8!a!&1(%Ngu&Hn4FH^hy2h zQ~PyAkHY61^MonSXFo%E=Dc~^IoTd8A-9a%IrWhXN`i}!8@|_JRtLElE2xiWe$A;5 zoKugbDRjlT=kq$iy2qKZSU>5U+vK=u%B}LffAdlE%@v$$?~}D@)10?~;6@I{IiBY| zCl|Ld#7!C0F{f7`e0Q?zfDYGM1$KR-0XzqPthLHxXr1NfxdwoLz_5GH^O^>5AABRN zpOHDUF-Iy{Uiut)+O-J;dd3jk{5Hofb-2H|j=7AYL@1D+n{tt(vwmOMjb13u}<8LTVy+>lKK{2A-Sz{=-aJ^sP3|SXY)+uXsq5IKshT@lR-J16c*=qR; zHare!xw}a?0y{%h=?s7D`6%Jf7O-dXWC}9$EXEtNjc`t>K)Uacd6Gj2WZ7 zUKdt`En1+E?{Lz*U(lO%F?B(Y>r`Qj*-{rM-$JsE4c|zLRCHZoAI@87c^jBF$6!^? zp==|XN09i8-#X^OwCyF@21jm!L*y!TxL=mDYdm5d4FqeJIogrbGvZOpJ?sG#}ywMH9^6>`R$ z62I1=%o(Obc#=^=@620hit;F%lcD`JDDDTb<-~aT7rJ_0mu*waYM`)G*P!SF^x%H^ zm-XqaF6(&izA^Pe&9*t`P`1}hQD}W?UgH$OZuN`3B z9J5e$d9$&z+-02ITE-45XKU*ry&3D-P3paW53QspdFS{8le#Y}{=rnQulT< z*k@B5<&_5Z!AZT(r0C1LspdZP{S)ZiYCqL&-n8CmLk&G2U*9Dh)QAkn&R*je{ zYlgDzyoN(~D|8?5=nOQ=hbDBg2}hq(1f1D}`B+4a#*cr2pO1crwbz`w)&}Ut^3zYq z;Cai5N1#0n6~8uv0*?Of4azY@L!nvLXb-#4Hm~cVR&0Q^e))#=Xd%4e2+$0Nv<>ZT z+Vd~8-dbJo5j^Y``qvtr+hc$u0t#+f)2;St!rO(ysdvqS!XAe^Y^{L__-m~$co*yE z@zg?mek9Hs*N3NXisBdYW=#f?4{ES2_P2IaV8 z;E?D65^Ws{nzF{HF08~g`yV-OSqW|Um+v^9Q7`#`vmW6Wl5-s!+=du>gj(n)6m@*Z zqPQd*z;l?aWV)z%uUMZrZq4hP>#pKPis){AMJ8o$mdO$YHeOHym^TjN*Lqz*!QpP9%h(Lc zQEu9cUqV0EaEN^7uj|6Lf*;qR%&UfCu6E68q)kKwu@<8)EY!J7Hx$&0?DH?8EOV`s z^PxZd3+kQA^vLIUpMQbFO`zy~ZXud-GbqZB76LVw>GT|lV=pfMS{r3UF=Esezvi02 z`H)n`Ay6TmXOhkN&;?N!x_gbHfI`}s=Hu5Ie>op`i@LD9)@TDL+GNbfFED>FX%1G9 zA4-mAY_1su zb}Jeh2%gcx;V1FT5ZwCr)nAc_71ltWumtRQZwSJKk z`C(h!zmQvNb%AxXvg_g(l4lMDrD5^eyNh3Q%>w5W8^>OwuK2ZPi<{4&Cquz?YjT^? zsR?Q@lz+|THc|kdqjaGB3;fTqfwzgZX3YE7`dk+l4Kl-{>|e;9SzX9L>}+Tc2@${M z6a^>dSWNs{;}qK&P+_(o!04J?M7c;8C<<)y3+XZM7x|zg_bYxuQ70-b7prgTy>y4V zd05@*c=t1kwX$}RRk87o8Cq7$vJSV5X0xu69h>KpPsd(p$2`3*{B7mFBbCajAEo~F z*(uv8s_XO8&!p0$Ja(^BTl~)D-&C0oR%Kn3F88_S>_GBfJoPZ;*i7PR^we|iT{1Ywq$!V+>XNLfL>)ns&Rge0PrJQ-K zbWI(sNv5RoI}{&0z5H6PIX|(0^~n(Bit;myJmm`Ky051fdBL-H5!E@lfw*pU-ZfR` z{6gX}qU@VO zR0=1`Zf$*FlBdNxd$TxwnOVrUMI+D;yGX4^`t{UhuzLj>Wv_#G=5gKuJD7aVzvbaI zm5#K$xuZwelXj@ftMHh2M#s65>~TVl6ZJ$tpbIi@Z>POe%#Kn6J4V3wlc_%?ZKJVD z-I+%jjIvKK?&vtN)2@2-eRi{bVKh2rXDD>^k@T*IGuCfWOGq3fZD7kd)AO$>|hJLgiXYK-QLv}IZADPx5`}d4I_dL^wo40MwV*G zk0?JZN7}{smsGh|yV_jMo^JMPB6<5-9IGeq&AgfB1zO|mY^?61 zdcL7wi8s9RXV&CNVab^N18b{vH4uLiJE`JS+Ax^3| z(ftMoWccGnp8kn4Aty{P*F-b4xV3tg)@ab2IntEFoJGbrwvy=_DNwH}%(?PY=oe0R zU?ibis1f?3?LI%o_IyYqX#AQy{ZhAswQ|gYo6$e$oAMj&>z@m9u-eVNon#yyT*;p` z*RU^~{qsn@uo&kMKFh%JiaygCY%Zi4JKTGc{b|)egaiI$$Gm-ljK%B$d{J%19={|V z$Qf1L`>wpPF%{!eHfYZtJ|xd6y=@K8&hi%DKy)RznLAD$D&E~_`Bujm)_ z#n`(1O-w$w>3ahv>Y1|>lr=6uY9xfJ$o*RHG+Gu9gm8-Y0VWST1X_9 zmBbg+PTz~bsBhYjI5isoX)h&gZGG@I+8@}@o1%wtW`%`{FKDRy@n#!jo)ztdHPG5N2 z^UBI{>l#hz;9(P3^dDSXwwblTp(WRArxv1BoI=r-6LS2rus&NYzs&cnN(83tC-`%_ zBBp__*UuTYNv_#X>*Yn+b#_Tt%ObuDQbnqVxE2K7wTUZ||5tQw=- z-BCw6!lyvy!wH!Rdeky2`vV(N++NG*QQ52vWN_WbQVQo$i20V><0akC>RC!CdlAvz zEXji-<~6+`X$%FSZ~6a{5_2&26L_EHRW2!NE5~`(>W?hOxnII2t@(jHa7su|#|*I~ z!?&TeV9q)rkI%=yOQq*X-Y54^VlAsTZ}s;lb4&d-han>g;LQ z(TobWUWW&SoiWmuwXc*V>hS`;&x;R;V}06eoHshEMODcO+YOs!9TR??zxhk&;pbvU}+ z(^o*WG*i#iBcbXwlti%FcX$J1e;!YhC{5|j*YP>5cx0fXW^s3gXT*8$6YNgxVl}U| zY$@fGYPykhtY=dn}OPRrQ$&qtee{MMx+U74u2?{;2$kC1qrNsQ#^Ifdt=SPl9DzC<5 z8$syN8n#zHtMAG#e(`2%s_Dt^vQI%p4{QL}_B3Gc*^&I`L}5ftuspNx2Ij5F@u;9# zysoo5Fu@-YeM9<%PsRKnJP!xtwO9RGT6u6%_H}@}UAKQSS9(F|MWvUN zhyx*InAhXndTKy5FA60rs>03(gDt%k& zXDIzlrJtqrvz301($7`;c}hQD=@%&dLZx4%^ox~#iPA4s`ejPLT0x0U{m(%)73drE&_=^rTlL#2O2=^s`4$CUnYrGG-{ zpH%v%l>TX@e@5w_Rr=?Y{&}T;LFr#q`j?dcWu<>b>0ed)*OdNsrGG=|-&Fdyl>Tj{ ze@E%xRr>do{(YtYKTd_|3>M*Rr>Fg z{(GhWLFs=~`k$2kXQlr|>3>!F-<1A$rT;_e|5WTp}|3~TnRr>$T0?32++@bVd zrS~cAQ@T@WztRDvgGz^#4l5l|I;wO`>A2DfrISjhluj$1QMya%Zl$wI_bA<~y6#XV zyMI(T%=4c6lQvW}s^Z}(0Dt$=l!%81f`l!;!ls>NX zJxZTY`d+2)Q~G|TA5hv>`az{nDm|?9DWyl0KCSeq(r1)DtMr%>b^aKoAFK4^lzzO@ zPf+@aN2pd?DP2qEBNgaC+9ez&fhm@`;T~)fK z^t{p+mA<6(Wu>nu{jkzcR{AMQKUL|cDP33k=}Ipsy{Pn((#uM(D7~umn$lO5zNYkb zrEe&`uJne|4W&1g-ctIe(%VWmm2N5hh|-TLy`%IkrFWISt@JaLex}mTQu^6SKS$~3 zD*ZgApRe=_lzySoFH-u&O20(umn!`-rC+Y}E0lhv(yvnb)k?oc>DMa#I;CH)^c$3Z zqtb6u`prteMd`OH{WhiFuJk*Uey7s!Qu^IWzenl!D*ZmC->>usl>VU7A5!|mN`FM@ zk1G8!r9ZCpCzSrA(w|cL(@K9v>CYD*ZjBzpwNUl>XuW-^E=3yK!uRqCGJ)Gc!A8W@ct)NX*Q!6Eib2 zGecr0cFfGo%*+gL>E^$xS6@|2yEU5W>E3&!(b18_KK65fgB;>8M>xtcj&p*OoZ>WR zILkTCbAgLo;xbpb$~CTYgPYvqcF=#%=E6^RT$QJQ_T9h&3JUkQ&jTLvh{rtPDbIM$ z3tsYy*Sz5^?|9D#KJtmreBmqK_|A|2UR4Ah;K70soDhU06rl-2Si%vW2t*_jk%>Z7 zq7j`K#3UB6&8LhQhq%NeJ_$%jA`+8?q$DFbDM(2wQj>ru_RjEdGYEY9} z)TRz~sYiVp(2zznrU^}HMsr%wl2)|l7k;G;ZD~h)I?$0$bfybk=|*>Y(34*DrVoAT z$8Yp!0KfAG0~y3%hA@<23}*x*8O3PEFqUzQX95$M#AK#0m1#_81~Zw(Z00bRdCX@4 z3t7Zsmavp%EN2BPS;cDBu$FbKX9FAA#AdeeCx5Y(ZT!tYY-b1mvXfoxW)FMW$9@iQ zkV72i2uC@_aZYfOQ=H}uXF11tE^v`cT;>W_xyE&FaFbiy<_>qc$9*2~kVib`2~T;( zb6)V0SG?v8Z+XXiKJbxGeC7*Z`NnsC{O=U~zjJr+VA{b6K}bRonlOYV9N~#TL?RKH zC`2V1(TNfC->abE+A)bmY~m1?c*G|G2}wj^l8}^SBqs$aNkwYXkd}0$Cj%MznM`CR z3t7oVc5;xDT;wJXdC5n93Q&+j6s8D8DMoQhP?A!VHm@NBwktzf?GQh?`oEVzqRP1u zSXS@9h5z@-BzSqZ>k{(+-9WbgcL^+${h(0)zdM6hurRR9E`vh{lo#;## zy3&pA^q?ob=uIE`(vRQh&j5bs4+b)b!N_;;p$sE%JdI!^qZrK?#xjoaOkg6Dn9LNW zGL7lXU?#Je%^c=R{#kJz^I5<`7O|KmEM*zXS;0zHv6?lkWgY9;z(zK)nJxUuUuH!(R5Wp937^5QjO!QI2t(6P)A}r#VAlPUkq!1uk-l%Ut0q*SO9N zZgPv;+~F?wxX%L~@`%Sg;VI8}&I?}hir2j1E$?{G2R`zN&wSx4-}ufC52c|09!?>G ziNUcTL`XsrnlOYV9N~#TL?RKHC`2V1(TPD!ViB7-#3df_J+2an0SQS&Vv>-QWF#jA zDM>|Y(vX&Pq$dLz`I$^)CJR}~Ms{+LlU(E`4|&N)ehN^KLKLP5MJYycN>Gwgl%@=2 zDMxuKP?1VhrV3T5Ms;dXlUmf4WOWEphq~0GJ`HF{BO23$rZl5DEoezATJsCP(uTIQ zqdgtyNGCeeg|2j?J3Z)0FM895zVzca`ZIvv`GbKBVlYD($}omAf{~13G-DXcIL0%9 ziA-WLQ<%y$rZav8qknNG^Pnn6=Jp6jOMhUC9P=9FZ@ay+R~2p zbf6=h=u8*7(v9x)peMcPO&|KwkKgFe0Dk8W1~Q1j3}Gn47|sYrGK$fRVJzbq&jcni ziOEc1D$|(G3}!Nm+00=s^O(;97P5%NEMY0jSk4MovWh^i*07d!tY-ro*~DhH@F#z< zm2LdZKWt|Q|FV-^>}C&p*~fkkaF9bB<_JeQ#&J$?l2e@K3}-pVc`k5~OI+p(SGmS@ zZg7)Z+~y8hL}7|hlwuU8gx4(U7^)7rN4o?)0E1z35FJ`qGcz=+6Lt=MM%lh`|hDD8m@e2u3oB(Trg%;~38bCNhc1 zOkpb1n9dAlGK<;FVJ`ES&jJ>*h{Y^nDa%;S3Rbd;)vRGH>sZeQHnNG$Y~fG-Vk_JD zn}68O4*q2)yV%Vh_Og%t9N-{_ILr}_a*X4g;3TIw%^A*ej`LjLBA2+#6|QoP>)hZb zx46w6?sAX&Jm4XZc+3-?@{H%a;3cnk%^TkGj`w`vBcJ%p7rye1@B9b~3LV5x1S2>h z2uUd189EGM2}gJ$5RphkCJIrBMs#8jlUT$i4snS`d=ik5L?k8&Nl8X>Qjn5Vq$Uk% zNk@7zkddFsL}s#(m26}u2RX?_Zt{?qeB`G91t~;ficpkd6sH6wDMe|@P?mC(rveqJ zL}jW_m1*(;aA$wmUgtK10Cr^XS&dp zZgi&yJ?TYn`p}nt{6>EU@H>AnkU$y!A)*)n>*a)9`|{`Lmu(iI9>+@1vBSh72JNpQ=SnR-wR&4ucr74 z>xO>ATi)@W4}9bkpZUU9zVV$OK|x`Hkk2r|2u=t>5{l4RAxv1p5uOM{BodK{LR6v= zofyO<7O{y#T;dU*1SBL8iAh3Il98Mgq$CxoNkdxFk)8}>LRG3!of@c1m|E1P4t1$V zeHze^Ml_}gO=(7RTF{bKwB{Fnr44OqM|(QZkxq1`3tj0(cY4s1Ui799ed)(<3LltP ze+KY7e=v|i3}y&J8Rj?()L=Lx7|AF`GlsE@V>}a>$Rs8+g{e$qIy0EbEM_x@xsLVt z;ymWFfQ2k#F-us=GM2M~m8@blYgo%V*0X_)Y%<4k;%2t+Cx5Y(ZT!tYY-b1mvXfox zW)FMW$9@iQkV72i2uC@_aZYfOQ=H}uXF11tE^v`cT;>W_xyE&FaFbiy<_>qcC;x%E z-RA)hdBkI$@RVmf=LIi$#cSU1mUq1810VUsXTI>2Z+z!RP*7ND3;Pqn2u=t>5{l4- z!AfDn5uOM{3P^DMC?-QJfN#q!gto zLs`mEo(fc?5|yb!RjN^)8q}l~wW&j0>QSEtG^7!YX+l$)(VP~vR3!Td3hbj5t@(vt zX+vAu(Vh-;q!XR#LRY%cogVb07rp62U;6PI{TaaT{J}s5F_<9?Wf;R5!AM3inlX%J z9OE6wfqhM2B9oZR6sEc_mN<>+%wQ(7n9UsKGLQKzU?GcG%o3KejODCgC97D?8rHIo z^=x1xo7l`2{^T#VvW>s_hwbd(Uv{#K-Rxm6``FI`4swXY9N{R(IL--k3`TJ6lbqr- zXE@6_&U1l_T;eiUxXLxIbAy}Q;x>1<%RTP%fQLNdF;95PGoJH;m%QRNZ+Oc)-t&Qv zeBv`-_{ulF^CKuITo6BDKHTw zNFfSSgrXFqI3*}aDN0j@vXrAd6{tuhDpQ53RHHgIs7WnqQ-`|LqdpC2NFy54gr+p3 zIW1^OD_ZjlztV=bw4*&8=tw6z(}k{dqdPt5NiTZSN3o43C@`MB^y4@BGl1XugMkcU zFhdy1ForXNk&I$AV;IXg#xsG5Oky%qn94M!GlQATVm5P_%RJ_@fQ2k#F-us=GM2M~ zm8@blYgo%V*0X_)Y+^H8_>;fb$~OMyAGWiDf7!_{cC&}Q>|;L%IOseVPdvn7j&PJ? z9OnclImKztaF%nPC-RHuxxhs(S*8x*E^~#eT;n=7xXCSUbBDX!<310JBhY@xBOddF zr#$01FL=o-Uh{^xyyHC|_{b+d^M$W`<2yfsg2D&!6Tt{h2tpFd*o#v_JG66e8Omyh zAuQprarg*CBodK{LR6v=ofyO<7O{y#T;w=>d=ik5L?k8&Nl8X>Qjn5Vq$Uk%Nk@7z zkddFsL}s#(m26}u2RX?_Zt{?qe5hIY0u-bWg(*T&iXjK#134&3DM}+3;RCrSM|mnx zkxEpi3RS5_b!t$PS~woU*P$-;s80hL(ul@#u8!fG(3EC0rv)u(MQeWHSK82)cC@Dh z9qB}8y3mzwbf*VB=|yk)(3gJvMt=tIJAW{cK@4UHLm9?!Mlh05jAjgD8OL}gFp)`2 zW(rf8#&l*dlUdAW4s)5ud={{fMJ#3sOIgNpR!$9XPrkxN|WipN$S z@haE2&JAvIi`(4cF88?41LH|4KI9RPdBRhk@thaD`P7Goai`c{=F7b#@0uqvl#3Ugp z$w*EL%sWCVQj>#VAe* zN>Yl_l%Xu;C{G0{Qi;k`p(@p=P7P{Oi`vwoF7>ES0~*qZ#x$WR&1g;wTGEQv{KBua zp)KubPX{{EiOzJPE8XZ$4|>vz-t?g_{rHXk4B&VEU?77S%n*h$jNy!6B%>J37{)S= z@l0SMlbFmDrZSD`%wQ(7n9UsKGLQKzU?GcG%o3KejODCgC97D?8rHIo^=x1xo7l`2 z{^T#VvW>s_hwbd(Uv{#K-Rxm6``FI`4swXY9N{R(IL--9a*ETO;VkDk&jl`WiOXE! zD%ZHq4Q_Ia+uY$U_qfjk9`cCCJmD$Nc+Lx6@`~5I;VtiY&j&v8iO+oDE8qCekD#E4 zLHtB8f)j#}gd#Ly2unD^69F4Vj6`Ij5S3^|Ck8QzMQq{_mw3b{0SQS&Vv>-QWF#jA zDM>|Y(vX&Pq$dLz`I$^)CJR}~Ms{+LlU(E`4|&N)ehN^KLKLP5MJYycN>Gwgl%@=2 zDMxuKP?1VhrV3T5Ms;dXlUmfK4t1$VeHze^Ml_}gO=(7RTF{bKwB{Fnr44OqM|(QZ zkxq1`3tj0(cY4s1Ui799ed)(<^k)FS^9KVN#9)Rnlwk~K1S1*6XvQ#>ag1jI6Pd(h zrZAOhOlJl&nZ<18Fqe7EX8{XY#A24Plw~Yuh4Z1h22S|UJKW_S_j$lW9`TqbJmneBdBICw$xkZrHE(#!JKpnwk9^`YU--&5 zzVjm}C{hqVxvC`wBRC-lNhm@ShOmSqJQ0Y9jUz=S3Q>thbYc*bSi~j{afwHK5|EHY zBqj+-Nk(!~kP`EXl$tc8B^~L>Kt_Hh6Pd|ERP^DMC?- zQJfN#q!gtoLs`mEo(fc?5|yb!RjN^)8q_3^*V@#fF7>ES0~*qZ#x$WR&1g;wTGEQv z{KBuap)KubPX{{EiOzJPE8XZ$4|>vz-t?g_{rHXk4B&VEU?77S%n*h$jNy!6B%>J3 z7{)S=@l0SMlbFmDrZSD`%wQ(7n9UsKGLQKzU?GcG%o3KejODCgC97D?8rHIo^=x1x zo7l`2{^T#VvW>s_hwbd(Uv{#K-Rxm6``FI`4swXY9N{R(IL--9a*ETO;VkDk&jl`W ziOXE!D%ZHq4Q_Ia+uY$U_qfjk9`cCCJmD$Nc+Lx6@`~5I;VtiY&j&v8iO+oDE8qCe zkD#E)LHtB8f)j#}gd#Ly2unD^6M=|C!p4!K5S3`2i?WbRJ329lNi1R$hq%NeJ_$%j zA`+8?qy)B4P6|?ziqxbbE$K*41~T$9naGU&N6tz%;|TPXogCyOmx;=0#VAe*N>Yl_l%Xu;C{G0{Qi;k`p(@p=P7P{Oi`vwoF7>ES0~*qZ#x$WR z&1g;wTGEQv{KBuap)KubPX{{EiOzJPE8XZ$4|>vz-t?g_{rHXk4B&VEU?77S%n*h$ zjNy!6B%>J37{)S=@l0SMlbFmDrZSD`%wQ(7n9UsKGLQKzU?GcG%o3KejODCgC97D? z8rHIo^=x1xo7l`2{^T#VvW>s_hwbd(Uv{#K-Rxm6``FI`4swXY9N{R(IL--9a*ETO z;VkDk&jl`WiOXE!D%ZHq4Q_Ia+uY$U_qfjk9`cCCJmD$Nc+Lx6@`~5I;VtiY&j&v8 ziO+oDE8qCekD#C^LHtB8f)j#}gd#Ly2unD^d#@uAiM1mTkw`>FM^T~@jp)Q6Cb5W3 z9O4p>_#_}9`im0iF9}IWMsiY+l2oK74QWY7dNPoapUFgKvXGT*WG4qX$whARke7Vq zrvL>hL}7|hlwuU81SKg&Y06NRa+Ie66{$pJs!)|`RHp_tsYPw-P?vhtrvVLVL}QxJ zlx8%i1ubbsYkuKZ+R&DEw5J0d=|pF`(3NgW(;E)$9N_%kx5Ku3R9WJbY?J-EM^HyS;lf!u##1* zW({ju$9gufkxgu73xDz#TiM3n{KIy3@Gm>r#cuYnmwoK#00%k5VUBQ=V;tuMCppDw z&Ty7I+R>g4bfgoV=|We!(VZUjq!+#ELtpyw8~qu;@BG0) z1~Hf+3}qO@8No|rna*v|nDa)`qm;V8#A z&IwL(iqo9oEay1S1uk-l%Ut0q*SO9NZgPv;+~F?wxX%L~@`%Sg;VI8}&I?}hir2j1 zE$?{G2R`zN&wSx4-}ugtprB|${6sK<6M~S0A~azLOE|(4frvyRGEs<%j-o{;1~G|6 zY~m1?c*G}x$7EK_BU(Zdk(eYTB^k*{K}u4Qnlz*(9qGwHMt&v}naP5_qh%vIImk&a za+8O=&aK$t-3whq=sSJ_}gL zA{MiRr7UAPD_F@YR++qZ~kFBJNTEK>|!^2*vmflbAW>! z;&4zq#cl3zmwVjj z0S|e^W1jGoXFTTxFL}jl-td-pyypWS`NU_w@Re_T=SNUbbW@D}6Tt{h2tpEy(1al@ z;RsIzA`*$nL?J5C&{^~t#3UB6i9=lC5uXGkBoT>8LQ;~EoD`%a6{$%>TGEl83}obI zGLe}qWF;Hf$w5wXk()f^B_H`IKtT#om?9LV7{w_;NlH*h{Y^nDa%;S3Rbd;)vRGH>sZeQHnNG$Y~fG- zVk_JDn}68O4*q2)yV%Vh_Og%t9N-{_ILr}_a*X4g;3TIw%^A*ej`LjLBA2+#6|QoP z>)hZbx46w6?sAX&Jm4XZc+3-?@{H%a;3cnk%^TkGj`w`vBcJ%p7rye1@B9b~iV?(5 z1S2>h2uUbH6Na#aBRmm^NF*W?g{VX$Iy#IIlUT$i4snS`d=ik5L?k8&Nl8X>Qjn5V zq$Uk%Nk@7zkddFsL}s#(m26}u2RX?_Zt{?qeB`G91t~;ficpkd6sH6weHiSlSc=k= zp)BPnPX#JciON)=D%Ge?4Qf)0+SH*g^{7t+8q$cyG@&WYXif`S(u&sn!mqTUE$wJe z2RhP;&UB$G-RMpadeV#D^r0{P_>KMy;CKFDAcGjp5QZ|0;X(gh&aK$t=sQ6JxeW zj5*?3aW3*h{Y^nDa%;S3Rc=KP@h$-W(|RU*0G)qY_v`wSDVN~@F#z< zm2LdZKWt|Q|FV-^>}C&p*~fkkaF9dDK@2&Fag<{m=L9D?#c9rPmUEov0vEZ&Wdgao z$~CTYgPYvqHg~vd{J)9!koy=9c*r9j^Mt27<2f&Q$tzy-hPS-qJsRSZK|!dY1kV}=*)J7xqTY8zk7NJJ(Ifo-A@ofz0j z%vi)G4snS`d=ik5L?k8&Nl8X>Qjn5Vq$Uk%Nk@7zkddFsL}s#(m26}u2RX^*ye_{n zbCZX>=E{TaaT{J}s5F_<9?Wf;R5q0c~GM>2}hjA1O}7|#SIGKtAd zVJg#@&J1QUi`mR!F7uer0v57}#Vlbd%UEvz>Ja!sNz4_jBrxaItYNJ@B^Av(TqJQl z8`#JuHnW94`HQV=<8S_9J3I6r$iu(vWEZ>H!(R5Wp937^5QjO!QI2t(6P)A}r#Zt} z&T*a#T;vj$xx!Vhah)67thbYc(_9mk4I9O4p> z_#_}9iAYQm)H7Bxl9Pgzq#`wGNNbRC7%Ls=$>6p;#LCFeWFj+J$VxV{lY^Y(A~$)+ zOFr^bfPxgFFhwXzF^W@yl9Zw}WhhHI%2R=gRH8Cfs7f`eQ-hk+qBeD?OFin-fQB@p zF->SnGn&(amb9WZzwj$1Nfak7|0+7 zGlZcGV>lxi$tXrMhOvxeJQJA6BqlS3sZ3)!GnmONW;2Jm%ws+aSjZw4vxKEAV>v5W z$tqT}hPA9?Jsa4_CN{H$KlzKTY~yeKVLLncm!0flH+$IYc_xmykNq6rAcr{25sq?< z>6Q1&n=iZzQ)b52C zsN+js@tQZh>6Q1&n z=e*!0uXxQH-tvz3eBdLWkgM2V_{ulF^CKuIjw#2H(>TG9%QztjNhm@ShOmSqJQ0XU zByXBD79$gds6-<=F^EYlVq+(9;u4SeBp@M)NK6uvl8oe}ASJ0tO&ZdYj`U<8BR`Xg z%w!=e*~m@~a*~VODP6Jl zYEp~Z)S)i*s4wY(?HbU~A4GwCG$N4CCN!lP&1pePTG5(c_?0%ar5)|*Ku0>!nJ#pt z8{O^Cm;-N8#OXm#O?CL+C6I$&{%Bhw_V%klqr^V+wQQ-|qqX~q6UEJ%j~?_pw~Uc(u|NCNu}>}w2T^%EGwI0F4n zZ~_V(OMx*=Vlq>h$~2}kgPF`?w(%q)aBR(CuCYE7=P{oJEM$>+EfxdJKky3|fnRe8 zd~+d=xkpJME@Qc0Ke^($=c@J!RlD{Gd)1#gBaAvoU-Z zznHJNhcowZ<{bD1oiKs<%3I)**KxiPSno$rP+VQam7BQ12u=v=5;vr6r;DKoO&G!w zj_^bvB9Vwp6rvK1=)@pqP*8~cVk}}4N8bZPJB=HU_#_}9iAYQml9G(%q#z}!NKG0X zBXQG_o(yEfyy9jeGg-(=HnNk0oa7=mdB{sXj4$x5p|}MoXuN^(7ospl9BbvpqNr`$ z;y9M#mZX&X^d0!7L)_Aop)BPHY@s7?)PQj6Nup{}v?73)!-1~jCR gaT)vnex2C3|93D8|6KwFYOEP3ViTIuEO6KV0k8*3@&Et; literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 000000000000..25cb955ba235 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..3931c81cf2c33bb6cf2cb8a702dbb5441f644923 GIT binary patch literal 230 zcmZ{du?oU46h&Wxjt+`~_zOZL#acQ_aS)`7;-03Dn$jjEc?Cb;QkOb7-QnDGF9QGu z>;N+kJLfBbx-nfqp`AzJF}U7q46xMB5?acXe&L-IA+VSYGQehv9;U@Ws_kGQk1~=` znxv;x#vInu^}3|-0ainq@QFScXY;--&;ySW4%?r4AW?_ztL*;~L8@v@As%B~ZHaG~ JXSd5a{{VZ|N4Nk0 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 000000000000..6b2aaa764072 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap new file mode 100644 index 0000000000000000000000000000000000000000..91d6c541512db06197e1b732473d567ce4b92d6a GIT binary patch literal 16 YcmZ?R*xjhShe1S2b=vdAllRF105-b@zW@LL literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 0000000000000000000000000000000000000000..693f619ff953b4d69f4381f9d2ef8e4774e23df5 GIT binary patch literal 228 zcmZ9HT?zs*4208e5#LvQ@eJEz2)?QpkUGe&TUweb?g_n?i9evu%RuIvkhsQLdda>0 z+YBvIIeCP!&kSF2h(27I+JcxWx&ls@640G7N$(FIj@5@$pc{=f5{nyJZlC4d#1)bE shwUfKYX4B>aIJfj-~Nl+Xdu1C>lB-v9sr literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000000000000000000000000000000000000..4d3c581705e78dd3cfa3e5e1ba35e5e74367dc56 GIT binary patch literal 882 zcmZ?R*xjhShe1S2b=vdAllRFf=Oz}Hq!uZZBqrsgaw&&olq&cqmnayTDHs`8nV47^ zStta!h5$K+CR{10IVFj%6$P0^i6xo&dGYy0>3XTjIhh5;sd`x{C3?yEMX9!iCWgkQ zh6YAv7M2EvT>5$?MX5kRt^*OjKZETJ{M=K$yZo2~1@1`BNlh$r0XYW62}M9>q-Ex$ z7VDK}+NLGu6sL0GP??gNRGN-ZMTWod8Vn8xybb_4m9Q#!nBp}nw=$4gI2+01 uR10@w14R7e@H9%emlTx}4tB62nuIz&>*0ZpPZ2!K@hL(JaZr literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 000000000000..6c1bf2717946 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,3889 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + topLevel + + + Minimized + MinimizedByZoom + + + persp.actionSet:ajrefactoring + persp.actionSet:org.eclipse.contribution.xref.ui.XRefActionSet + persp.actionSet:org.eclipse.mylyn.context.ui.actionSet + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.rse.core.search.searchActionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.jboss.ide.eclipse.archives.ui.actions.Archives + persp.actionSet:org.jboss.tools.jst.web.ui.server.actionSet + persp.actionSet:org.jboss.tools.central + persp.actionSet:org.jboss.tools.common.model.ui.actionSet + persp.actionSet:org.springframework.ide.eclipse.aop.ui.ActionSet + persp.actionSet:org.springframework.ide.eclipse.aop.ui.matcher.actionSet + persp.actionSet:org.springframework.ide.eclipse.beans.ui.actionSet + persp.actionSet:org.springframework.ide.eclipse.beans.search.actionSet + persp.actionSet:org.springsource.ide.eclipse.quicksearch.actionSet + persp.actionSet:org.springsource.ide.eclipse.commons.launch.actionSet + persp.actionSet:com.springsource.sts.ide.ui.actionSet.workbench + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.newWizSC:com.android.ide.eclipse.adt.project.NewProjectWizard + persp.newWizSC:com.android.ide.eclipse.editors.wizards.NewXmlFileWizard + persp.actionSet:adt.actionSet.wizards + persp.actionSet:adt.actionSet.avdManager + persp.actionSet:adt.actionSet.lint + persp.actionSet:adt.actionSet.refactorings + persp.perspSC:com.android.ide.eclipse.ddms.Perspective + persp.perspSC:com.android.ide.eclipse.hierarchyviewer.PixelPerfectPespective + persp.perspSC:com.android.ide.eclipse.hierarchyviewer.TreeViewPerspective + persp.actionSet:ajelementCreation + persp.newWizSC:ajaspectwizard + persp.newWizSC:ajprojectwizard + persp.perspSC:org.eclipse.ajdt.ui.visualiser.AspectVisualizationPerspective + persp.viewSC:org.eclipse.ant.ui.views.AntView + persp.perspSC:org.eclipse.birt.report.designer.ui.ReportPerspective + persp.newWizSC:org.eclipse.birt.report.designer.ui.ide.wizards.NewReportWizard + persp.newWizSC:org.eclipse.birt.report.designer.ui.ide.wizards.NewTemplateWizard + persp.newWizSC:org.eclipse.birt.report.designer.ui.wizards.NewLibraryWizard + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.views.ResourceNavigator + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.perspSC:org.eclipse.wst.jsdt.ui.JavaPerspective + persp.actionSet:org.hibernate.eclipse.launch.actionset + persp.showIn:org.jboss.tools.forge.ui.view + persp.perspSC:org.jboss.tools.jst.web.ui.WebDevelopmentPerspective + persp.viewSC:org.jboss.tools.common.model.ui.navigator.NavigatorViewPart + persp.viewSC:org.springframework.ide.eclipse.aop.ui.navigator.aopReferenceModelNavigator + persp.viewSC:org.springframework.ide.eclipse.aop.ui.tracing.eventTraceView + persp.newWizSC:org.springframework.ide.eclipse.beans.ui.wizards.newBeansConfig + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.newWizSC:com.springsource.sts.roo.ui.wizard.newRooProjectWizard + persp.showIn:org.springframework.ide.eclipse.ui.navigator.springExplorer + persp.viewSC:org.springframework.ide.eclipse.ui.navigator.springExplorer + persp.newWizSC:org.springframework.ide.eclipse.webflow.ui.wizard.newWebflowConfigWizard + persp.newWizSC:com.springsource.sts.wizard.template + persp.newWizSC:org.springsource.ide.eclipse.commons.gettingstarted.wizard.boot.NewSpringBootWizard + persp.newWizSC:org.springsource.ide.eclipse.gettingstarted.wizards.import.generic.newalias + + + + newtablook + org.eclipse.e4.primaryNavigationStack + + + + + + + + newtablook + + + + + + + + + + newtablook + + + + + + newtablook + org.eclipse.e4.secondaryNavigationStack + + + + + + newtablook + + + + + newtablook + + + + + + newtablook + + + + + + newtablook + org.eclipse.e4.secondaryDataStack + + + + + + + + + + + + + + + + active + Maximized + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + active + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Help + + + + newtablook + org.eclipse.e4.primaryDataStack + EditorStack + + + Editor + org.eclipse.wst.server.ui.editor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + Editor + com.android.ide.eclipse.editors.CommonXmlEditor + removeOnHide + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Java + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:Ant + + + View + categoryTag:AspectJ + + + View + categoryTag:Git + + + View + categoryTag:Java + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Spring + + + + View + categoryTag:Spring + + ViewMenu + menuContribution:menu + + + + + + View + categoryTag:Server + + ViewMenu + menuContribution:menu + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + + + + toolbarSeparator + + + + Draggable + + + + + + Draggable + + + + + Draggable + + + + + Draggable + + + + + Draggable + + + + + + + + + + + Draggable + + + + + + + + Draggable + + + + + + + + Draggable + + + + + + + Draggable + + + + + + + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + + + + stretch + + + glue + + + + glue + + + Draggable + + + + + stretch + + + + Draggable + + + + + + TrimStack + + + + + + + + + + + + + platform:cocoa + + + + + + + + + + platform:cocoa + + + + + + + + + + + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + + platform:cocoa + + + + + + + + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + + + + + + + + + + + + + + + + + + + + platform:cocoa + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + platform:cocoa + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + platform:cocoa + + + + + + + + + + platform:cocoa + + + + + platform:cocoa + + + + platform:cocoa + + + + + + + + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + platform:cocoa + + + + + + + + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + + + + + platform:cocoa + + + + platform:cocoa + + + + + + + + + + platform:cocoa + + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + platform:cocoa + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + + + platform:cocoa + + + + + platform:cocoa + + + + platform:cocoa + + + + + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + + + + + + + + platform:cocoa + + + platform:cocoa + + + + + platform:cocoa + + + + platform:cocoa + + + + + + platform:cocoa + + + + platform:cocoa + + + + + + platform:cocoa + + + + + platform:cocoa + + + platform:cocoa + + + + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + + + + + + + + + + + platform:cocoa + + + + + + + platform:cocoa + + + + + + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + + + platform:cocoa + + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + platform:cocoa + + + + + platform:cocoa + + + + + + + + platform:cocoa + + + + + + + + + + + + + + + + + + + + + + + + + + platform:cocoa + + + + + + + + + platform:cocoa + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:cocoa + + + + platform:cocoa + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Tracer for OpenGL ES + + + View + categoryTag:Tracer for OpenGL ES + + + View + categoryTag:Tracer for OpenGL ES + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:Android + + + View + categoryTag:AspectJ + + + View + categoryTag:Ant + + + View + categoryTag:Report Design + + + View + categoryTag:Report Design + + + View + categoryTag:Report Design + + + View + categoryTag:&C/C++ + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Make + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:General + + + View + categoryTag:Visualiser + + + View + categoryTag:Visualiser + + + View + categoryTag:AspectJ + + + View + categoryTag:Data Management + + + View + categoryTag:Data Management + + + View + categoryTag:Data Management + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:JPA + + + View + categoryTag:JPA + + + View + categoryTag:JavaServer Faces + + + View + categoryTag:JavaServer Faces + + + View + categoryTag:Maven + + + View + categoryTag:Maven + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:API Tools + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:CVS + + + View + categoryTag:CVS + + + View + categoryTag:Team + + + View + categoryTag:Team + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Debug + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:Server + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:Hibernate + + + View + categoryTag:Hibernate + + + View + categoryTag:Hibernate + + + View + categoryTag:Hibernate + + + View + categoryTag:JBoss Tools + + + View + categoryTag:Server + + + View + categoryTag:Forge + + + View + categoryTag:JMX + + + View + categoryTag:JBoss Tools Web + + + View + categoryTag:JBoss Tools Web + + + View + categoryTag:JBoss Tools Web + + + View + categoryTag:JBoss Tools + + + View + categoryTag:Seam + + + View + categoryTag:JBoss Tools Web Services + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Spring + + + View + categoryTag:Debug + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..dd4af88111a23b0a696d83b454b8b21d3101eb42 GIT binary patch literal 6503 zcmb_gUvJ|!4DaXJW~=#g-MtM(k#*~}*si^G54WLHY&DUiSe~S$=^X|Pdl-g2>@$y| zoy2lfIdO^tsU^~+NRdC1J~=tLJo!w1(oAVG5-g`Ap7)7jh1A?g^-QFi5M3yqPaYMW zvnQ!$)jDFULNTqm%*inB#i#M@=z4U1H`=8~4n5Lxp%SL!jH;8L$=$OyY)-EESW!@T zMVAzR?zu7xDsE^p+JMg$)dwlYM>gbJ2YLs2mAXw{g} zT>A||l4}d9x;n;&3qiF8^A;RsU9=s0E4k+ZxiyujUHyZ zbC0s4%0w#W_qL_D&UO^)jtZaHc)m>hDoa{G=@;Ic9<3l8Z60Xy{)3I*_!BQqe(~~J z@}ZHf7kQSjheF9EPnp6io_9C@McV_0|ItxhVpDZxBE2XIsf=HBgULMxTKn!8U#>F@ ze2Bsp$Jr9L;bo+|3#m=yoJ_cxF2*FALG#Ig4C0=<6TuG3{ijXt4uY^`p}2WogTJoUk)abnXbrmh@tbCe zXmWx68W*1AjrZznDR*8Jg54#G7iN@Cpj6;%U$woKQT|{d2D#%l?wi}I4^oO5H^|?L z18J@wbc(z`cxCU21MApL$|`{ZX9wR6*6-+0ODJw@>|e zuw6y4a!SQ-L2&@cE3%}5L+fCBneAgl3l7P53V)a9jeW?$avu-;cSwV`g?cGn01F@a zq$OKQCQq{b`-BqzPbj?<$KmY;7F=l$CUfY(Ad7h%u z-bU$q8#R{5+qJM)Mf8B`gboen#vTqu?^=Itjl#IVE!1%R8u*t%kBrjpkCEog3(!>+ zvqbkwxBnHo-~%(bL*}4u?_19x9)}sx_BRr8GR%5?9E*DH9$?d1RmVpmkz4%SKJ6eW zp6t(%n1j3nMF?SKXIk8}0>FXDw&B1Nd=okW`T_<(@Cf*$ANS761vtVkP(U6Mut%UD zfE=jrzmUFzT-LcHI0*LRF^RKjL#EJ=GEoO!P!x{}ADVBm6l4&FCHRFT5V#m(!LxRxnwInJFJS0n%K(MYQ4{H_W|1d&j;fG-$ zc!rx`p@dhc5S-=-BlTx!Kk92ZwOg=0ww)d8?z+&{gWIXVHA1ZlcXfJV1waMj#8AR;{2B8QV$=o$<+qiTC1~Y{XZyIk7JI9~MsDs{jB1 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps new file mode 100644 index 0000000000000000000000000000000000000000..80b5f91d5487d47a2dda655a640b25e7adcab826 GIT binary patch literal 5404 zcmb_gU5Fe-5N>}WdGZHQ2@xUzInd1X?e66+dC=T)Z0>U25p$O)x(S!wncm%*ot+t{ zd-wJN0ZAZ=5|V%-NaP+CUlK%}=*|jrX!U z-8J3SRrOVU)q@b)j3)3dMjeJr1~mzmn|bU|+hQ8GoF!~IHQcoJX@)_tQ`bxj=j5@u z5${j&;S5tTuHdCWbkARL=EHf<-VHY+gON>TmQUo?l{|Ht~#B zaR|6%nzV`dc|vn|ix{&+0mo1Vo*9M1>uLi}SSF_?XL!nLQfz1yOgkJKmO>1w5>9*t z#qNpUKR_E|6_h%#1Jf*%VZES|ma19)s`2utzubWyi(TcOZGdA<7=$r6v98eYD90y$ zLvrkI!CGu18iNp`{hz7_Z>L7Ft_C% z^l(;G+f->1UiTM`m){**KvLEsooEY+rBWqa_V&@M==n4=V|`4OmZR~dAlaEemN=YZ#d3l~7%zWv`3#ziwSIcA?2074YBH1g2ZCgg zze5{i_wGruqHP;=UU4*=m&_WJme9lRyzun^UrB)Z(A+At zJr-31A~xUy#p4CvZ^hRS9#B>gIYcosvKih;Fme5ri|FwcF|iJ`LwS&r#qL)xKb1}~ zhE;>+!TWV7B{%8~1i$1)LvWuSx(^j%kJyvjO{i&$4zX?OEI2fJ}EgrHW>%Kzq>pg=rp4iyRMnwaIh*4F*k7N-Ik&n;3>hOoig!XE=NB zSlHsVw518SrM_sE>$0VFydy;&=S&rW_Y}HI+#L4}ZLC8bzy}7M|lq|Ig z-3srBB-_+anY<%XE1VCM>3r;CL~l?T_%XgG0zpDE^xU^=(4I7P9tOjfuD8(<7%aGV z1VBSi1LV$wbuJ3M$W4}ieQy*!6q`^z*$Cvkz*K(?u=DO)Q7!Fgu?>u<@sh4qlz7Lx zk_6Yc&+bP%G8OjllBhztytr!Qu*XgQTpvH3_?e`q`Tz+iSSgx(f`!CX;OTRK3AeEI7RW_H20W*y$F3d7oy({d(f1W6JjQ3MYKPY^rb_6Yt;Q zfR#;9J;O2J1ja%1$`{#P=!w`oadi)Hm+U7VyP>dLuz#`J{bCn7^q+m3+$Wh;t(MV6 zD3<$DLL)JB={B%8g(id(ZMf4@=sTND_X6(!O9nA(1yG)g&WOt6*PWX$&+I|d|Hq#} zFV+g0gJSpW>7xU*{ROqfH6v(j#>?-Y{V1Ee5>O2;x}9I(+Q$cP)08FYSYJy;9$_pp!LX8qE{m-+RMMDp)7t<)EMn o@`*@7{~x=s4wX{dBQgrJ8{@VNwsBk}RXbNy8H%;#(W1uQc^EC2ui literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt b/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt new file mode 100644 index 000000000000..32e47edfaff1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt @@ -0,0 +1 @@ +INDEX VERSION 1.127 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 000000000000..4644f71d7902 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1,2 @@ +aj +java \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000000000000000000000000000000000000..d3473153f2a45d801866c97b04962b1bd2bc30a8 GIT binary patch literal 4948 zcmb_gZExc?49@S_W~+I*?)GUYitHuV!*=bh`*0gN*;W%dvgAohnjSD<*oR?1dlYRa zcA{FzC)se0@8qo+ErlC0}?iG~Gbd3|HXZyZ0{4@kd?`e)Gz@<5Lr0Rx(f7L#fr8 zXH4Tw{tCJCLKae&;*E{Wsw|bZ{(S5Sc{20n9Os(MfK%wpU7s(hD#)DM#VR5BQqpuu z7F1?}B@{3?jK}e)wE?Mu4ODvHr_{lemQVnUfd0Z|uKphhD(7P|j)&cy2zF5Ke<8gG zfoJJTbNk$Y-PG&I(m9lv0b8T^)qY9rOM(5C6yD^OHwP^+UX`U_cd6#3oys}XI)3e| z(ARRxA5x_&={O|)_ICDODY4`hwFfICljgx>DEpIF_mLISfGDlX92G84&J9vk^u&^4 zo%(B`I`fo(`9x!EQ)*@$UHA>|&OJu|=rfuFw`|Co3JzrL^zR-cT5_nC3;6r~YHuHk zrrO6C{@Z84OYbk?8(8F#&jawTggof(B?YWsX@w@#eNH01l9ofynn0C|_BJ7mu!+ts z`kZr2^GKm*>P;a?4pd_xhOQEtMdX@b!evHAF?6eg?FhHgQqgD08^#KXHTC+T(eUzN zr|iYW5ssmkU8meu%b}akQLH(1WDL*!IodkY2{gxYnVMn6&i|Yo_LtEMdGCeMUmfC;4!ML)fsp2X%Q_H=Svp%3NhMLiF#RM)8wQx9wXXfmOYgz#DwqcLR(CjGGVslK~?^_o~qK%R&e0yU>`zekkK0oZzZM6?X80rzkjL^ z4$d7?ZED@2xO0F}|I!PJ*5s9sGe-_6eCriHa?0sY9gI%0!ccgI8)tNtafLTHMtWtr zI0B!LQz`_fGG(Ow3?oE)4X~=pXY6&p6{!M7;3rMXlIaH+Jn_Es5JV0}?51}DWp}dG zq!F3Ab8?oUJWEofzt{U?yE{SJ+n%7I;54w{3Dc5VMz&8;J-sPi`}7@`RQS$ogyK1x z3*vLl(t_Fr3jf&`?P{ci_x-hCmgJ@cx`ZJ!u6JVC!O_xnm{F8mxS7avjvWZk(d6gr zLo^kECJhpv>GJmzoNhaW&bn7Y*Ed>@x_vOyz8cPgpM-ERCf cXg8h;>>WHXm1Ku>a&AC0d0BV%!@1-nL+RRdAs&G?a zEmUKaTPAicO48sr2TwX$j!&n>V9&$Ew7Q){>hLAK86W74K2ZBVF?lC~!c-dhb5Sl- Cf*BnE literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 000000000000..81c4e135f36b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 000000000000..a4ee3cbc9a7f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000000..9e390f501d05 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 000000000000..a67b723f21af --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,13 @@ + +
+
+ + + + + +
+
+ +
+
diff --git a/.metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat b/.metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat new file mode 100644 index 0000000000000000000000000000000000000000..9f3dde8c83f9ee3a0de403271ab008c8ea700e28 GIT binary patch literal 15826 zcmds8*;3<16z%8visS=i14Bq^-pGW>3kz! zudtSk zJG9Q#xyI%iZA;)lDv@hP`0U{`121pT_Fm&kIxI1hqdsa15$m~@fG+wr=;QAdFz4DM z%^lanXOU+QFsuQm#cn^f-+RKIR3NA8fSJ_qgId0pO;Wk5 zl5L*mBdIM^CC1%HsS<8|Kp&->QkrkRmoeW3_om4oIlb1>cZF{s(s-|FM*6zoRZMft zupjy3LGGu}7@`-FZ9MC5!KdVS(F1R5fYqECQj9w7T0<+kZvi}(`lLsHd!TF&JrfN* zq2x)*9^+x0Sb?ffQx6amk2(IP8peUfC##(&d=Idv_lqVF9ayavAYG`TH-JTK)xDNp z>e3lnZt+X>7VVX35%?%YhOS>>3D07-Q2O3MBTn_2@32Bqxqc2PzsLUPu)|+qw>{YM z&*}qO#*n9u#&ZY@@tW~i01I;FN?T8I?sa1nsK0mjL+-|S8sV>f zC&>e5w=Ke}4IGMUhW2o1^Q0fzgOk;H?ZL_NsXeEu4VbK9fqcY0%%(7s9m3aRrbw~` zK`XTQrWIHWLReIlM+?U`%uUQ75d+ADWWglr=|EP(J&Y&qylAgPJtpGW4Rzk!#EH&b zF}uY)pox6B&lJ8qqg&=QNwNHU7mKq@Odjam1t~Mpo?TDp5*`4FuQPJteos9Bx<2S8 zIY!9_T_Dan!{-?J(i8Nh&4}iIqBC4@%}eLg$5{7ya**$#RhXY;)XbbDV`DzMKwdSM zC^dKB8TBDE%TX>6+HgPflmlSZ)malp_dnnhhxAc5f{M1^%ZMQ`#CzsTA^ss0{S>cHOW|SB$udZDS7^))4i zpaJpEsvE{f7p)%_lSqT{L|e9N*f{zhGx#Q~K(Ri`8Wbx9L)bHVC(NRo`l9eQeS}D; z;eLJomaQAkv<>#)Yuy8KAF>s$Dw_JJ_^Gtk=_3UXR#NM%C6eOIJF_-upAP|}4<514 zRHZ0alrL5lwv7}YQASpOlJZ-Uu*MMocL9D4fQ_pcEc5dD!cDQGFM)lQH4MWt))C4A za#c_DquKJZn_`wuRr?O%$b+?l?GYvQJGF(}>YxU^gXh7UGU8?AKV#ch%6IBso;I$2 zt6hnje zR^5GCc}h8+c@UGqa-n$I{ASRfckXyQ>OpHPY9M-KSDFuXWCY0XZMQSlINf$k2h=Bg z<^~7lg?iWCKcgQd+Q0)=dpb(XKi}RBI>4GT-$f?NorPmyA~&lpaVAXN`2==?Q2_4` z)&~n|W^%KXdzYPyMLd>E%vyxGyiEcu=gD<*=g6)Vml!i%G`) z_cC$jZf~-P$0WCz{bG?9w^)R8>h^7_rkimVnP;@M&gR3P{eB2D2}|g~8+Z-@EL|PhQEOS{{S>jX=2kWR zvLpEMc9hsu`s(a?&D0hThh9zKvp^6#OgV`8gId<%jRiG8b$QAirSY>mn7&4`!Lp}TYt>pUZP z|MWVFz9p0wvu!7(hqE%&GFjhA;rl)GNBOo)5B&GxLokM4;h7rwM_Ap%NW17nX|E5? z-EoHX8O8gzS! +
+
+ + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000000000000000000000000000000000000..a02fb4650f8e45ea2e1df34b92eecd43f1edbfc7 GIT binary patch literal 545 zcmcJL&rSj{5QiraP%%aYY8WvL*x`K z0&j*#F!AW!U6v5y&4azPo!`vYFMa-kj3GEu&+18`F};tP($2UM-Y=y4`TfxwjkZ&ebzwPDx*8xEp#lqe zx5Ed#D0$!)o0df2AG%POI##*nH$n<4&{$YaTKiVW;w9H}eGTmO1z{HhYkKeiX%{vq zskP=A(=0z!bZ0d8@RY2$<=$*+WtP-cH$mx8TPQfJ!W>pEIhE3Gd4I<_DD6c*y&k)> zScsi-(~hJv3** +
+
+ +
+
+ +
+
+ + + + + +
+ +
+
+ + + + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml new file mode 100644 index 000000000000..50f1edb316c5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 000000000000..24f718e1cac7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,30 @@ + +
+
+ + + + + +
+
+ + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml new file mode 100644 index 000000000000..b9f4ca805bdb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml @@ -0,0 +1,23 @@ + +
+
+ + + + + + + + + + + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 000000000000..1ae420da85e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,33 @@ + +
+
+ + + + + + + + + + +
+
+ + + + +
+
+ + + + + + + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 000000000000..61cd82aa2a58 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml new file mode 100644 index 000000000000..5ca0b7769013 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml b/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml new file mode 100644 index 000000000000..1b1be0f54ece --- /dev/null +++ b/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps new file mode 100644 index 0000000000000000000000000000000000000000..35109d64d3e3256206edf3012bd512e0c531ec6a GIT binary patch literal 503 zcmb`=!3n}Z5J1uKU={YT1A+|*9>g3Cxe1%>5LY(YFtZ`11JBW;2P?24n=vR!1$+Pe z2LMYrVJgIeJ4dy~&<4*|J3&=Z&_)N1s&Q>;YeCPYqQcomNOcm_MNCkIXF_Ll)@(^I zXWxy#%+|(tV*#+(uZH#oMPx?{ZU0vC!}|$)yzh|3#iW-&)dUQm8>Ddo#2gbF` literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat new file mode 100644 index 0000000000000000000000000000000000000000..ba9a8170ae5ec89bdb5d171754fea4c255312989 GIT binary patch literal 840 zcmb`EO-{ow5QT?QevZKbs4W&f0H7>Ds7O_-?m(_HN{k#knsF3*d+dY;q*lr%3u|O) z-n{S40Kg0YF5&~YE0xQwam9jb>Pk?-=mjDBhBR{QN!_vi-cun^TT?TNmV@}>JP4~A zr^~1muj}md`F*u{d|74dPLXu~%x18YTSj7;S#(N2#rhljJ{{@C}5@risJ>E62Whp3&$mj({ox&l3I zfK%JkF#Vl=qa>68=NdjH#_2b(GcNb-2uWJ + diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000000..9e390f501d05 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml b/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml new file mode 100644 index 000000000000..0bd2033fef4d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties b/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties new file mode 100644 index 000000000000..4acf7ba3bcec --- /dev/null +++ b/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties @@ -0,0 +1,3 @@ +# +#Thu Oct 16 20:44:26 PET 2014 +task-tag-projects-already-scanned= diff --git a/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml new file mode 100644 index 000000000000..63fae25e8f31 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml b/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml new file mode 100644 index 000000000000..f977cc958a0a --- /dev/null +++ b/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml @@ -0,0 +1,8 @@ + +
+
+ + + +
+
diff --git a/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state b/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state new file mode 100644 index 000000000000..8a7bbde21f5a --- /dev/null +++ b/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state b/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state new file mode 100644 index 0000000000000000000000000000000000000000..9fa791da421b3fb5dc677f2f61a85c116ef22a46 GIT binary patch literal 8765 zcmeHMU2GIp6u#XSQlQ~48jT{v*ccFYCX}{dD=DS4bjfakZm|Xsy*qQeJ9KttxN~>A zE6pY*7=HprqY#Wy6A}|78iG+oUU)LW80Enj^+9~_LDcwS&?g@}_s;C@?C#Jl&~Cel zP1^0uCILO z#dTX7QDX=#u}M4$k43OO9zredDw@#7*a6h+E^UT39td;kGM6qFrOOr4TceJ^?u>;H zS_Z$XQZ&E4x^ji>!xKHdZEru$0tg97%fUctdIsiYtmzED_S75ewgync09ve@SRKF$ zGiipRwZ4*cQyI6VVFGwiY_Kpa$M&7wu;J?AKR`wpHQ8B1VMz9eLhP1HcDF`h10Vsq zw@>%P)*;gv!y4sV$xCg&Mvq=u!a<-YIBgMp@1@me-aNNs|D?0GV~V}KF&pev*xnRL z5tZ*vP}9(!BNVLfOZ5!@0@jBh#297-^yr+1tlbj^j_JfJY}3!@KmRCcevtPl>e+^n zeFWt|GXJ{>V&(t$roe!qa~r$16KvQKQziOjTUP=bs;(LFplwm{0v^(oASJe$q6)Dm zH+9)mk&{?6Q^OaMhntdPmxlW?v5QM3WMxhSG-}U-OpWlQsRQI zd0_{txiJ7Cw9{{&mu?Qx1g%7L?t+5u1M-a%HwF`{8m~ zIL$6`n!xH^)vPWhj+;+_;guoXb8*wnQ`dj{*I~{6YJ#h?29k*HK{sD%dpUQp?^8%& zhnPs^0HFqD?`wayuk`W)!bf{%_h~4NMsyro-`YZ#PB({y?#7X>j z2p&{|nyNV^V98kqjMrD4+$B{HF;rVUeIaw$T0voo2K~~Hx3-mL`Q8*WCp1bbbG)}R z;;FQw&YFWxKOme+G$t;$S;^BPK?ph2^}6h+4IbX ztGrfoKW<|vHoH7KM2s{;cZ>fcHPO?bTvn#8g5B2$hCZI(cVL?+Q3A6!jb)t%o!^Cd zga+L^g>-x&;2!wwf z;_C^QqJ0dVpWie{m`MWh�EgqCyQ9*0M+#e4S0^{3A~eScVt?3XAo zA+!hioYWaeiEg1TgTc4;fT^w&(+t(y^_2oNH<7`sf|HbsHIAaHlgQFGzSNLgwt|Ie zN}(0Z)rtW*p67CV`Fv6*-MPJDoYu{aKUTo~0fy#S9}n@o*|us+E(V5z;NCk$VFDQ; zd@T4RpSESOw1$U>o48CnSbh6x!% zEAp-uYiVcyNQTe2YL>~MHK@1h;Bjg(o6h?NACk6zTRh^irLHakeJ|50n?2k(pK!&AM*DzF*9V!dk1$;y!*rEkh=JA> z1q=)f{6H*IS_IQh*l}>}LFM+2MzbwTm>3wqCJ6vNs7IU!VP?pi`AmqItZB={!05)n zm6M;C;+B|Pl3!F&#GrxIq@4WZ>|(v3RA6`%CFYg*0J&+QD|B>DWW5HO;lsdET$z_# z!k~{mD8Rb)QFN;W12q6c0_b)VVr^9M%g;+o%q#+FP3SfQy{35dIwlnZ{hM48SejazngY_BQIwyTS(RD@^u2Sbeb8f|?>&J@tR%4{ z73dB#BFyqH&r3|oNkuly`2PBxYjg8g!eW%c-hqLkxR9X^XflZ81g4cyF+5>VP*4E? Da!f9r literal 0 HcmV?d00001 diff --git a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml new file mode 100644 index 000000000000..ff2193fcc332 --- /dev/null +++ b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml @@ -0,0 +1,816 @@ + + + Spring + + + http://spring.io/blog.atom + https://spring.io/favicon.ico + 2014-10-15T13:20:00Z + + Whats new in Spring Data Evans? + + + + Christoph Strobl + + tag:spring.io,2014-09-17:1764 + 2014-10-15T13:20:00Z + <p>Spring Data Release <a href="https://spring.io/blog/2014/09/09/spring-data-release-train-evans-goes-ga">Evans</a> has been around for a while and it's more than time to finally introduce you to the latest and greatest features we shipped with it.</p> + +<p>There's a lot to cover since major enhancements have gone into the commons module. Those changes already have made it into some store modules and will go on and sneak their way into others over time, too. All of them are already available for at least <a href="http://projects.spring.io/spring-data-jpa/">Spring Data JPA</a>. That said, lets jump right in.</p> + +<h2> +<a name="user-content-advanced-support-for-java-8" class="anchor" href="#advanced-support-for-java-8" aria-hidden="true"><span class="octicon octicon-link"></span></a>Advanced support for Java 8</h2> + +<p>Java8 has now been around for a while and previous Spring Data release trains already added fundamental support for some of those. With the Evans release train we extended the support significantly.</p> + +<p>Java 8's <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html"><code>Optional</code></a> has been a supported return since the <a href="https://spring.io/blog/2014/05/21/what-s-new-in-spring-data-dijkstra">Dijkstra release</a> freeing you of having <code>null</code> checks spread across your code. We simply wrap and unwrap values for you when used as return types with repositories.</p> + +<p>As of the Evans release <a href="http://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html">default methods</a> can be used in repository interfaces to e.g. forward parts of the parameters handed into the method to other query methods.</p> + +<div class="highlight highlight-java"><pre><span class="kd">interface</span> <span class="nc">PersonRepository</span> <span class="kd">extends</span> <span class="n">Repository</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">,</span> <span class="n">Long</span><span class="o">&gt;</span> <span class="o">{</span> + + <span class="n">Optional</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">);</span> + + <span class="k">default</span> <span class="n">Optional</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">Customer</span> <span class="n">customer</span><span class="o">)</span> <span class="o">{</span> + <span class="k">return</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">customer</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">?</span> <span class="kc">null</span> <span class="o">:</span> <span class="n">customer</span><span class="o">.</span><span class="na">getLastname</span><span class="o">());</span> + <span class="o">}</span> +<span class="o">}</span> +</pre></div> + +<h2> +<a name="user-content-enhanced-multi-store-support" class="anchor" href="#enhanced-multi-store-support" aria-hidden="true"><span class="octicon octicon-link"></span></a>Enhanced multi-store support</h2> + +<p>Configuring your application to make use of different Spring Data modules has not been without issues so far. E.g. you might want to combine JPA and MongoDB where <code>Customer</code> happens to be a JPA Entity while <code>Order</code> is a MongoDB Document both persisted via according repository interfaces.</p> + +<div class="highlight highlight-java"><pre><span class="nd">@Entity</span> +<span class="kd">class</span> <span class="nc">Customer</span> <span class="o">{</span> + + <span class="nd">@Id</span> <span class="nd">@GeneratedValue</span> <span class="n">Long</span> <span class="n">id</span><span class="o">;</span> + <span class="n">String</span> <span class="n">firstname</span><span class="o">,</span> <span class="n">lastname</span><span class="o">;</span> + <span class="c1">// ...</span> +<span class="o">}</span> + +<span class="nd">@Document</span> +<span class="kd">class</span> <span class="nc">Order</span> <span class="o">{</span> + + <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> + <span class="n">Long</span> <span class="n">customerId</span><span class="o">;</span> + <span class="n">Date</span> <span class="n">orderDate</span><span class="o">;</span> + <span class="c1">// ...</span> +<span class="o">}</span> + +<span class="kd">interface</span> <span class="nc">CustomerRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">,</span> <span class="n">Long</span><span class="o">&gt;</span> <span class="o">{}</span> + +<span class="kd">interface</span> <span class="nc">OrderRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">Order</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="o">{}</span> +</pre></div> + +<p>Until the Spring Data Evans release you had to manually configure the repository setup for MongoDB and JPA to mutually exclude the interfaces not relevant for the given store. Users usually used separate packages for that.</p> + +<p>Now the repository setup detects that multiple Spring Data modules are on the classpath, and automatically restricts the repository scanning and inspect the domain type used by a given repository for store specific annotations such as <code>@Entity</code> and <code>@Document</code> to determine the concrete implementation they belong to. E.g. the Spring Data MongoDB module would drop the (accidentally) detected <code>CustomerRepository</code> as we don't find an <code>@Document</code> annotation.</p> + +<h3> +<a name="user-content-statically-limiting-results" class="anchor" href="#statically-limiting-results" aria-hidden="true"><span class="octicon octicon-link"></span></a>Statically limiting results</h3> + +<p>Dynamically limiting results is no new concept since Spring Data has had <code>Pagable</code> as abstraction since its inception and I bet nearly every Spring Data user is already familiar with something like this:</p> + +<div class="highlight highlight-java"><pre><span class="n">List</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">,</span> <span class="n">Pageable</span> <span class="n">page</span><span class="o">)</span> +</pre></div> + +<p>This method declaration provides quite some flexibility: clients define the page number, size and a sort order of the elements they want to access. This is great if these values change dynamically (e.g. when you traverse the result set page by page).</p> + +<p>But what if you're always only interested in e.g. the first 10 results and you always want them to be ordered by lastname? This could've been achieved by statically defining a <code>PageRequest</code> and reusing that for every method invocation. However, that still required the client to hand in the special <code>PageRequest</code>. </p> + +<p>As of Spring Data Evans we now offer you a convenient way to explicitly limit the result set to a certain number of elements by using the keywords <code>top</code> and <code>first</code> followed by an optional positive numeric value (defaulting to 1).</p> + +<div class="highlight highlight-java"><pre><span class="n">List</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">&gt;</span> <span class="nf">findTop10ByLastnameOrderByFirstnameDesc</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">);</span> +</pre></div> + +<h2> +<a name="user-content-mongodb-full-text-search" class="anchor" href="#mongodb-full-text-search" aria-hidden="true"><span class="octicon octicon-link"></span></a>MongoDB Full Text Search</h2> + +<p>The Evans RC1 release introduced basic <a href="https://spring.io/blog/2014/07/17/text-search-your-documents-with-spring-data-mongodb">text index support</a> for MongoDB 2.6. Using <code>@TextIndexed</code> allows you to mark properties you want to have text search enabled for so that we can go on and create the index for you. Note, that placing <code>@TextIndexed</code> on properties referring to complex types will index all properties of that type. Since scoring is a fundamental part of full text search the <code>@TextScore</code> annotation will assert that any full text query returns the documents score allowing you to order them by relevance.</p> + +<div class="highlight highlight-java"><pre><span class="nd">@Document</span> +<span class="kd">class</span> <span class="nc">BlogPost</span> <span class="o">{</span> + + <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> + <span class="nd">@TextIndexed</span><span class="o">(</span><span class="n">weight</span> <span class="o">=</span> <span class="mi">3</span><span class="o">)</span> <span class="n">String</span> <span class="n">title</span><span class="o">;</span> + <span class="nd">@TextIndexed</span><span class="o">(</span><span class="n">weight</span> <span class="o">=</span> <span class="mi">2</span><span class="o">)</span> <span class="n">String</span> <span class="n">content</span><span class="o">;</span> + <span class="nd">@TextIndexed</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">categories</span><span class="o">;</span> + <span class="nd">@TextScore</span> <span class="n">Float</span> <span class="n">score</span><span class="o">;</span> +<span class="o">}</span> +</pre></div> + +<p>That in place, we extended the repository support to accept a <code>TextCriteria</code> instance that will define detailed options about the text search that shall be executed: the terms to be searched for, language options etc.</p> + +<div class="highlight highlight-java"><pre><span class="kd">interface</span> <span class="nc">BlogPostRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="o">{</span> + + <span class="n">Page</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">&gt;</span> <span class="nf">findBy</span><span class="o">(</span><span class="n">TextCriteria</span> <span class="n">criteria</span><span class="o">,</span> <span class="n">Pageable</span> <span class="n">page</span><span class="o">);</span> + + <span class="n">List</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">&gt;</span> <span class="nf">findAllByOrderByScoreDesc</span><span class="o">(</span><span class="n">TextCriteria</span> <span class="n">criteria</span><span class="o">);</span> +<span class="o">}</span> +</pre></div> + +<p>The first query method is quite straight forward. It executes the given <code>TextCriteria</code> and pages the results. The second query method definition combines the given <code>TextCriteria</code> with a standard criteria definition derived from the method name. This shows that you can freely combine text search with standard query easily.</p> + +<h2> +<a name="user-content-mongodb-query-modifiers" class="anchor" href="#mongodb-query-modifiers" aria-hidden="true"><span class="octicon octicon-link"></span></a>MongoDB query modifiers</h2> + +<p>We added <code>@Meta</code> allowing you to define output and behavior of a query. By setting e.g. <code>maxExecutionTime</code> one can define the maximum duration a query may take (in milliseconds). Any execution that exceeds the limit will result in an error. You can also advice MongoDB to only scan through a maximum number of documents and return what has been found until reaching the limit by setting <code>maxScanDocuments</code>, while <code>comment</code> allows you to define text you can search for within the <code>system.profile</code> collection in case you got profiling enabled for your MongoDB instance. </p> + +<div class="highlight highlight-java"><pre><span class="nd">@Meta</span><span class="o">(</span><span class="n">maxExcecutionTime</span> <span class="o">=</span> <span class="mi">100</span><span class="o">,</span> <span class="n">comment</span> <span class="o">=</span> <span class="s">"onlyLimitedTime"</span><span class="o">)</span> +<span class="n">List</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByFirstname</span><span class="o">(</span><span class="n">String</span> <span class="n">firstname</span><span class="o">);</span> +</pre></div> + +<h2> +<a name="user-content-configuration-options-for-redis-sentinel" class="anchor" href="#configuration-options-for-redis-sentinel" aria-hidden="true"><span class="octicon octicon-link"></span></a>Configuration options for Redis Sentinel</h2> + +<p>Redis 2.8 introduced high-availability support know as <a href="http://redis.io/topics/sentinel">Sentinels</a>. The Redis module of Spring Data Evans adds support to easily configure connecting to a sentinel setup so that your client will be able to continue working in case of re-elections of master nodes in a Redis cluster.</p> + +<p><code>RedisSentinelConfiguration</code> defines where the Sentiels are located so that the <code>ConnectionFactory</code> can set up pooling accordingly. In case of Jedis it will create a <code>JedisSentinelPool</code> for automatic failover. This means that in case your master node goes down, you'll receive, as soon as the Sentinels agreed on a new master, a connection to the new master without the need of any further interaction. </p> + +<div class="highlight highlight-java"><pre><span class="nd">@Configuration</span> +<span class="kd">class</span> <span class="nc">RedisSentinelApplicationConfig</span> <span class="o">{</span> + + <span class="nd">@Bean</span> + <span class="n">RedisConnectionFactory</span> <span class="nf">connectionFactory</span><span class="o">()</span> <span class="o">{</span> + <span class="k">return</span> <span class="k">new</span> <span class="nf">JedisConnectionFactory</span><span class="o">(</span><span class="n">sentinelConfig</span><span class="o">());</span> + <span class="o">}</span> + + <span class="nd">@Bean</span> + <span class="n">RedisSentinelConfiguration</span> <span class="nf">sentinelConfig</span><span class="o">()</span> <span class="o">{</span> + <span class="k">return</span> <span class="k">new</span> <span class="nf">RedisSentinelConfiguration</span><span class="o">().</span><span class="na">master</span><span class="o">(</span><span class="s">"mymaster"</span><span class="o">)</span> + <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26379</span><span class="o">)</span> + <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26380</span><span class="o">)</span> + <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26381</span><span class="o">);</span> + <span class="o">}</span> +<span class="o">}</span> +</pre></div> + +<p>The upcoming Spring Boot 1.2, will even take this even further by automatically picking up the <code>RedisSentinelConfiguration</code> if present and initialize the <code>RedisConnectionFactory</code> accordingly.</p> + +<h2> +<a name="user-content-schema-support-for-solr" class="anchor" href="#schema-support-for-solr" aria-hidden="true"><span class="octicon octicon-link"></span></a>Schema support for Solr</h2> + +<p>Although the <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a> is not finished yet, we already try to support as much of it as possible. With the Evans release you can now dynamically add missing fields to an existing (managed) schema. To achieve this, we read the existing field definition and compare it against the one derived from the properties of the domain type. To do so we extended the <code>@Indexed</code> annotation a bit. It now allows some fine tuning of the fields to be created as values such as <code>indexed</code>, <code>stored</code> and <code>solrType</code> can be explicitly defined.</p> + +<div class="highlight highlight-java"><pre><span class="nd">@Configuration</span> +<span class="nd">@EnableSolrRepositories</span><span class="o">(</span><span class="n">schemaCreationSupport</span> <span class="o">=</span> <span class="kc">true</span><span class="o">)</span> +<span class="kd">class</span> <span class="nc">SolrConfiguration</span> <span class="o">{</span> + + <span class="nd">@Bean</span> + <span class="n">SolrServer</span> <span class="nf">solrServer</span><span class="o">()</span> <span class="o">{</span> + <span class="k">return</span> <span class="k">new</span> <span class="nf">HttpSolrServer</span><span class="o">(</span><span class="s">"http://localhost:8983/solr"</span><span class="o">);</span> + <span class="o">}</span> +<span class="o">}</span> + +<span class="nd">@SolrDocument</span><span class="o">(</span><span class="n">solrCoreName</span> <span class="o">=</span> <span class="s">"collection1"</span><span class="o">)</span> +<span class="kd">class</span> <span class="nc">ManagedProduct</span> <span class="o">{</span> + + <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> + <span class="nd">@Indexed</span><span class="o">(</span><span class="n">type</span> <span class="o">=</span> <span class="s">"text_general"</span><span class="o">)</span> <span class="n">String</span> <span class="n">name</span><span class="o">;</span> + <span class="nd">@Indexed</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">"cat"</span><span class="o">)</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">category</span><span class="o">;</span> +<span class="o">}</span> +</pre></div> + +<p>As always we are eager to hear from you! Reach out to us on <a href="https://twitter.com/SpringData">Twitter</a>, <a href="http://stackoverflow.com/tags/spring-data">Stackoverflow</a> or <a href="http://jira.spring.io">JIRA</a> to request new features, suggest improvements or report a bug.</p> + + + This Week in Spring - Tuesday October 14th, 2014 + + + + Josh Long + + tag:spring.io,2014-10-14:1789 + 2014-10-14T18:05:00Z + <p>Welcome to another installment of <em>This Week in Spring</em>! This week I've been at Silicon Valley Code Camp, JAX London and Geekout UK talking to developers about how to build scalable, microservice-centric <a href="http://start.spring.io">Spring Boot</a> applications on <a href="http://cloudfoundry.org/index.html">Cloud Foundry</a>. It's been a lot fun talking to enthusiastic developers (on both sides of the Atlantic!).</p> + +<p>Without further ado, let's get on with the roundup!</p> + +<ul> +<li>Spring Boot co-lead Phil Webb just announced the availability of <a href="https://spring.io/blog/2014/10/11/spring-boot-1-2-0-m2-available-now">Spring Boot 1.2.0.M2</a> which includes, among other things, auto-configuration for Jersey, log4j, <code>commons-dbcp</code> support, a smarter <em>disk usage</em> health indicator and improved RabbitMQ support</li> +<li>Spring and Groovy Tool Suite lead Martin Lippert <a href="https://spring.io/blog/2014/10/13/spring-tool-suite-and-groovy-grails-tool-suite-3-6-2-released">has just announced the latest and greatest release, 3.6.2</a>, which is a maintenance release that includes an update to the latest Eclipse Luna SR1 installation. </li> +<li>Also, Spring Boot co-lead <a href="https://spring.io/blog/2014/10/11/spring-boot-1-1-8-released">Phil Webb just announced the 1.1.8 release of the 1.1x line of Spring Boot</a> which includes a fix for the white-label error page cross-site scripting attack. </li> +<li>Federated security is an important part of any distributed, multi-client, (micro)service-oriented system. Spring Security and Spring Security OAuth, in particular, provide a compelling solution. Join the good Dr. Dave Syer for this <a href="https://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">upcoming webinar on microservice security using OAuth2</a> +</li> +<li>Matt Stine will be doing a webinar introducing <a href="https://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">how Pivotal Cloud Foundry and Spring Cloud make for a natural solution to building microservices</a>. Don't miss this one!</li> +<li>Atlanta, GA, USA Tuesday Oct 21, Learn about Spring, Microservices, and Cloud Foundry at a <a href="http://www.pivotal.io/platform-as-a-service/cloud-platform-roadshow/atlanta#cities">one day roadshow event</a> at Cox communications.</li> +<li>Munich, Germany, GA, Thursday Oct 23, Learn about Spring, Microservices, and Cloud Foundry at a <a href="http://www.pivotal.io/platform-as-a-service/cloud-platform-roadshow/munich">one day roadshow event</a> at EMC's office in Ismaning, Germany. </li> +<li>I hope you'll join the Vaadin team and I on October 23rd for a <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">look how to build Spring Boot-powered Vaadin applications</a>.</li> +<li>The <em>Java et Moi</em> blog has a nice (French language) post <a href="http://javaetmoi.com/2014/10/annotation-sessionattributes-modelattribute-spring-mvc/">on using Spring MVC's <code>@SessionAttribute</code> annotation</a><br> +</li> +<li>I <em>really</em> enjoyed this <a href="http://altfatterz.blogspot.com/2014/10/software-configuration-with-spring-boot.html">very thorough look at contributing configuration property values</a> to a Spring Boot application (as <code>--D</code> arguments, environment variables, values in a property file, and values inside of JNDI)</li> +<li>Sudhir Dharmadhikari has done a <em>very</em> <a href="http://iwaow.blogspot.com/2014/10/jhipster-super-baby-in-springroos-pouch.html">nice job introducing the <code>yeoman</code> code-generator based JHipster</a>, which builds on top of <a href="http://spring.io/projects/spring-boot">Spring Boot</a>.</li> +<li>Our pal Miroslav Kopecky is back, this <a href="http://java.dzone.com/articles/scala-4-spring-mvc-without-0">time with a nice post on using Spring MVC (in Spring 4) using Java configuration</a> (through Scala!)</li> +<li> +<a href="http://antirez.com/news/79">Redis Cluster is no longer vaporware</a>! Check out the details.</li> +<li> Biju Kunjummen has put together <a href="http://java.dzone.com/articles/spring-configuration-and">a very nice post on the two styles of Java configuration</a>: one where you declare dependencies as parameters to the <code>@Bean</code>-annotated bean definition method, and one where you simply reference the other bean by calling a method.<br> +</li> +<li>Check out this post on <a href="http://architects.dzone.com/articles/using-log4j2-slf4j-spring-4">avoiding dependency conflicts between Log4j2 and SLF4J</a> in a Spring application.</li> +<li>Check out this post by Daniel Murygin which includes a detailed walk-through <a href="http://murygin.wordpress.com/2014/10/13/rest-web-service-file-uploads-spring-boot/">on building a fairly non-trivial REST service (that even handles file-uploads!) and client application using Spring Boot</a>?<br> +</li> +</ul> + + + Spring Tool Suite and Groovy/Grails Tool Suite 3.6.2 released + + + + Martin Lippert + + tag:spring.io,2014-10-13:1788 + 2014-10-13T14:20:11Z + <p>Dear Spring Community,</p> + +<p>I am happy to announce the new release of our Eclipse-based tooling today: +The Spring Tool Suite (STS) 3.6.2 and the Groovy/Grails Tool Suite (GGTS) 3.6.2.</p> + +<p>This is a maintenance release that updates STS/GGTS to the just released Eclipse Luna SR1 release. This includes a number of fixes across the various projects that are included in the STS distribution, together with fixes for the Java8 compiler and tooling in Eclipse.</p> + +<p>To download the distributions, please go visit:</p> + +<ul> +<li>Spring Tool Suite: <a href="https://spring.io/tools/sts/all">https://spring.io/tools/sts/all</a> +</li> +<li>Groovy/Grails Tool Suite: <a href="https://spring.io/tools/ggts/all">https://spring.io/tools/ggts/all</a> +</li> +</ul> + +<p>Detailed new and noteworthy notes can be found here: <a href="http://docs.spring.io/sts/nan/v362/NewAndNoteworthy.html">STS/GGTS 3.6.2 New &amp; Noteworthy</a>.</p> + +<p>NOTE: +Both tool suites ship on top of the latest Eclipse Luna 4.4 SR1 release as 64bit and 32bit based zip files only. There will be no native installers for STS/GGTS anymore.</p> + +<p>Since the 3.6.0 release we shifted towards a slightly changed release schedule, shipping minor releases more frequently. Therefore 3.6.3 is scheduled to ship in December, followed by 3.6.4 in early March 2015, shortly after the Eclipse Luna SR2 release.</p> + +<p>Enjoy!</p> + + + Spring Boot 1.2.0.M2 Available Now + + + + Phil Webb + + tag:spring.io,2014-10-11:1786 + 2014-10-11T03:55:53Z + <p>I am pleased to announce that Spring Boot 1.2.0.M2 is available now in the <a href="http://repo.springsource.org/milestone">Spring milestone repository</a>. This release adds a number of improvements and new features over <a href="https://spring.io/blog/2014/09/08/spring-boot-1-2-0-m1-available-now">M1</a>. Highlights include:</p> + +<ul> +<li>Full configuration of Jackson <code>ObjectMapper</code> features from your <code>application.properties</code> file.</li> +<li>Auto-configuration for Jersey.</li> +<li>Support for Log4j2.</li> +<li>Support for commons-dbcp2.</li> +<li>A new "disk usage" health indicator.</li> +<li>Improved RabbitMQ auto-configuration.</li> +</ul> + +<p>For a complete list of changes, and for upgrade instructions, see the <a href="http://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.2-Release-Notes">Spring Boot 1.2 Release Notes</a> on the WIKI. The <a href="http://docs.spring.io/spring-boot/docs/1.2.0.M2/reference/htmlsingle/">reference documentation</a> also continues to be updated to cover the new features.</p> + +<p>Thanks again to everyone that has contributed to the release! Please give it a go and report any problems using <a href="http://github.com/spring-projects/spring-boot/issues">the project Issue tracker</a> page.</p> + + + Spring Boot 1.1.8 released + + + + Phil Webb + + tag:spring.io,2014-10-11:1785 + 2014-10-11T00:37:52Z + <p>Spring Boot 1.1.8 has been released and is available now from <a href="http://repo.spring.io/release">repo.spring.io</a> and <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.springframework.boot%22">Maven Central</a>. </p> + +<p>This maintenance release includes a <a href="https://github.com/spring-projects/spring-boot/commit/3135c7f8aeb30b71eccc02bb0bb3817132c41060">security patch</a> to the "white label error" page which prevents potential cross-site scripting attacks; as such it is a recommended upgrade for all Spring Boot users. For a complete list of changes please refer to the <a href="https://github.com/spring-projects/spring-boot/issues?q=milestone%3A1.1.8">issue tracker</a>.</p> + +<p><a href="http://projects.spring.io/spring-boot/">Project Page</a> | <a href="https://github.com/spring-projects/spring-boot">GitHub</a> | <a href="https://github.com/spring-projects/spring-boot/issues">Issues</a> | <a href="http://docs.spring.io/spring-boot/docs/1.1.8.RELEASE/reference/htmlsingle">Documentation</a></p> + + + Pivotal at Silicon Valley Code Camp 2014 + + + + Pieter Humphrey + + tag:spring.io,2014-10-10:1784 + 2014-10-10T10:24:00Z + <p>Are you heading to Silicon Valley Code Camp 2014?   If you are, we invite all of the Java community members to stop by the Pivotal Booth and talk to Pivotal engineers about the latest innovations in Java SE, in Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Cloud Foundry and Hadoop. The exhibit space is open Saturday 8:00am – 5:00pm, and Saturday from 8:30am to 3:30pm, so there should be plenty of time to get your questions answered.  See below for details about our sessions and awesome giveaways - come find us! </p> + +<p><strong>SATURDAY - OCTOBER 11, 2014            </strong><br> +9:45 AM </p> + +<ul> + <li>Josh Long — Spring advocate at Pivotal</li> + <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/building-bootiful-applications-with-spring-boot" target="_blank">Building "Bootiful Applications with Spring Boot </a></li> + <li>Room: 8401</li> +</ul> + +<p>11:45 AM </p> + +<ul> + <li>John Hann, — Pivotal</li> + <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/introducing-ravejs-zero-config-javascript-applications" target="_blank">Introducing Rave.js: Zero-config JavaScript Applications</a></li> + <li>Room: 8401</li> +</ul> + +<p>1:45 PM </p> + +<ul> + <li>Ilayaperumal Gopinathan — Pivotal</li> + <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/simplifying-big-data-development-using-spring-xd" target="_blank">Simplifying Big Data development at Spring XD</a></li> + <li> Room: 8403</li> +</ul> + +<p><strong>SUNDAY - OCTOBER 12, 2014</strong></p> + +<p>9:15 AM </p> + +<ul> + <li>Cornelia Davis — Platform Engineer at Pivotal</li> + <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/the-self-healing-elastic-runtime-that-is-cloud-foundry">The Self-healing, Elastic Runtime that is Cloud Foundry</a></li> + <li>Room: Room: 4302</li> +</ul> + +<p>10:45 AM</p> + +<ul> + <li>Cornelia Davis — Platform Engineer at Pivotal</li> + <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/running-your-spring-apps-in-the-cloud" target="_blank">Running Your Spring Apps in the Cloud</a></li> + <li>Room: 4302</li> +</ul> + +<p>Visit us at the Pivotal Code Camp booth for technical expert conversations on Cloud Foundry, Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Hadoop and much more. </p> + +<p>Also, don't miss the <a href="http://run.pivotal.io">Pivotal Web Services</a> Hoodie Push!  <a href="https://spring.io/guides/gs/rest-service/">Build a REST service with Spring Boot</a>, push it live to run.pivotal.io and get a hoodie!  You can do it ahead of time, and show it running to us, or use our laptops at the booth. </p> + +<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" target="_blank"><img border="0" width="215" height="254" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" style="max-width:100%;"></a></p> + +<p> </p> + +<p> </p> + +<p>Save the date for SpringOne2GX 2015!  We hope you will mark your calendar and join us again! SpringOne2GX 2015 will be held September 14 - 17, 2015 at the Marriott Marquis in Washington DC.</p> + + + This Week in Spring - October 7th, 2014 + + + + Josh Long + + tag:spring.io,2014-10-08:1783 + 2014-10-08T03:49:00Z + <p>Welcome to another installment of <em>This Week in Spring</em>! This week, I've been at the Couchbase Connect conference talking to developers about Spring Data Couchbase (and Spring Boot, Spring XD, Spring Session, and more..). Fun show, fun crowd! Next week, I'll be at <a href="http://jaxlondon.com/2014/speakers/josh-long">JAX London</a> and <a href="http://uk.geekout.ee/speakers/josh-long/">Geekout UK</a>, so be sure to say hi if you're around. </p> + +<p>Now, with that, let's get on to the roundup..</p> + +<ol> +<li>The good Dr. Pollack just announced <a href="http://spring.io/blog/2014/10/02/spring-xd-1-0-1-released">the 1.0.1 release of Spring XD</a>, the easiest way to build data-integration and ingestion solutions. It may be only a 1.0.1 release, but make no mistake: there are some very cool features in this release, including improved administrative and administrative UI features. </li> +<li>Federated security is an important part of any distributed, multi-client, (micro)service-oriented system. Spring Security and Spring Security OAuth, in particular, provide a compelling solution. Join the good Dr. Dave Syer for this <a href="https://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">upcoming webinar on microservice security using OAuth2</a> +</li> +<li>Matt Stine will be doing a webinar introducing <a href="https://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">how Pivotal Cloud Foundry and Spring Cloud make for a natural solution to building microservices</a>. Don't miss this one!</li> +<li> Spring and JavaScript ninja Brian Cavalier has written a <em>very</em> interesting post on some of <a href="http://github.com/spring-projects/spring-sync/">the work</a> we're doing towards enabling <a href="http://spring.io/blog/2014/10/08/streaming-json-patch-from-spring-to-a-react-ui">easier differential sync between JavaScript clients and services</a>. This post not only introduces all these exciting new stuff, but also builds on RaveJS, the Spring Boot-inspired approach to JavaScript.</li> +<li>I hope you'll join the Vaadin team and I on October 23rd for a <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">look how to build Spring Boot-powered Vaadin applications</a>.</li> +<li>Justin Lee Grant has put together <a href="http://www.justinleegrant.com/?p=489">a good introductory look at Spring Boot</a>.</li> +<li>Spring lead Juergen Hoeller just <a href="http://spring.io/blog/2014/10/01/spring-framework-4-1-1-released">announced the 4.1.1 release of Spring framework</a>. This release includes improved <code>Optional</code> handling, a Jackson <code>ObjectMapper</code> builder, some requested JDBC improvements, and much more. </li> +<li>The good Dr. Syer just announced <a href="http://spring.io/blog/2014/10/07/spring-cloud-1-0-0-m1-available-now">the first milestone release of the Spring Cloud project</a>. Spring Cloud provides primatives for building microservice and PaaS-centric applications. It builds on top of the Netflix OSS stack and Spring Boot.</li> +<li>Karthik Abram put together <a href="http://www.eclecticlogic.com/2014/09/01/classpath-scanning/">a nice post on a hidden gem in Spring: the <code>ClassPathScanningCandidateComponentProvider</code></a> class, which makes it easy to discover beans of a certain type. </li> +<li>Nicolas Lejeune has written up a fascinating look at how he managed <a href="http://labs.bsb.com/2014/09/turn-a-legacy-app-into-a-cf-service/">to convert a legacy application (it uses EJB3) and move it to a Cloud Foundry environment</a> </li> +<li>Our pal Toshiaki Maki put together <a href="http://github.com/making/spring-boot-blank">his ideal Spring Boot Maven archetype</a>, and <a href="http://twitter.com/making/status/519626091934134272">shared it</a>!<br> +</li> +<li>Are you a Groovy fan? (who isn't??) Check out Groovy project lead Guillaume LaForge's weekly roundup, <a href="http://t.co/AiDLC6novd"><em>This Week in Groovy</em></a>!</li> +<li>Do you want <a href="http://mikusa.blogspot.com/2014/08/debugging-java-applications-on.html">to debug applications deployed on Cloud Foundry</a>? Daniel Mikusa put together a very nice post explaining one approach. </li> +</ol> + + + Streaming JSON Patch from Spring to a React UI + + + + Brian Cavalier + + tag:spring.io,2014-10-07:1782 + 2014-10-08T01:47:03Z + <p>We're exploring ways to help developers create rich, modern front-ends that integrate easily with Spring back-ends. If you attended SpringOne this year, you've already seen some of the things we've been working on:</p> + +<ol> +<li> +<a href="https://speakerdeck.com/gregturn/springone2gx-2014-spring-data-rest-data-meets-hypermedia">Hypermedia support in Spring Data REST</a> presented by Greg Turnquist, Oliver Gierke, and Roy Clarkson</li> +<li> +<a href="http://www.slideshare.net/unscriptable/rave-js-springone-2gx-2014">RaveJS: Spring Boot concepts for JavaScript applications</a> by John Hann</li> +<li> +<a href="http://www.slideshare.net/briancavalier/differential-sync-and-json-patch-s2-gx-2014">Differential Synchronization and JSON Patch</a> by Craig Walls and me</li> +</ol><p>In short, We want to make it easy to communicate efficiently between a Spring back-end and a client and to easily integrate the best and most popular client-side technologies.</p> + +<h2> +<a name="user-content-react--streaming-updates" class="anchor" href="#react--streaming-updates" aria-hidden="true"><span class="octicon octicon-link"></span></a>React + streaming updates</h2> + +<p>JSON Patch is a format for sending incremental changes to structured data. I thought it would be interesting to try streaming updates in JSON Patch format via STOMP all the way out to a web UI.</p> + +<p>Craig Walls had already built a simple <a href="https://github.com/habuma/scores">football scores proof of concept</a>, using the new <a href="https://github.com/spring-projects/spring-sync/">Spring Sync</a> project to push score updates to a browser using JSON Patch over STOMP. I was able to take his POC, drop in RaveJS, add client-side reactive streams, and integrate the updates into a <a href="http://facebook.github.io/react/">React</a> UI component.</p> + +<p>You can find the <a href="https://github.com/briancavalier/scores">complete code on github in my rave-most-react branch</a>. The server is unchanged from Craig's original version. The <a href="https://github.com/briancavalier/scores/tree/rave-most-react/src/main/resources/public">web client</a> is where the action is. Have a look at the <a href="https://github.com/briancavalier/scores/blob/rave-most-react/src/main/resources/public/main.js">main.js to get an overall sense of the app</a> before we dive into some specifics.</p> + +<h2> +<a name="user-content-starting-out" class="anchor" href="#starting-out" aria-hidden="true"><span class="octicon octicon-link"></span></a>Starting out</h2> + +<p>I used <a href="https://github.com/RaveJS/rave">RaveJS</a> and npm to manage my client side dependencies, so my startup was simple:</p> + +<div class="highlight highlight-sh"><pre>&gt; <span class="nb">cd </span>src/main/resources/public + +&gt; npm init + +&lt;answer a few questions&gt; + +&gt; npm install --save rave most jiff react rave-load-jsx rave-node-process stompjs +</pre></div> + +<p>Then I just needed a single script tag in the existing HTML, and I was off to coding!</p> + +<div class="highlight highlight-html"><pre><span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"node_modules/rave/rave.js"</span><span class="nt">&gt;&lt;/script&gt;</span> +</pre></div> + +<h2> +<a name="user-content-introducing-mostjs" class="anchor" href="#introducing-mostjs" aria-hidden="true"><span class="octicon octicon-link"></span></a>Introducing most.js</h2> + +<p>Thanks to Craig, I already had a stream of updates (in JSON Patch format) flowing to the client over STOMP. I decided that the nicest way to work with the stream of patches would be to (surprise!) <em>actually use a stream</em>.</p> + +<p><a href="https://github.com/cujojs/most">Most.js</a> is cujoJS's new JavaScript reactive streams package. It provides a small, but powerful set of APIs for creating, transforming, and consuming event streams. I used it to wrap up the stompjs API.</p> + +<p>It turns out that there were two STOMP subscriptions: one that carried an initial, complete copy of all the score data, and another that carried all the subsequent changes. I was able to wrap both subscriptions up into a single reactive stream representing "the latest set of scores" by using <a href="https://github.com/cujojs/jiff">jiff.js</a> to apply the JSON Patches as they arrived.</p> + +<p>This bit of code creates a stream from a STOMP subscription to the initial data, takes the first event (a complete snapshot of all scores), and combines it with a second stream containing only JSON Patch updates to produce a view of the scores that changes over time.</p> + +<div class="highlight highlight-js"><pre><span class="kd">function</span> <span class="nx">getScoresStream</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> <span class="p">{</span> + <span class="c1">// Create a stream containing one full copy of the data, and</span> + <span class="c1">// flatMap that to a stream containing the time-varying</span> + <span class="c1">// current set of scores, by accumulating each patch</span> + <span class="c1">// and emitting the updated scores data.</span> + <span class="k">return</span> <span class="nx">getInitialDataStream</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> + <span class="p">.</span><span class="nx">flatMap</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span> + <span class="k">return</span> <span class="nx">getUpdatesStream</span><span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span> + <span class="p">});</span> +<span class="p">}</span> + +<span class="kd">function</span> <span class="nx">getInitialDataStream</span> <span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> <span class="p">{</span> + <span class="c1">// Await a copy of the data from the STOMP subscription</span> + <span class="c1">// that is sending the full scores data, then unsubscribe.</span> + <span class="k">return</span> <span class="nx">streamFromStompJson</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> + <span class="p">.</span><span class="nx">take</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> +<span class="p">}</span> + +<span class="kd">function</span> <span class="nx">getUpdatesStream</span> <span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span> + <span class="c1">// Incrementally accumulate patches from the STOMP subscription</span> + <span class="c1">// that is carrying JSON Patches onto the scores data to produce</span> + <span class="c1">// an updated view of the scores.</span> + <span class="k">return</span> <span class="nx">streamFromStompJson</span><span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> + <span class="p">.</span><span class="nx">startWith</span><span class="p">([])</span> + <span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">updateWithJsonPatch</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span> +<span class="p">}</span> +</pre></div> + +<p>Most.js also automatically cleans up underlying resources when streams end. It was easy to arrange to unsubscribe from the first subscription after an initial copy of the full scores data had arrived, leaving only one subscription: the changes.</p> + +<h2> +<a name="user-content-making-the-ui-with-react" class="anchor" href="#making-the-ui-with-react" aria-hidden="true"><span class="octicon octicon-link"></span></a>Making the UI with React</h2> + +<p>Now that I had a single most.js stream representing the latest scores, I created a <a href="https://github.com/briancavalier/scores/blob/rave-most-react/src/main/resources/public/Scoreboard.jsx">React component to display them</a>. I installed (see above) the <a href="https://github.com/KidkArolis/rave-load-jsx">rave-load-jsx extension</a>, a RaveJS extension created by a community member, which enables direct JSX component loading in RaveJS. All I had to do was create a Scoreboard.jsx file and start coding a simple React scoreboard component.</p> + +<p>React components have an internal <code>state</code> object containing the data that will be used to render the component. All I needed to do was pass the latest scores stream when creating the component, and then have the component observe the stream and update its <code>state</code>. The relevant bit of code is only a couple lines:</p> + +<div class="highlight highlight-js"><pre><span class="c1">// this.props.scores is the scores stream provided when the</span> +<span class="c1">// Scoreboard component is created</span> + +<span class="k">this</span><span class="p">.</span><span class="nx">props</span><span class="p">.</span><span class="nx">scores</span><span class="p">.</span><span class="nx">observe</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">scores</span><span class="p">)</span> <span class="p">{</span> + <span class="nx">self</span><span class="p">.</span><span class="nx">setState</span><span class="p">({</span> <span class="nx">scores</span><span class="o">:</span> <span class="nx">scores</span> <span class="p">});</span> +<span class="p">});</span> +</pre></div> + +<p>React took care of automatically keeping the DOM in sync with the <code>state</code>.</p> + +<h2> +<a name="user-content-from-bits-to-pixels" class="anchor" href="#from-bits-to-pixels" aria-hidden="true"><span class="octicon octicon-link"></span></a>From bits to pixels</h2> + +<p>This is admittedly a toy app. However, it shows quite a few powerful concepts working together in a very small space, with very little code: small, server-generated deltas flowing over STOMP + WebSocket, to a reactive stream on the client being observed by a React component. Changes are flowing from a Spring back-end through to the UI--bits to pixels, as it were.</p> + +<p>I hope this tiny app also provides a glimpse at the direction we're headed. We want to provide tools and client-side packages that help developers build rich, modern client applications that integrate with leading client-side technologies and Spring back-ends.</p> + + + Spring Cloud 1.0.0.M1 Available Now + + + + Dave Syer + + tag:spring.io,2014-10-07:1781 + 2014-10-07T13:25:00Z + <p><a href="http://projects.spring.io/spring-cloud">Spring Cloud</a> (the new umbrella project announced in September) has reached a milestone, its first, and fresh jars are available in the <a href="http://repo.spring.io/libs-milestone-local">repo.spring.io</a> repository. Spring Cloud is going to follow a "release train" model for releases, a bit like Spring Data, but we haven't got a cool name for this one yet, so it's just 1.0.0.M1. The modules that are part of this release are </p> + +<ul> +<li><p>Spring Cloud Config: Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring <code>Environment</code> but could be used by non-Spring applications if desired.</p></li> +<li><p>Spring Cloud Netflix: Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).</p></li> +<li><p>Spring Cloud Bus: An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events).</p></li> +<li><p>Spring Cloud Security: A set of primitives for building secure applications and services with minimum fuss.</p></li> +<li><p>Spring Cloud CLI: Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy.</p></li> +<li><p>Spring Cloud Starters: Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud.</p></li> +</ul><p>All of the above have the 1.0.0.M1 release tag, so a good starting point to try it out would be to <a href="http://projects.spring.io/spring-cloud/spring-cloud.html#_installation">install the CLI</a> and run Config Server with this code:</p> + +<div class="highlight highlight-groovy"><pre><span class="nd">@EnableConfigServer</span> +<span class="kd">class</span> <span class="nc">ConfigServer</span> <span class="o">{</span> +<span class="o">}</span> +</pre></div> + +<p>then hit <code>http://localhost:8080/foo/default</code> to see some property sources.</p> + +<p>The <a href="https://github.com/spring-cloud">code</a> is hosted on github, and community contributions are extremely welcome, so get on over there are check it out. There are some neat samples in a separate organization: <a href="https://github.com/spring-cloud-samples">spring-cloud-samples</a>, including a "scripts" project that has git submodules and scripts to get a complete demo system up and running as quickly as possible.</p> + + + Spring XD 1.0.1 released + + + + Mark Pollack + + tag:spring.io,2014-10-02:1780 + 2014-10-02T22:49:48Z + <p>On behalf of the Spring XD team, I am very pleased to announce the general availability of Spring XD 1.0.1! </p> + +<p>This release includes <a href="https://jira.spring.io/secure/ReleaseNote.jspa?projectId=11401&amp;version=14685">bug fixes and enhancements</a> as well as some new features:</p> + +<ul> +<li> +<a href="https://github.com/spring-projects/spring-xd/wiki/Application-Configuration#enabling-https">HTTPS access</a> and <a href="https://github.com/spring-projects/spring-xd/wiki/Application-Configuration#enabling-authentication">Authentication</a> to Admin Server</li> +<li> +<a href="https://github.com/spring-projects/spring-xd/wiki/AdminUI#containers">Cluster</a> and <a href="https://github.com/spring-projects/spring-xd/wiki/AdminUI#streams">Stream</a> views in UI</li> +<li>Configure a <a href="https://github.com/spring-projects/spring-xd/wiki/Modules#custom-module-registry">location for custom modules</a> +</li> +<li><a href="https://github.com/spring-projects/spring-xd/wiki/Sinks#null-sink">Null sink</a></li> +</ul><p>You can <a href="http://repo.spring.io/release/org/springframework/xd/spring-xd/1.0.1.RELEASE/spring-xd-1.0.1.RELEASE-dist.zip">download the zip distribution</a> or install on OSX <a href="https://github.com/spring-projects/spring-xd/wiki/Getting-Started#osx-homebrew-installation">using homebrew</a>. On RHEL/CentOs you can <a href="https://github.com/spring-projects/spring-xd/wiki/Getting-Started#redhatcentos-installation">install using yum</a>.</p> + +<p>Feedback is very important, so please get in touch with questions and comments via</p> + +<ul> +<li> +<a href="http://stackoverflow.com/questions/tagged/spring-xd">StackOverflow</a> <code>spring-xd</code> tag</li> +<li> +<a href="https://jira.spring.io/browse/XD/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel">Spring JIRA</a> or <a href="https://github.com/spring-projects/spring-xd/issues">GitHub Issues</a> +</li> +</ul> + + + Spring Framework 4.1.1 released + + + + Juergen Hoeller + + tag:spring.io,2014-10-01:1779 + 2014-10-01T13:15:00Z + <p>Dear Spring community,</p> + +<p>I'm pleased to announce that Spring Framework 4.1.1 is available now. As the <b>first maintenance release in the 4.1 line</b>, this release contains a wide range of fixes for regressions and other issues reported against 4.1 GA. A big thank you to all the issue reporters out there!</p> + +<p>4.1.1 also comes with a <b>selection of minor enhancements</b>, for example: consistent handling of Java 8's Optional type, a Jackson ObjectMapper builder class with refined defaults, some requested JDBC refinements, as well as <b>specific performance improvements</b>.</p> + +<p><a href="https://jira.spring.io/issues/?jql=project%20%3D%20SPR%20AND%20fixVersion%20%3D%204.1.1%20ORDER%20BY%20issuetype%20ASC">-&gt; List of resolved JIRA issues for Spring Framework 4.1.1</a></p> + +<p>We strongly recommend an immediate upgrade to 4.1.1 for all 4.1 GA users. The Spring Framework team is now working towards <b>Spring Framework 4.1.2 at the end of October</b>, which will be the foundation for the upcoming Spring Boot 1.2 GA release.</p> + +<p>On a related note, along with 4.1.2, we are preparing <b>Spring Framework 4.0.8 as the last 4.0.x maintenance release</b>. If there is anything you'd like to get fixed in the 4.0.x branch still, now is the time to raise it! Otherwise, please upgrade to 4.1.x for ongoing active maintenance.</p> + +<p>Cheers,</p> + +<p>Juergen</p> + + + This Week in Spring - September 30, 2014 + + + + Josh Long + + tag:spring.io,2014-10-01:1774 + 2014-10-01T03:20:00Z + <p>Welcome to another installment of <em>This Week in Spring!</em> This week <a href="http://spring.io/blog/2014/09/26/pivotal-at-javaone-2014">the Spring team is at JavaOne</a>! There's been, and will be, <em>lots</em> to see! We're also hanging out at the booth, talking to as many users as possible. Check out the link I just give listing all the cool Pivotal (and non-Pivotal) talks at JavaOne. (Ahem. Naturally, I personally would <em>love</em> it if you made <a href="http://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3693&amp;tclass=popup">my talk - <em>Spring4TW!</em> - tomorrow morning at 8:30am at Parc 55, Cyril Magnin II/III</a>!).</p> + +<p></p><p><a href="https://raw.githubusercontent.com/joshlong/meh/master/javaone2014-boot-twis.jpg" target="_blank"><img src="https://raw.githubusercontent.com/joshlong/meh/master/javaone2014-boot-twis.jpg" style="max-width:100%;"></a></p><p>In addition to IoT, Big Data, and Microservice demos using <a href="http://projects.spring.io/spring-cloud/">NetFlixOSS on Spring</a>, students were doing the coding challenge to build a <a href="https://spring.io/guides/gs/rest-service/">REST service with Spring Boot</a> and pushed to <a href="http://run.pivotal.io">Pivotal Web Services</a> in &lt; 15 minutes to get the <a href="http://preshavedyak.com/">preshavedyak hoodie</a> from American Apparel, and learning about the best PaaS for Java available on the market today; Java 8 / Tomcat 8 support was released just days ago, and there is strong support for Spring, Groovy and Grails.</p><ul> +<li>I really liked Michael Plod's <a href="http://spring.io/blog/2014/09/26/webinar-replay-why-i-recommend-spring"><em>Why I Recommend Spring</em> webinar</a>, now available online as a replay</li> +<li>Last week, Activiti BPMN2 engine co-founder Joram Barrez and I gave a talk on <a href="http://spring.io/blog/2014/09/26/webinar-replay-process-driven-spring-applications-with-activiti">how to build process (read: workflow) centric Spring applications</a>, also now available online. </li> +<li>Tuesday, Oct 21st, 2014 join <a href="https://twitter.com/mstine">Matt Stine</a> for microservice architecture series #2: <a href="http://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">Architecting for Continuous Delivery: Microservices with Pivotal CF and Spring Cloud</a> +</li> +<li>Thursday, October 23, 2014, 2014 <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">Building “Bootful†UIs with Spring Boot and Vaadin</a> +</li> +<li>Tuesday, November 4, 2014 - microservice architecture series #3 - Join <a href="https://twitter.com/david_syer">Dr. Dave Syer</a> on <a href="http://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">Security for Microservices with Spring and OAuth2</a> +</li> +<li>Missed microservice architecture #1? Catch the replay of <a href="http://spring.io/blog/2014/09/17/webinar-replay-building-bootiful-microservices-with-spring-boot">Building "Bootiful" Microservices with Spring Boot</a> on the Spring Developer Channel</li> +<li> +<a href="http://spring.io/blog/2014/09/26/spring-boot-1-1-7-released">Spring Boot 1.1.7 is now available</a>! </li> +<li> +<a href="http://raymondhlee.wordpress.com/2014/09/20/setup-spring-security-with-active-directory-ldap-in-spring-boot-web-application/">Setup Spring Security with Active Directory LDAP in Spring Boot Web Application</a> (I <em>just</em> got asked about this at the Spring BOF yesterday!)</li> +<li>There's been an interesting debate on microservices recently. <a href="http://blog.cleancoder.com/uncle-bob/2014/09/19/MicroServicesAndJars.html">"Uncle" Bob Martin has written up a post claiming that <code>.jar</code>s and Ruby <code>gem</code>s give you the same benefit of microservices</a>. There's a <a href="http://www.giorgiosironi.com/2014/09/microservices-are-not-jars.html">great rebuttal (which I happen to agree with..) by Giorgio Sironi on his blog</a>. There's even a nice wrapup of <a href="http://www.infoq.com/news/2014/09/microservices-shared-libraries?utm_source=infoq&amp;utm_medium=popular_links_homepage">the whole discussion on InfoQ</a>.</li> +<li>I really dig <a href="http://blog.pivotal.io/cloud-foundry-pivotal/case-studies-2/platform-wind-tunnel-part-i-heroku">Matt Stine's <em>wind tunnel</em> comparison of PaaSes</a>. Up first: Heroku. I can't wait to see subsequent posts in the series!</li> +<li>This post on using Spring Data Redis was published (and included in <em>TWiS</em>..) last year, <a href="http://www.ibm.com/developerworks/library/os-springredis/index.html">but it came up again and I still thnk it's a worthy read</a> </li> +<li>The eHarmony blog has a nice post on <a href="http://www.eharmony.com/engineering/spring-batch-admin-the-tricky-parts/#.VCtPFildUpg">how to setup Spring Batch Admin (the tricky parts..)</a> +</li> +<li>In the <em>you have to see it to beleive it</em> department, did you know there's a <a href="http://bitbucket.org/sglienke/spring4d">Spring for Delphi (Spring4D) project</a>? There are Spring-inspired C++, ColdFusion, JavaScript, .NET, Python, and numerous others. Cool to add this to the list.</li> +<li>The Intertech blog has <a href="http://www.intertech.com/Blog/spring-integration-tutorial-part-7-service-activators/">another installment on their <em>epic</em> Spring Integration tutorial</a>. This one's on <em>service activators</em> - basically the Spring Integration escape-hatch so you can call regular Java objects.</li> +<li>Benjamin Ball has a great <a href="http://java.dzone.com/articles/getting-started-rabbitmq-and">writeup on using RabbitMQ and Spring</a> </li> +<li>Yashwant Chavan has a nice post on building a simple <a href="http://www.technicalkeeda.com/spring/spring-boot-mvc-example">Spring Boot (with Spring MVC) example and editing it in Eclipse</a>. </li> +<li>Our pals at Codecentric are at it again! They've just released <a href="http://blog.codecentric.de/en/2014/09/spring-boot-admin-first-official-release/">their first cut of their <em>Spring Boot Admin</em></a>. This looks like something that would fit nicely in the <a href="http://github.com/spring-cloud/">Spring Cloud</a> project... </li> +<li> +<a href="http://prezi.com/ob4vxjmj_h1f/spring-boot/">This has to be one of the coolest Spring Boot presentations, ever</a>! Careful, I don't recommend watching it full-screen if you get motion sickness! :)</li> +<li>Are you stuck on Apache CXF but still want first-class security? This post <a href="http://java.dzone.com/articles/embedded-jetty-and-apache-cxf">looks at how to plugin Spring Security on top of CXF in minutes</a> </li> +<li>Biju Kunjummen did a nice job <a href="http://java.dzone.com/articles/spring-1">clarifying the differences between Spring's <code>WebApplicationInitializer</code> and <code>ApplicationContextInitializer</code></a> +</li> +</ul> + + + Webinar: Architecting for Continuous Delivery: Microservices with Pivotal CF and Spring Cloud + + + + Pieter Humphrey + + tag:spring.io,2014-10-01:1776 + 2014-10-01T02:20:00Z + <p>Speaker: Matt Stine, Pivotal </p> + +<p>Join Matt Stine to hear how you can architect systems that are optimized for continuous delivery, allowing you to innovate and deliver value faster and safer. Microservices, Pivotal CF, and Spring Cloud combine to create an operationalized architecture that enables enterprises to continuously deliver value at scale through rapid, iterative development, and to meet the needs of a mobile-first world.</p> + +<p>Tuesday, Oct 21st, 2014 3:00PM BST (London GMT+01:00) <a href="http://connect.pivotal.io/OSS_Webinar_MicroserviceswithPivotalCFandSpringCloud7AM_Register.html">Register</a></p> + +<p>Tuesday, Oct 21st, 2014 10:00AM PDT (San Francisco GMT-07:00) <a href="http://connect.pivotal.io/OSS_Webinar_MicroserviceswithPivotalCFandSpringCloud10AM_Register.html">Register</a></p> + + + Webinar: Building “Bootful†UIs with Spring Boot and Vaadin + + + + Pieter Humphrey + + tag:spring.io,2014-10-01:1777 + 2014-10-01T01:20:00Z + <p>Speaker: Josh Long, Pivotal and Vaadin</p> + +<p> It's been a long day, but you've done it: you've got a Spring Boot powered backend and now you need to build the UI that'll power the workforce and deliver next week. Vaadin, a UI framework that marries the ease of use of server-side Java and the rich, dynamic nature of client-side JavaScript, integrates well with Spring Boot and offers UI polish that would be hard to secure any other way. Join Spring developer advocate Josh Long and Vaadin evangelists for a look at how Vaadin and Spring Boot can get you to production quicker, and easier.</p> + +<p>Thursday, October 23, 2014, 2014 3:00PM BST (London GMT+01:00) <a href="http://connect.pivotal.io/OSS_Webinar_BuildingBootfulUIswithSpringBootandVaadin7AM_Register.html">Register</a></p> + +<p>Thursday, October 23, 2014 10:00AM PDT (San Francisco GMT-07:00) <a href="http://connect.pivotal.io/OSS_Webinar_BuildingBootfulUIswithSpringBootandVaadin10AM_Register.html">Register</a></p> + + + Webinar: Security for Microservices with Spring and OAuth2 + + + + Pieter Humphrey + + tag:spring.io,2014-10-01:1778 + 2014-10-01T01:10:00Z + <p>Speaker: Dave Syer</p> + +<p>Security for Microservices with Spring and OAuth2 OAuth2 is a lightweight security protocol that is well-suited for use with HTTP, the protocol at the heart of many modern architectures. Spring Security OAuth2 has a load of new features, not the least of which being the `@Configuration` support in version 2.0. Combine these with Spring Boot and you have a platform which can get you a secure HTTP service application in about 20 lines of code. This presentation shows how the combination of rapid development and production-ready features in the modern Spring stack are a perfect mixture for developing secure components in a system composed of microservices. We explore the new features in Spring OAuth2, guide you through the choice of which to use and when, and show how easy they are to enable quickly.</p> + +<p>Tuesday, November 4, 2014 3:00PM GMT (London GMT) <a href="http://connect.pivotal.io/OSS_Webinar_SecurityforMicroserviceswithSpringandOAuth2_7AM_Register.html">Register</a></p> + +<p>Tuesday, November 4, 2014 10:00AM PST (San Francisco GMT-08:00) <a href="http://connect.pivotal.io/OSS_Webinar_SecurityforMicroserviceswithSpringandOAuth2_10AM_Register.html">Register</a></p> + + + Webinar Replay: Why I Recommend Spring + + + + Pieter Humphrey + + tag:spring.io,2014-09-26:1773 + 2014-09-26T14:03:00Z + <p>Speaker: Michael Plod</p> + +<p>Slides: <a href="https://speakerdeck.com/mploed/pivotal-webinar-why-do-i-recommend-spring">https://speakerdeck.com/mploed/pivotal-webinar-why-do-i-recommend-spring</a></p> + +<p>Is Spring the new legacy as quite a few people tell you on their blogs? I disagree on many levels. Throughout this session I will holistically detail without any polemics why I do recommend using the Spring Framework and its ecosystem. Aspects that will be covered include: operational impacts, ecosystem, coding and road maps. This presentation is aimed at IT managers, Architects and Developers alike.</p> + +<p>Learn more about Spring IO: <a href="http://spring.io">http://spring.io</a></p> + +<p>Learn more about Spring IO Platform: <a href="http://spring.io/platform">http://spring.io/platform</a></p> + +<p></p><iframe width="420" height="315" src="//www.youtube.com/embed/z1rpWpSKtT8" frameborder="0" allowfullscreen></iframe> + + + Webinar Replay: Process Driven Spring Applications with Activiti + + + + Pieter Humphrey + + tag:spring.io,2014-09-26:1772 + 2014-09-26T13:56:00Z + <p>Speakers: Josh Long and Joram Barrez, Activiti </p> + +<p>Slides: <a href="https://speakerdeck.com/joshlong/process-driven-applications-with-spring-boot">https://speakerdeck.com/joshlong/process-driven-applications-with-spring-boot</a> </p> + +<p>Today's applications are complex, distributed systems that - taken together - produce results. Tracking the flow of work through that system, however, becomes increasingly more painful as automated- and human-driven tasks are integrated into business processes. Business can't react to what it can't see. Business can't measure what it can't see. "Workflow" describes the sequence of processes through which a piece of work passes from initiation to completion. Workflow systems, like Activiti, describe and then execute these processes. Activiti is an open-source, Apache 2-licensed workflow engine that works with Spring and Spring Boot. In this webinar, join Spring Developer Advocate Josh Long and Activiti-ninja Joram Barrez for a look at how to distill, describe and reuse complex business processes using Spring (and Spring Boot) and Activiti. </p> + +<p>Learn more about Spring Boot: <a href="http://projects.spring.io/spring-boot">http://projects.spring.io/spring-boot</a> </p> + +<p>Learn more about Activiti below! </p> + +<p>Activiti project page: <a href="http://activiti.org/">http://activiti.org/</a> </p> + +<p>Joram's blog: <a href="http://jorambarrez.com/blog">http://jorambarrez.com/blog</a> </p> + +<p>Activiti documentation: <a href="http://activiti.org/userguide/index.html">http://activiti.org/userguide/index.html</a> </p> + +<p>Activiti Github: <a href="https://github.com/Activiti/Activiti">https://github.com/Activiti/Activiti</a></p> + +<p></p><iframe width="420" height="315" src="//www.youtube.com/embed/0PV_8Lew3vg" frameborder="0" allowfullscreen></iframe> + + + Pivotal at JavaOne 2014 + + + + Pieter Humphrey + + tag:spring.io,2014-09-25:1770 + 2014-09-26T05:56:00Z + <p>Are you heading to JavaOne 2014?   If you are, we invite all of the Java community members to stop by the Pivotal Booth (Booth Number 5201) and talk to Pivotal engineers about the latest innovations in Java SE, in Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Cloud Foundry and Hadoop. The exhibit space is open Monday, Tuesday from 9:30am – 5:30pm, and Wednesday from 9:30am to 4:30pm, so there should be plenty of time to get your questions answered.  See below for a map and booth details about our giveaways - come find us!  Lots of great stuff at the booth.</p> + +<p>Pivotal technologists are also presenting a lot of sessions as well so be sure to add the following talks to your session builder and reserve a seat:<br> +            <br> +Josh Long — Spring advocate at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3868&amp;tclass=popup" target="_blank">The Spring BOF [BOF3868]</a></li> + <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3693&amp;tclass=popup" target="_blank">Spring 4TW! [CON3693]</a></li> +</ul><p>Cornelia Davis — Platform Engineer at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=4327&amp;tclass=popup" target="_blank">Running Your Spring Apps in the Cloud [CON4327]</a></li> +</ul><p>John Field — Solutions Architect at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3478&amp;tclass=popup" target="_blank">Open Source Identity and Access Management Expert Panel, Part 3 [BOF3478]</a></li> + <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3479&amp;tclass=popup" target="_blank">The Anatomy of a Secure Web Application Using Java [CON3479]</a></li> +</ul><p>Guillaume Laforge — Groovy project manager at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=2939&amp;tclass=popup" target="_blank">Script Bowl 2014: The Battle Rages On [CON2939]</a></li> + <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=5996&amp;tclass=popup" target="_blank">Groovy in 2014 and Beyond [CON5996]</a></li> + <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=5839&amp;tclass=popup" target="_blank">Groovy in the Light of Java 8 [CON5839]</a></li> +</ul><p>Martin Lippert - Principal Software Engineer at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=1739&amp;tclass=popup" target="_blank">Connecting the Eclipse IDE to the Cloud-Based Era of Developer Tooling [CON1739]</a></li> +</ul><p>Oliver Gierke - Spring Data Project Lead at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=6071&amp;tclass=popup" target="_blank">REST Assured: Hypermedia APIs with Spring MVC [CON6071]</a></li> +</ul><p>Cédric Champeau — Senior software engineer in the Groovy team at Pivotal</p> +<ul> +<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=2425&amp;tclass=popup" target="_blank">Rethinking API Design with Groovy Traits [CON2425]</a></li> +</ul><p>Interesting non-Pivotal Sessions</p> +<p><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=1764" target="_blank">Groovy and Grails Puzzlers: As Usual—Traps, Pitfalls, and End Cases[CON1764]</a> <br><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=4952" target="_blank">Microservices on the JVM: A Practical Overview [CON4952]</a></p> +<p><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=9447" target="_blank">Use Java, the Spring Framework, and Oracle Tuxedo to Extend Existing C/C++/COBOL Apps[HOL9447]</a> <br></p><p>Visit us at the booth for technical expert conversations on Cloud Foundry, Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Hadoop and much more. We'll have great demos in the booth about:</p> +<ul> +<li> Java EE and PaaS with <a href="http://www.pivotal.io/platform-as-a-service/pivotal-cf">Cloud Foundry</a> via JBoss and WebLogic Buildpack demos</li> + + <li>Internet of Things, Hadoop with <a href="http://projects.spring.io/spring-xd">Spring XD</a> Demos</li> + <li> +<a href="http://microservices.io">Microservice Architecture</a> and <a href="http://www.pivotal.io/platform-as-a-service/pivotal-cf">PaaS</a> with <a href="http://projects.spring.io/spring-boot">Spring Boot</a>, <a href="http://projects.spring.io/spring-cloud">Spring Cloud</a> Demos</li> +</ul><p><a href="http://run.pivotal.io">Pivotal Web Services</a> Hoodie Push!  <a href="https://spring.io/guides/gs/rest-service/">Build a REST service with Spring Boot</a>, push it live to run.pivotal.io and get a hoodie!  You can do it ahead of time, and show it running to us, or use our laptops at the booth. </p> +<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" target="_blank"><img border="0" width="215" height="254" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" style="max-width:100%;"></a></p> +<p> </p> +<p> </p> +<p>Save the date for SpringOne2GX 2015!  We hope you will mark your calendar and join us again! SpringOne2GX 2015 will be held September 14 - 17, 2015 at the Marriott Marquis in Washington DC.</p> +<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/javaone_booth_pivotal.PNG" target="_blank"><img border="0" width="624" height="398" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/javaone_booth_pivotal.PNG" style="max-width:100%;"></a></p> +<p><a href="https://github.com/pieterhumphrey/springio_website_images/blob/master/javaone_booth_pivotal2.PNG" target="_blank"><img src="https://github.com/pieterhumphrey/springio_website_images/raw/master/javaone_booth_pivotal2.PNG" width="577" height="441" style="max-width:100%;"></a></p> +<p><br></p> + + + Spring Boot 1.1.7 released + + + + Phil Webb + + tag:spring.io,2014-09-26:1771 + 2014-09-26T04:56:15Z + <p>Spring Boot 1.1.7 has been released and is available now from <a href="http://repo.spring.io/release">repo.spring.io</a> and <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.springframework.boot%22">Maven Central</a>. </p> + +<p>This maintenance release is a recommended upgrade for all Spring Boot users. For a complete list of changes please refer to the <a href="https://github.com/spring-projects/spring-boot/issues?q=milestone%3A1.1.7">issue tracker</a>.</p> + +<p><a href="http://projects.spring.io/spring-boot/">Project Page</a> | <a href="https://github.com/spring-projects/spring-boot">GitHub</a> | <a href="https://github.com/spring-projects/spring-boot/issues">Issues</a> | <a href="http://docs.spring.io/spring-boot/docs/1.1.7.RELEASE/reference/htmlsingle">Documentation</a></p> + + + Demo: IoT Realized with Spring XD - The Connected Car + + + + Pieter Humphrey + + tag:spring.io,2014-09-25:1769 + 2014-09-24T20:59:00Z + <p>Speaker: Derek Beauregard +Contributors: Phil Berman, Darrel Sharpe, Michael Minella +In this demo we will explore the power of Spring XD in the context of the Internet of Things (IoT). We will look at a solution developed with Spring XD to stream real time analytics from a moving car using open standards. Ingestion of the real time data (location, speed, engine diagnostics, etc), analyzing it to provide highly accurate MPG and vehicle range prediction, as well as providing real time dashboards will all be covered. Watch this demo to get a sense of how Spring XD can serve as a critical building block for the IoT.</p> + +<iframe width="420" height="315" src="//www.youtube.com/embed/qkm2GV57hzY" frameborder="0" allowfullscreen></iframe> + + + diff --git a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml new file mode 100644 index 000000000000..f87bdf6f7a2a --- /dev/null +++ b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml @@ -0,0 +1,291 @@ + + + + SpringSource Tool Suites Updates + http://www.springsource.com/products/sts + This feeds imforms about important updates relevant to users of STS. + Feeder 2.0.7(1195) http://reinventedsoftware.com/feeder/ + http://blogs.law.harvard.edu/tech/rss + en-us + sts@springsource.com + Mon, 13 Oct 2014 10:38:33 +0100 + Mon, 13 Oct 2014 10:38:33 +0100 + + + + + + Thanks for installing STS/GGTS 3.6.2 + http://spring.io/tools +
+

Please review the following documents:

+
  • 3.6.2 New & Noteworthy
  • ]]> + Mon, 13 Oct 2014 12:13:33 +0100 + version=[3.6.2.201410090827-RELEASE,3.6.3) + + thanks-for-installing-sts-362 + + + + STS/GGTS 3.6.2 has been released + http://spring.io/tools +

    Pivotal has released an update to Spring Tool Suite (STS) and Groovy/Grails Tool Suite (GGTS), the best Eclipse-powered development environment for building Spring, Groovy, and Grails powered enterprise application.

    It is recommend to update as soon as possible.

    +

    Please review the following documents:

    +
  • 3.6.2 New & Noteworthy
  • ]]>
    + Mon, 13 Oct 2014 12:12:33 +0100 + version=[0,3.6.2.201410090827-RELEASE) + severity=important + sts-362-released +
    + + + + Cloud Foundry Eclipse 1.7.1 released + http://www.cloudfoundry.com +

    Pivotal has released Cloud Foundry Eclipse version 1.7.1 which features various application deployment and home page navigation improvements, and a new Cloud Routes wizard for browsing and deleting application routes. Java 7 is a required Execution Environment.

    ]]>
    + Tue, 16 Sep 2014 10:38:33 +0100 + + + bundle=!org.cloudfoundry.ide.eclipse.feature.group + cloud-foundry-integration-171-released +
    + + + + + + Patch released to fix a Xerces classloading issue + https://issuetracker.springsource.com/browse/STS-1672 +

    SpringSource has just published a patch to fix a severe issue in STS that causes parsing of Spring XML files to fail with a Xerces classloading issue.

    It is recommend to update as soon as possible. The feature patch is available from the STS Dashboard -> Extensions tab.

    +

    Get to get more details about the issue please read the following bug entries:

    +
  • Issue in the STS JIRA
  • +
  • Community forum discussion
  • We apologize that this patch did not make it into the 2.6.0 release of STS.

    ]]>
    + Mon, 21 Mar 2011 10:38:33 +0100 + version=[2.6.0.201103160035-RELEASE,2.7.0.201105101000-M1) + severity=important + bundle=!org.springframework.ide.eclipse.patch.feature.feature.group + patch-STS1672-released +
    + + + + + + + + + + + + diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 000000000000..c51ff745b6c9 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1 @@ +org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/RemoteSystemsTempFiles/.project b/RemoteSystemsTempFiles/.project new file mode 100644 index 000000000000..5447a64fa9d0 --- /dev/null +++ b/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/handling-spring-static-resources/.classpath b/handling-spring-static-resources/.classpath new file mode 100644 index 000000000000..ceb436dc822c --- /dev/null +++ b/handling-spring-static-resources/.classpath @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/handling-spring-static-resources/.project b/handling-spring-static-resources/.project new file mode 100644 index 000000000000..3d1ebc3a9581 --- /dev/null +++ b/handling-spring-static-resources/.project @@ -0,0 +1,53 @@ + + + handling-spring-static-resources + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.hibernate.eclipse.console.hibernateBuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.jsdt.core.jsNature + org.hibernate.eclipse.console.hibernateNature + + diff --git a/handling-spring-static-resources/.springBeans b/handling-spring-static-resources/.springBeans new file mode 100644 index 000000000000..dd8f096d1da9 --- /dev/null +++ b/handling-spring-static-resources/.springBeans @@ -0,0 +1,16 @@ + + + 1 + + + + + + + + + src/main/webapp/WEB-INF/mvc-servlet.xml + + + + diff --git a/handling-spring-static-resources/pom.xml b/handling-spring-static-resources/pom.xml new file mode 100644 index 000000000000..fb29bf1a3d23 --- /dev/null +++ b/handling-spring-static-resources/pom.xml @@ -0,0 +1,163 @@ + + + 4.0.0 + org.baeldung + handling-spring-static-resources + handling-spring-static-resources + war + 1.0.0-BUILD-SNAPSHOT + + 1.7 + 4.1.0.RELEASE + 3.2.0.RELEASE + 1.8.1 + 1.6.1 + + 2.3.2-b01 + + + + + org.springframework + spring-context + 4.1.0.RELEASE + + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + org.springframework.security + spring-security-config + 3.2.5.RELEASE + runtime + + + org.springframework + spring-context-support + 4.1.0.RELEASE + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + runtime + + + org.slf4j + slf4j-log4j12 + ${org.slf4j-version} + runtime + + + log4j + log4j + 1.2.16 + runtime + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + + + javax.servlet.jsp + javax.servlet.jsp-api + ${javax.servlet.jsp-api.version} + + + javax.servlet + jstl + 1.2 + + + + org.springframework.security + spring-security-taglibs + 3.2.5.RELEASE + + + + com.fasterxml.jackson.core + jackson-databind + 2.4.1 + + + + + + + javax.validation + validation-api + 1.0.0.GA + + + org.hibernate + hibernate-validator + 4.1.0.Final + + + + + joda-time + joda-time + 2.3 + + + + + com.github.jknack + handlebars + 1.3.2 + + + + org.springframework.security + spring-security-web + ${org.springframework.security-version} + + + + + + + handling-spring-static-resources + + + src/main/resources + true + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/handling-spring-static-resources/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java new file mode 100644 index 000000000000..45ce91adc889 --- /dev/null +++ b/handling-spring-static-resources/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java @@ -0,0 +1,62 @@ +package org.baeldung.security; + +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.WebAttributes; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + handle(request, response, authentication); + HttpSession session = request.getSession(false); + if (session != null) { + session.setMaxInactiveInterval(30); + } + clearAuthenticationAttributes(request); + } + + protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { + String targetUrl = determineTargetUrl(authentication); + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + + redirectStrategy.sendRedirect(request, response, targetUrl); + } + + protected String determineTargetUrl(Authentication authentication) { + + return "/home.html"; + + } + + protected void clearAuthenticationAttributes(HttpServletRequest request) { + HttpSession session = request.getSession(false); + if (session == null) { + return; + } + session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + } + + public void setRedirectStrategy(RedirectStrategy redirectStrategy) { + this.redirectStrategy = redirectStrategy; + } + + protected RedirectStrategy getRedirectStrategy() { + return redirectStrategy; + } +} \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/java/org/baeldung/spring/AppConfig.java b/handling-spring-static-resources/src/main/java/org/baeldung/spring/AppConfig.java new file mode 100644 index 000000000000..c379d2004718 --- /dev/null +++ b/handling-spring-static-resources/src/main/java/org/baeldung/spring/AppConfig.java @@ -0,0 +1,20 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan(basePackages = { "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) +@Import({ MvcConfig.class, SecSecurityConfig.class }) +@PropertySource("classpath:application.properties") +public class AppConfig { + + @Bean + public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } +} diff --git a/handling-spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java b/handling-spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java new file mode 100644 index 000000000000..bd874a6e67fd --- /dev/null +++ b/handling-spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java @@ -0,0 +1,109 @@ +package org.baeldung.spring; + + +import java.util.Locale; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ReloadableResourceBundleMessageSource; +import org.springframework.core.env.Environment; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.i18n.CookieLocaleResolver; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import org.springframework.web.servlet.resource.GzipResourceResolver; +import org.springframework.web.servlet.resource.PathResourceResolver; +import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" }) +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { + @Autowired + Environment env; + + public MvcConfig() { + super(); + } + + // API + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + registry.addViewController("/login.html"); + registry.addViewController("/home.html"); + + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + return bean; + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + //For examples using Spring 4.1.0 + if((env.getProperty("resource.handler.conf")).equals("4.1.0")){ + registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver()); + registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver()); + registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver()); + registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/"). + setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()); + } + //For examples using Spring 4.0.7 + else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")){ + registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/", "classpath:/other-resources/"); + registry.addResourceHandler("/files/**") + .addResourceLocations("file:/Users/Elena/"); + + } + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); + localeChangeInterceptor.setParamName("lang"); + registry.addInterceptor(localeChangeInterceptor); + } + + @Bean + public ResourceUrlEncodingFilter resourceUrlEncodingFilter() { + ResourceUrlEncodingFilter filter = new ResourceUrlEncodingFilter(); + + return filter; + } + + @Bean + public LocaleResolver localeResolver() { + CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver(); + cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH); + return cookieLocaleResolver; + } + + @Bean + public MessageSource messageSource() { + ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); + messageSource.setBasename("classpath:messages"); + messageSource.setUseCodeAsDefaultMessage(true); + messageSource.setDefaultEncoding("UTF-8"); + messageSource.setCacheSeconds(0); + return messageSource; + } + +} \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/handling-spring-static-resources/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 000000000000..d51d0e9a5070 --- /dev/null +++ b/handling-spring-static-resources/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,14 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/handling-spring-static-resources/src/main/java/org/baeldung/web/controller/HomeController.java b/handling-spring-static-resources/src/main/java/org/baeldung/web/controller/HomeController.java new file mode 100644 index 000000000000..aa2b9f63fcd0 --- /dev/null +++ b/handling-spring-static-resources/src/main/java/org/baeldung/web/controller/HomeController.java @@ -0,0 +1,35 @@ +package org.baeldung.web.controller; + +import java.io.IOException; +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.context.request.WebRequest; + +@Controller +public class HomeController { + + + + @Autowired + Environment env; + + + @RequestMapping(value = "/home", method = RequestMethod.GET) + public String showHome(WebRequest request, Model model, Locale locale) throws IOException { + + Date date = new Date(); + DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); + + String formattedDate = dateFormat.format(date); + model.addAttribute("serverTime", formattedDate ); + return "home"; + } + +} diff --git a/handling-spring-static-resources/src/main/resources/application.properties b/handling-spring-static-resources/src/main/resources/application.properties new file mode 100644 index 000000000000..07fd88113af9 --- /dev/null +++ b/handling-spring-static-resources/src/main/resources/application.properties @@ -0,0 +1,6 @@ +################### App Version ########################## +app.version=de4db33lzbl +spring.profiles.active=dev +################### Resource Handler Configuration ########################## +resource.handler.conf=4.1.0 +###resource.handler.conf=4.0.7### \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/resources/logback.xml b/handling-spring-static-resources/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/handling-spring-static-resources/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/resources/messages_en.properties b/handling-spring-static-resources/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..7db64bdff0ff --- /dev/null +++ b/handling-spring-static-resources/src/main/resources/messages_en.properties @@ -0,0 +1,42 @@ +message.username=Username required +message.password=Password required +message.unauth=Unauthorized Access !! +message.badCredentials=Invalid Username or Password +message.sessionExpired=Session Timed Out +message.logoutError=Sorry, error logging out +message.logoutSucc=You logged out successfully +message.regSucc=You registered successfully. We will send you a confirmation message to your email account. +message.regError=An account for that username/email already exists. Please enter a different username. +message.lastName=Last name is required +message.firstName=First name required +message.badEmail=Invalid email address +label.user.email=Email: +label.user.firstName=First name: +label.user.lastName=Last name: +label.user.password=Password: +label.user.confirmPass=Confirm password +label.form.submit=Submit +label.form.title=Registration Form +label.form.loginLink=Back to login +label.login=Login here +label.form.loginTitle=Login +label.form.loginEmail=Email +label.form.loginUsername=Username +label.form.loginPass=Password +label.form.loginEnglish=English +label.form.loginSpanish=Spanish +label.form.loginSignUp=Sign up +ValidEmail.user.email=Invalid email address! +UniqueUsername.user.username=An account with that username/email already exists +NotNull.user.firstName=First name required +NotEmpty.user.firstName=First name required +NotNull.user.lastName=Last name required +NotEmpty.user.lastName=Last name required +NotNull.user.username=Username(Email) required +NotEmpty.user.username=Username(Email) required +NotNull.user.password=Password required +NotEmpty.user.password=Password required +NotNull.user.matchingPassword=Required +NotEmpty.user.matchingPassword=Required +PasswordMatches.user:Password does not match! +Email.user.email=Invalid Username (Email) \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/resources/messages_es_ES.properties b/handling-spring-static-resources/src/main/resources/messages_es_ES.properties new file mode 100644 index 000000000000..839c4ff70a87 --- /dev/null +++ b/handling-spring-static-resources/src/main/resources/messages_es_ES.properties @@ -0,0 +1,42 @@ +message.username=Por favor ingrese el nombre de usuario +message.password=Por favor ingrese una clave +message.unauth=Acceso denegado !! +message.badCredentials=Usuario o clave invalida +message.sessionExpired=La sesion expiro +message.logoutError=Lo sentimos, hubo problemas al salir +message.logoutSucc=Salida con exito +message.regSucc=Se registro correctamente. Le enviaremos un mensaje de confirmacion a su direccion de email. +message.regError=Ya existe una cuenta con ese nombre de usuario. Ingrese un nombre de usuario diferente. +message.lastName=Por favor ingrese su apellido +message.firstName=Por favor ingrese su nombre +message.badEmail=Direccion de correo no es valida +label.user.email=Correo Electronico: +label.user.firstName=Nombre: +label.user.lastName=Apellido: +label.user.password=Contrasenia: +label.user.confirmPass=Confirme la contrasenia +label.form.submit=Enviar +label.form.title=Formulario de Registro +label.login=Autehtifiquese aqui +label.form.loginTitle=Ingreso +label.form.loginLink=Regrese a autentificacion +label.form.loginEmail=Correo Electronico +label.form.loginUsername=Nombre de Usuario +label.form.loginPass=Contrasenia +label.form.loginEnglish=Ingles +label.form.loginSpanish=Espaniol +label.form.loginSignUp=Registrese +ValidEmail.user.email=Cuenta correo invlida! +UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario +NotNull.user.firstName=Por favor ingrese su nombre +NotEmpty.user.firstName=Por favor ingrese su nombre +NotNull.user.lastName=Por favor ingrese su apellido +NotEmpty.user.lastName=Por favor ingrese su apellido +NotNull.user.username=Por favor ingrese su cuenta de email +NotEmpty.user.username=Por favor ingrese su cuenta de email +NotNull.user.password=Por favor ingrese su clave +NotEmpty.user.password=Por favor ingrese su contraseña +NotNull.user.matchingPassword=Campo obligatirio +NotEmpty.user.matchingPassword=Campo obligatrio +PasswordMatches.user:Las claves no coinciden! +Email.user.email=Email no es valido diff --git a/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..7bb096671b0a --- /dev/null +++ b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/Hello.html b/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/Hello.html new file mode 100644 index 000000000000..b5b3c3640f77 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/Hello.html @@ -0,0 +1,10 @@ + + + + +Hello + + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/bootstrap.css b/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/bootstrap.css new file mode 100644 index 000000000000..5b7fe7e8562e --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/classes/other-resources/bootstrap.css @@ -0,0 +1,6167 @@ +/*! + * Bootstrap v2.3.2 + * + * Copyright 2013 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world by @mdo and @fat. + */ + +.clearfix { + *zoom: 1; +} + +.clearfix:before, +.clearfix:after { + display: table; + line-height: 0; + content: ""; +} + +.clearfix:after { + clear: both; +} + +.hide-text { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} + +.input-block-level { + display: block; + width: 100%; + min-height: 30px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section { + display: block; +} + +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +audio:not([controls]) { + display: none; +} + +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +a:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +a:hover, +a:active { + outline: 0; +} + +sub, +sup { + position: relative; + font-size: 75%; + line-height: 0; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +img { + width: auto\9; + height: auto; + max-width: 100%; + vertical-align: middle; + border: 0; + -ms-interpolation-mode: bicubic; +} + +#map_canvas img, +.google-maps img { + max-width: none; +} + +button, +input, +select, +textarea { + margin: 0; + font-size: 100%; + vertical-align: middle; +} + +button, +input { + *overflow: visible; + line-height: normal; +} + +button::-moz-focus-inner, +input::-moz-focus-inner { + padding: 0; + border: 0; +} + +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + -webkit-appearance: button; +} + +label, +select, +button, +input[type="button"], +input[type="reset"], +input[type="submit"], +input[type="radio"], +input[type="checkbox"] { + cursor: pointer; +} + +input[type="search"] { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +textarea { + overflow: auto; + vertical-align: top; +} + +@media print { + * { + color: #000 !important; + text-shadow: none !important; + background: transparent !important; + box-shadow: none !important; + } + a, + a:visited { + text-decoration: underline; + } + a[href]:after { + content: " (" attr(href) ")"; + } + abbr[title]:after { + content: " (" attr(title) ")"; + } + .ir a:after, + a[href^="javascript:"]:after, + a[href^="#"]:after { + content: ""; + } + pre, + blockquote { + border: 1px solid #999; + page-break-inside: avoid; + } + thead { + display: table-header-group; + } + tr, + img { + page-break-inside: avoid; + } + img { + max-width: 100% !important; + } + @page { + margin: 0.5cm; + } + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + h2, + h3 { + page-break-after: avoid; + } +} + +body { + margin: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 20px; + color: #333333; + background-color: #ffffff; +} + +a { + color: #0088cc; + text-decoration: none; +} + +a:hover, +a:focus { + color: #005580; + text-decoration: underline; +} + +.img-rounded { + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.img-polaroid { + padding: 4px; + background-color: #fff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.img-circle { + -webkit-border-radius: 500px; + -moz-border-radius: 500px; + border-radius: 500px; +} + +.row { + margin-left: -20px; + *zoom: 1; +} + +.row:before, +.row:after { + display: table; + line-height: 0; + content: ""; +} + +.row:after { + clear: both; +} + +[class*="span"] { + float: left; + min-height: 1px; + margin-left: 20px; +} + +.container, +.navbar-static-top .container, +.navbar-fixed-top .container, +.navbar-fixed-bottom .container { + width: 940px; +} + +.span12 { + width: 940px; +} + +.span11 { + width: 860px; +} + +.span10 { + width: 780px; +} + +.span9 { + width: 700px; +} + +.span8 { + width: 620px; +} + +.span7 { + width: 540px; +} + +.span6 { + width: 460px; +} + +.span5 { + width: 380px; +} + +.span4 { + width: 300px; +} + +.span3 { + width: 220px; +} + +.span2 { + width: 140px; +} + +.span1 { + width: 60px; +} + +.offset12 { + margin-left: 980px; +} + +.offset11 { + margin-left: 900px; +} + +.offset10 { + margin-left: 820px; +} + +.offset9 { + margin-left: 740px; +} + +.offset8 { + margin-left: 660px; +} + +.offset7 { + margin-left: 580px; +} + +.offset6 { + margin-left: 500px; +} + +.offset5 { + margin-left: 420px; +} + +.offset4 { + margin-left: 340px; +} + +.offset3 { + margin-left: 260px; +} + +.offset2 { + margin-left: 180px; +} + +.offset1 { + margin-left: 100px; +} + +.row-fluid { + width: 100%; + *zoom: 1; +} + +.row-fluid:before, +.row-fluid:after { + display: table; + line-height: 0; + content: ""; +} + +.row-fluid:after { + clear: both; +} + +.row-fluid [class*="span"] { + display: block; + float: left; + width: 100%; + min-height: 30px; + margin-left: 2.127659574468085%; + *margin-left: 2.074468085106383%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.row-fluid [class*="span"]:first-child { + margin-left: 0; +} + +.row-fluid .controls-row [class*="span"] + [class*="span"] { + margin-left: 2.127659574468085%; +} + +.row-fluid .span12 { + width: 100%; + *width: 99.94680851063829%; +} + +.row-fluid .span11 { + width: 91.48936170212765%; + *width: 91.43617021276594%; +} + +.row-fluid .span10 { + width: 82.97872340425532%; + *width: 82.92553191489361%; +} + +.row-fluid .span9 { + width: 74.46808510638297%; + *width: 74.41489361702126%; +} + +.row-fluid .span8 { + width: 65.95744680851064%; + *width: 65.90425531914893%; +} + +.row-fluid .span7 { + width: 57.44680851063829%; + *width: 57.39361702127659%; +} + +.row-fluid .span6 { + width: 48.93617021276595%; + *width: 48.88297872340425%; +} + +.row-fluid .span5 { + width: 40.42553191489362%; + *width: 40.37234042553192%; +} + +.row-fluid .span4 { + width: 31.914893617021278%; + *width: 31.861702127659576%; +} + +.row-fluid .span3 { + width: 23.404255319148934%; + *width: 23.351063829787233%; +} + +.row-fluid .span2 { + width: 14.893617021276595%; + *width: 14.840425531914894%; +} + +.row-fluid .span1 { + width: 6.382978723404255%; + *width: 6.329787234042553%; +} + +.row-fluid .offset12 { + margin-left: 104.25531914893617%; + *margin-left: 104.14893617021275%; +} + +.row-fluid .offset12:first-child { + margin-left: 102.12765957446808%; + *margin-left: 102.02127659574467%; +} + +.row-fluid .offset11 { + margin-left: 95.74468085106382%; + *margin-left: 95.6382978723404%; +} + +.row-fluid .offset11:first-child { + margin-left: 93.61702127659574%; + *margin-left: 93.51063829787232%; +} + +.row-fluid .offset10 { + margin-left: 87.23404255319149%; + *margin-left: 87.12765957446807%; +} + +.row-fluid .offset10:first-child { + margin-left: 85.1063829787234%; + *margin-left: 84.99999999999999%; +} + +.row-fluid .offset9 { + margin-left: 78.72340425531914%; + *margin-left: 78.61702127659572%; +} + +.row-fluid .offset9:first-child { + margin-left: 76.59574468085106%; + *margin-left: 76.48936170212764%; +} + +.row-fluid .offset8 { + margin-left: 70.2127659574468%; + *margin-left: 70.10638297872339%; +} + +.row-fluid .offset8:first-child { + margin-left: 68.08510638297872%; + *margin-left: 67.9787234042553%; +} + +.row-fluid .offset7 { + margin-left: 61.70212765957446%; + *margin-left: 61.59574468085106%; +} + +.row-fluid .offset7:first-child { + margin-left: 59.574468085106375%; + *margin-left: 59.46808510638297%; +} + +.row-fluid .offset6 { + margin-left: 53.191489361702125%; + *margin-left: 53.085106382978715%; +} + +.row-fluid .offset6:first-child { + margin-left: 51.063829787234035%; + *margin-left: 50.95744680851063%; +} + +.row-fluid .offset5 { + margin-left: 44.68085106382979%; + *margin-left: 44.57446808510638%; +} + +.row-fluid .offset5:first-child { + margin-left: 42.5531914893617%; + *margin-left: 42.4468085106383%; +} + +.row-fluid .offset4 { + margin-left: 36.170212765957444%; + *margin-left: 36.06382978723405%; +} + +.row-fluid .offset4:first-child { + margin-left: 34.04255319148936%; + *margin-left: 33.93617021276596%; +} + +.row-fluid .offset3 { + margin-left: 27.659574468085104%; + *margin-left: 27.5531914893617%; +} + +.row-fluid .offset3:first-child { + margin-left: 25.53191489361702%; + *margin-left: 25.425531914893618%; +} + +.row-fluid .offset2 { + margin-left: 19.148936170212764%; + *margin-left: 19.04255319148936%; +} + +.row-fluid .offset2:first-child { + margin-left: 17.02127659574468%; + *margin-left: 16.914893617021278%; +} + +.row-fluid .offset1 { + margin-left: 10.638297872340425%; + *margin-left: 10.53191489361702%; +} + +.row-fluid .offset1:first-child { + margin-left: 8.51063829787234%; + *margin-left: 8.404255319148938%; +} + +[class*="span"].hide, +.row-fluid [class*="span"].hide { + display: none; +} + +[class*="span"].pull-right, +.row-fluid [class*="span"].pull-right { + float: right; +} + +.container { + margin-right: auto; + margin-left: auto; + *zoom: 1; +} + +.container:before, +.container:after { + display: table; + line-height: 0; + content: ""; +} + +.container:after { + clear: both; +} + +.container-fluid { + padding-right: 20px; + padding-left: 20px; + *zoom: 1; +} + +.container-fluid:before, +.container-fluid:after { + display: table; + line-height: 0; + content: ""; +} + +.container-fluid:after { + clear: both; +} + +p { + margin: 0 0 10px; +} + +.lead { + margin-bottom: 20px; + font-size: 21px; + font-weight: 200; + line-height: 30px; +} + +small { + font-size: 85%; +} + +strong { + font-weight: bold; +} + +em { + font-style: italic; +} + +cite { + font-style: normal; +} + +.muted { + color: #999999; +} + +a.muted:hover, +a.muted:focus { + color: #808080; +} + +.text-warning { + color: #c09853; +} + +a.text-warning:hover, +a.text-warning:focus { + color: #a47e3c; +} + +.text-error { + color: #b94a48; +} + +a.text-error:hover, +a.text-error:focus { + color: #953b39; +} + +.text-info { + color: #3a87ad; +} + +a.text-info:hover, +a.text-info:focus { + color: #2d6987; +} + +.text-success { + color: #468847; +} + +a.text-success:hover, +a.text-success:focus { + color: #356635; +} + +.text-left { + text-align: left; +} + +.text-right { + text-align: right; +} + +.text-center { + text-align: center; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 10px 0; + font-family: inherit; + font-weight: bold; + line-height: 20px; + color: inherit; + text-rendering: optimizelegibility; +} + +h1 small, +h2 small, +h3 small, +h4 small, +h5 small, +h6 small { + font-weight: normal; + line-height: 1; + color: #999999; +} + +h1, +h2, +h3 { + line-height: 40px; +} + +h1 { + font-size: 38.5px; +} + +h2 { + font-size: 31.5px; +} + +h3 { + font-size: 24.5px; +} + +h4 { + font-size: 17.5px; +} + +h5 { + font-size: 14px; +} + +h6 { + font-size: 11.9px; +} + +h1 small { + font-size: 24.5px; +} + +h2 small { + font-size: 17.5px; +} + +h3 small { + font-size: 14px; +} + +h4 small { + font-size: 14px; +} + +.page-header { + padding-bottom: 9px; + margin: 20px 0 30px; + border-bottom: 1px solid #eeeeee; +} + +ul, +ol { + padding: 0; + margin: 0 0 10px 25px; +} + +ul ul, +ul ol, +ol ol, +ol ul { + margin-bottom: 0; +} + +li { + line-height: 20px; +} + +ul.unstyled, +ol.unstyled { + margin-left: 0; + list-style: none; +} + +ul.inline, +ol.inline { + margin-left: 0; + list-style: none; +} + +ul.inline > li, +ol.inline > li { + display: inline-block; + *display: inline; + padding-right: 5px; + padding-left: 5px; + *zoom: 1; +} + +dl { + margin-bottom: 20px; +} + +dt, +dd { + line-height: 20px; +} + +dt { + font-weight: bold; +} + +dd { + margin-left: 10px; +} + +.dl-horizontal { + *zoom: 1; +} + +.dl-horizontal:before, +.dl-horizontal:after { + display: table; + line-height: 0; + content: ""; +} + +.dl-horizontal:after { + clear: both; +} + +.dl-horizontal dt { + float: left; + width: 160px; + overflow: hidden; + clear: left; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +.dl-horizontal dd { + margin-left: 180px; +} + +hr { + margin: 20px 0; + border: 0; + border-top: 1px solid #eeeeee; + border-bottom: 1px solid #ffffff; +} + +abbr[title], +abbr[data-original-title] { + cursor: help; + border-bottom: 1px dotted #999999; +} + +abbr.initialism { + font-size: 90%; + text-transform: uppercase; +} + +blockquote { + padding: 0 0 0 15px; + margin: 0 0 20px; + border-left: 5px solid #eeeeee; +} + +blockquote p { + margin-bottom: 0; + font-size: 17.5px; + font-weight: 300; + line-height: 1.25; +} + +blockquote small { + display: block; + line-height: 20px; + color: #999999; +} + +blockquote small:before { + content: '\2014 \00A0'; +} + +blockquote.pull-right { + float: right; + padding-right: 15px; + padding-left: 0; + border-right: 5px solid #eeeeee; + border-left: 0; +} + +blockquote.pull-right p, +blockquote.pull-right small { + text-align: right; +} + +blockquote.pull-right small:before { + content: ''; +} + +blockquote.pull-right small:after { + content: '\00A0 \2014'; +} + +q:before, +q:after, +blockquote:before, +blockquote:after { + content: ""; +} + +address { + display: block; + margin-bottom: 20px; + font-style: normal; + line-height: 20px; +} + +code, +pre { + padding: 0 3px 2px; + font-family: Monaco, Menlo, Consolas, "Courier New", monospace; + font-size: 12px; + color: #333333; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +code { + padding: 2px 4px; + color: #d14; + white-space: nowrap; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; +} + +pre { + display: block; + padding: 9.5px; + margin: 0 0 10px; + font-size: 13px; + line-height: 20px; + word-break: break-all; + word-wrap: break-word; + white-space: pre; + white-space: pre-wrap; + background-color: #f5f5f5; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.15); + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +pre.prettyprint { + margin-bottom: 20px; +} + +pre code { + padding: 0; + color: inherit; + white-space: pre; + white-space: pre-wrap; + background-color: transparent; + border: 0; +} + +.pre-scrollable { + max-height: 340px; + overflow-y: scroll; +} + +form { + margin: 0 0 20px; +} + +fieldset { + padding: 0; + margin: 0; + border: 0; +} + +legend { + display: block; + width: 100%; + padding: 0; + margin-bottom: 20px; + font-size: 21px; + line-height: 40px; + color: #333333; + border: 0; + border-bottom: 1px solid #e5e5e5; +} + +legend small { + font-size: 15px; + color: #999999; +} + +label, +input, +button, +select, +textarea { + font-size: 14px; + font-weight: normal; + line-height: 20px; +} + +input, +button, +select, +textarea { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +label { + display: block; + margin-bottom: 5px; +} + +select, +textarea, +input[type="text"], +input[type="password"], +input[type="datetime"], +input[type="datetime-local"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="week"], +input[type="number"], +input[type="email"], +input[type="url"], +input[type="search"], +input[type="tel"], +input[type="color"], +.uneditable-input { + display: inline-block; + height: 20px; + padding: 4px 6px; + margin-bottom: 10px; + font-size: 14px; + line-height: 20px; + color: #555555; + vertical-align: middle; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +input, +textarea, +.uneditable-input { + width: 206px; +} + +textarea { + height: auto; +} + +textarea, +input[type="text"], +input[type="password"], +input[type="datetime"], +input[type="datetime-local"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="week"], +input[type="number"], +input[type="email"], +input[type="url"], +input[type="search"], +input[type="tel"], +input[type="color"], +.uneditable-input { + background-color: #ffffff; + border: 1px solid #cccccc; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; + -moz-transition: border linear 0.2s, box-shadow linear 0.2s; + -o-transition: border linear 0.2s, box-shadow linear 0.2s; + transition: border linear 0.2s, box-shadow linear 0.2s; +} + +textarea:focus, +input[type="text"]:focus, +input[type="password"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="date"]:focus, +input[type="month"]:focus, +input[type="time"]:focus, +input[type="week"]:focus, +input[type="number"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="color"]:focus, +.uneditable-input:focus { + border-color: rgba(82, 168, 236, 0.8); + outline: 0; + outline: thin dotted \9; + /* IE6-9 */ + + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); +} + +input[type="radio"], +input[type="checkbox"] { + margin: 4px 0 0; + margin-top: 1px \9; + *margin-top: 0; + line-height: normal; +} + +input[type="file"], +input[type="image"], +input[type="submit"], +input[type="reset"], +input[type="button"], +input[type="radio"], +input[type="checkbox"] { + width: auto; +} + +select, +input[type="file"] { + height: 30px; + /* In IE7, the height of the select element cannot be changed by height, only font-size */ + + *margin-top: 4px; + /* For IE7, add top margin to align select with labels */ + + line-height: 30px; +} + +select { + width: 220px; + background-color: #ffffff; + border: 1px solid #cccccc; +} + +select[multiple], +select[size] { + height: auto; +} + +select:focus, +input[type="file"]:focus, +input[type="radio"]:focus, +input[type="checkbox"]:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +.uneditable-input, +.uneditable-textarea { + color: #999999; + cursor: not-allowed; + background-color: #fcfcfc; + border-color: #cccccc; + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); +} + +.uneditable-input { + overflow: hidden; + white-space: nowrap; +} + +.uneditable-textarea { + width: auto; + height: auto; +} + +input:-moz-placeholder, +textarea:-moz-placeholder { + color: #999999; +} + +input:-ms-input-placeholder, +textarea:-ms-input-placeholder { + color: #999999; +} + +input::-webkit-input-placeholder, +textarea::-webkit-input-placeholder { + color: #999999; +} + +.radio, +.checkbox { + min-height: 20px; + padding-left: 20px; +} + +.radio input[type="radio"], +.checkbox input[type="checkbox"] { + float: left; + margin-left: -20px; +} + +.controls > .radio:first-child, +.controls > .checkbox:first-child { + padding-top: 5px; +} + +.radio.inline, +.checkbox.inline { + display: inline-block; + padding-top: 5px; + margin-bottom: 0; + vertical-align: middle; +} + +.radio.inline + .radio.inline, +.checkbox.inline + .checkbox.inline { + margin-left: 10px; +} + +.input-mini { + width: 60px; +} + +.input-small { + width: 90px; +} + +.input-medium { + width: 150px; +} + +.input-large { + width: 210px; +} + +.input-xlarge { + width: 270px; +} + +.input-xxlarge { + width: 530px; +} + +input[class*="span"], +select[class*="span"], +textarea[class*="span"], +.uneditable-input[class*="span"], +.row-fluid input[class*="span"], +.row-fluid select[class*="span"], +.row-fluid textarea[class*="span"], +.row-fluid .uneditable-input[class*="span"] { + float: none; + margin-left: 0; +} + +.input-append input[class*="span"], +.input-append .uneditable-input[class*="span"], +.input-prepend input[class*="span"], +.input-prepend .uneditable-input[class*="span"], +.row-fluid input[class*="span"], +.row-fluid select[class*="span"], +.row-fluid textarea[class*="span"], +.row-fluid .uneditable-input[class*="span"], +.row-fluid .input-prepend [class*="span"], +.row-fluid .input-append [class*="span"] { + display: inline-block; +} + +input, +textarea, +.uneditable-input { + margin-left: 0; +} + +.controls-row [class*="span"] + [class*="span"] { + margin-left: 20px; +} + +input.span12, +textarea.span12, +.uneditable-input.span12 { + width: 926px; +} + +input.span11, +textarea.span11, +.uneditable-input.span11 { + width: 846px; +} + +input.span10, +textarea.span10, +.uneditable-input.span10 { + width: 766px; +} + +input.span9, +textarea.span9, +.uneditable-input.span9 { + width: 686px; +} + +input.span8, +textarea.span8, +.uneditable-input.span8 { + width: 606px; +} + +input.span7, +textarea.span7, +.uneditable-input.span7 { + width: 526px; +} + +input.span6, +textarea.span6, +.uneditable-input.span6 { + width: 446px; +} + +input.span5, +textarea.span5, +.uneditable-input.span5 { + width: 366px; +} + +input.span4, +textarea.span4, +.uneditable-input.span4 { + width: 286px; +} + +input.span3, +textarea.span3, +.uneditable-input.span3 { + width: 206px; +} + +input.span2, +textarea.span2, +.uneditable-input.span2 { + width: 126px; +} + +input.span1, +textarea.span1, +.uneditable-input.span1 { + width: 46px; +} + +.controls-row { + *zoom: 1; +} + +.controls-row:before, +.controls-row:after { + display: table; + line-height: 0; + content: ""; +} + +.controls-row:after { + clear: both; +} + +.controls-row [class*="span"], +.row-fluid .controls-row [class*="span"] { + float: left; +} + +.controls-row .checkbox[class*="span"], +.controls-row .radio[class*="span"] { + padding-top: 5px; +} + +input[disabled], +select[disabled], +textarea[disabled], +input[readonly], +select[readonly], +textarea[readonly] { + cursor: not-allowed; + background-color: #eeeeee; +} + +input[type="radio"][disabled], +input[type="checkbox"][disabled], +input[type="radio"][readonly], +input[type="checkbox"][readonly] { + background-color: transparent; +} + +.control-group.warning .control-label, +.control-group.warning .help-block, +.control-group.warning .help-inline { + color: #c09853; +} + +.control-group.warning .checkbox, +.control-group.warning .radio, +.control-group.warning input, +.control-group.warning select, +.control-group.warning textarea { + color: #c09853; +} + +.control-group.warning input, +.control-group.warning select, +.control-group.warning textarea { + border-color: #c09853; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.warning input:focus, +.control-group.warning select:focus, +.control-group.warning textarea:focus { + border-color: #a47e3c; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; +} + +.control-group.warning .input-prepend .add-on, +.control-group.warning .input-append .add-on { + color: #c09853; + background-color: #fcf8e3; + border-color: #c09853; +} + +.control-group.error .control-label, +.control-group.error .help-block, +.control-group.error .help-inline { + color: #b94a48; +} + +.control-group.error .checkbox, +.control-group.error .radio, +.control-group.error input, +.control-group.error select, +.control-group.error textarea { + color: #b94a48; +} + +.control-group.error input, +.control-group.error select, +.control-group.error textarea { + border-color: #b94a48; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.error input:focus, +.control-group.error select:focus, +.control-group.error textarea:focus { + border-color: #953b39; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; +} + +.control-group.error .input-prepend .add-on, +.control-group.error .input-append .add-on { + color: #b94a48; + background-color: #f2dede; + border-color: #b94a48; +} + +.control-group.success .control-label, +.control-group.success .help-block, +.control-group.success .help-inline { + color: #468847; +} + +.control-group.success .checkbox, +.control-group.success .radio, +.control-group.success input, +.control-group.success select, +.control-group.success textarea { + color: #468847; +} + +.control-group.success input, +.control-group.success select, +.control-group.success textarea { + border-color: #468847; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.success input:focus, +.control-group.success select:focus, +.control-group.success textarea:focus { + border-color: #356635; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; +} + +.control-group.success .input-prepend .add-on, +.control-group.success .input-append .add-on { + color: #468847; + background-color: #dff0d8; + border-color: #468847; +} + +.control-group.info .control-label, +.control-group.info .help-block, +.control-group.info .help-inline { + color: #3a87ad; +} + +.control-group.info .checkbox, +.control-group.info .radio, +.control-group.info input, +.control-group.info select, +.control-group.info textarea { + color: #3a87ad; +} + +.control-group.info input, +.control-group.info select, +.control-group.info textarea { + border-color: #3a87ad; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.info input:focus, +.control-group.info select:focus, +.control-group.info textarea:focus { + border-color: #2d6987; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; +} + +.control-group.info .input-prepend .add-on, +.control-group.info .input-append .add-on { + color: #3a87ad; + background-color: #d9edf7; + border-color: #3a87ad; +} + +input:focus:invalid, +textarea:focus:invalid, +select:focus:invalid { + color: #b94a48; + border-color: #ee5f5b; +} + +input:focus:invalid:focus, +textarea:focus:invalid:focus, +select:focus:invalid:focus { + border-color: #e9322d; + -webkit-box-shadow: 0 0 6px #f8b9b7; + -moz-box-shadow: 0 0 6px #f8b9b7; + box-shadow: 0 0 6px #f8b9b7; +} + +.form-actions { + padding: 19px 20px 20px; + margin-top: 20px; + margin-bottom: 20px; + background-color: #f5f5f5; + border-top: 1px solid #e5e5e5; + *zoom: 1; +} + +.form-actions:before, +.form-actions:after { + display: table; + line-height: 0; + content: ""; +} + +.form-actions:after { + clear: both; +} + +.help-block, +.help-inline { + color: #595959; +} + +.help-block { + display: block; + margin-bottom: 10px; +} + +.help-inline { + display: inline-block; + *display: inline; + padding-left: 5px; + vertical-align: middle; + *zoom: 1; +} + +.input-append, +.input-prepend { + display: inline-block; + margin-bottom: 10px; + font-size: 0; + white-space: nowrap; + vertical-align: middle; +} + +.input-append input, +.input-prepend input, +.input-append select, +.input-prepend select, +.input-append .uneditable-input, +.input-prepend .uneditable-input, +.input-append .dropdown-menu, +.input-prepend .dropdown-menu, +.input-append .popover, +.input-prepend .popover { + font-size: 14px; +} + +.input-append input, +.input-prepend input, +.input-append select, +.input-prepend select, +.input-append .uneditable-input, +.input-prepend .uneditable-input { + position: relative; + margin-bottom: 0; + *margin-left: 0; + vertical-align: top; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-append input:focus, +.input-prepend input:focus, +.input-append select:focus, +.input-prepend select:focus, +.input-append .uneditable-input:focus, +.input-prepend .uneditable-input:focus { + z-index: 2; +} + +.input-append .add-on, +.input-prepend .add-on { + display: inline-block; + width: auto; + height: 20px; + min-width: 16px; + padding: 4px 5px; + font-size: 14px; + font-weight: normal; + line-height: 20px; + text-align: center; + text-shadow: 0 1px 0 #ffffff; + background-color: #eeeeee; + border: 1px solid #ccc; +} + +.input-append .add-on, +.input-prepend .add-on, +.input-append .btn, +.input-prepend .btn, +.input-append .btn-group > .dropdown-toggle, +.input-prepend .btn-group > .dropdown-toggle { + vertical-align: top; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.input-append .active, +.input-prepend .active { + background-color: #a9dba9; + border-color: #46a546; +} + +.input-prepend .add-on, +.input-prepend .btn { + margin-right: -1px; +} + +.input-prepend .add-on:first-child, +.input-prepend .btn:first-child { + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-append input, +.input-append select, +.input-append .uneditable-input { + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-append input + .btn-group .btn:last-child, +.input-append select + .btn-group .btn:last-child, +.input-append .uneditable-input + .btn-group .btn:last-child { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-append .add-on, +.input-append .btn, +.input-append .btn-group { + margin-left: -1px; +} + +.input-append .add-on:last-child, +.input-append .btn:last-child, +.input-append .btn-group:last-child > .dropdown-toggle { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append input, +.input-prepend.input-append select, +.input-prepend.input-append .uneditable-input { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.input-prepend.input-append input + .btn-group .btn, +.input-prepend.input-append select + .btn-group .btn, +.input-prepend.input-append .uneditable-input + .btn-group .btn { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append .add-on:first-child, +.input-prepend.input-append .btn:first-child { + margin-right: -1px; + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-prepend.input-append .add-on:last-child, +.input-prepend.input-append .btn:last-child { + margin-left: -1px; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append .btn-group:first-child { + margin-left: 0; +} + +input.search-query { + padding-right: 14px; + padding-right: 4px \9; + padding-left: 14px; + padding-left: 4px \9; + /* IE7-8 doesn't have border-radius, so don't indent the padding */ + + margin-bottom: 0; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +/* Allow for input prepend/append in search forms */ + +.form-search .input-append .search-query, +.form-search .input-prepend .search-query { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.form-search .input-append .search-query { + -webkit-border-radius: 14px 0 0 14px; + -moz-border-radius: 14px 0 0 14px; + border-radius: 14px 0 0 14px; +} + +.form-search .input-append .btn { + -webkit-border-radius: 0 14px 14px 0; + -moz-border-radius: 0 14px 14px 0; + border-radius: 0 14px 14px 0; +} + +.form-search .input-prepend .search-query { + -webkit-border-radius: 0 14px 14px 0; + -moz-border-radius: 0 14px 14px 0; + border-radius: 0 14px 14px 0; +} + +.form-search .input-prepend .btn { + -webkit-border-radius: 14px 0 0 14px; + -moz-border-radius: 14px 0 0 14px; + border-radius: 14px 0 0 14px; +} + +.form-search input, +.form-inline input, +.form-horizontal input, +.form-search textarea, +.form-inline textarea, +.form-horizontal textarea, +.form-search select, +.form-inline select, +.form-horizontal select, +.form-search .help-inline, +.form-inline .help-inline, +.form-horizontal .help-inline, +.form-search .uneditable-input, +.form-inline .uneditable-input, +.form-horizontal .uneditable-input, +.form-search .input-prepend, +.form-inline .input-prepend, +.form-horizontal .input-prepend, +.form-search .input-append, +.form-inline .input-append, +.form-horizontal .input-append { + display: inline-block; + *display: inline; + margin-bottom: 0; + vertical-align: middle; + *zoom: 1; +} + +.form-search .hide, +.form-inline .hide, +.form-horizontal .hide { + display: none; +} + +.form-search label, +.form-inline label, +.form-search .btn-group, +.form-inline .btn-group { + display: inline-block; +} + +.form-search .input-append, +.form-inline .input-append, +.form-search .input-prepend, +.form-inline .input-prepend { + margin-bottom: 0; +} + +.form-search .radio, +.form-search .checkbox, +.form-inline .radio, +.form-inline .checkbox { + padding-left: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.form-search .radio input[type="radio"], +.form-search .checkbox input[type="checkbox"], +.form-inline .radio input[type="radio"], +.form-inline .checkbox input[type="checkbox"] { + float: left; + margin-right: 3px; + margin-left: 0; +} + +.control-group { + margin-bottom: 10px; +} + +legend + .control-group { + margin-top: 20px; + -webkit-margin-top-collapse: separate; +} + +.form-horizontal .control-group { + margin-bottom: 20px; + *zoom: 1; +} + +.form-horizontal .control-group:before, +.form-horizontal .control-group:after { + display: table; + line-height: 0; + content: ""; +} + +.form-horizontal .control-group:after { + clear: both; +} + +.form-horizontal .control-label { + float: left; + width: 160px; + padding-top: 5px; + text-align: right; +} + +.form-horizontal .controls { + *display: inline-block; + *padding-left: 20px; + margin-left: 180px; + *margin-left: 0; +} + +.form-horizontal .controls:first-child { + *padding-left: 180px; +} + +.form-horizontal .help-block { + margin-bottom: 0; +} + +.form-horizontal input + .help-block, +.form-horizontal select + .help-block, +.form-horizontal textarea + .help-block, +.form-horizontal .uneditable-input + .help-block, +.form-horizontal .input-prepend + .help-block, +.form-horizontal .input-append + .help-block { + margin-top: 10px; +} + +.form-horizontal .form-actions { + padding-left: 180px; +} + +table { + max-width: 100%; + background-color: transparent; + border-collapse: collapse; + border-spacing: 0; +} + +.table { + width: 100%; + margin-bottom: 20px; +} + +.table th, +.table td { + padding: 8px; + line-height: 20px; + text-align: left; + vertical-align: top; + border-top: 1px solid #dddddd; +} + +.table th { + font-weight: bold; +} + +.table thead th { + vertical-align: bottom; +} + +.table caption + thead tr:first-child th, +.table caption + thead tr:first-child td, +.table colgroup + thead tr:first-child th, +.table colgroup + thead tr:first-child td, +.table thead:first-child tr:first-child th, +.table thead:first-child tr:first-child td { + border-top: 0; +} + +.table tbody + tbody { + border-top: 2px solid #dddddd; +} + +.table .table { + background-color: #ffffff; +} + +.table-condensed th, +.table-condensed td { + padding: 4px 5px; +} + +.table-bordered { + border: 1px solid #dddddd; + border-collapse: separate; + *border-collapse: collapse; + border-left: 0; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.table-bordered th, +.table-bordered td { + border-left: 1px solid #dddddd; +} + +.table-bordered caption + thead tr:first-child th, +.table-bordered caption + tbody tr:first-child th, +.table-bordered caption + tbody tr:first-child td, +.table-bordered colgroup + thead tr:first-child th, +.table-bordered colgroup + tbody tr:first-child th, +.table-bordered colgroup + tbody tr:first-child td, +.table-bordered thead:first-child tr:first-child th, +.table-bordered tbody:first-child tr:first-child th, +.table-bordered tbody:first-child tr:first-child td { + border-top: 0; +} + +.table-bordered thead:first-child tr:first-child > th:first-child, +.table-bordered tbody:first-child tr:first-child > td:first-child, +.table-bordered tbody:first-child tr:first-child > th:first-child { + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; +} + +.table-bordered thead:first-child tr:first-child > th:last-child, +.table-bordered tbody:first-child tr:first-child > td:last-child, +.table-bordered tbody:first-child tr:first-child > th:last-child { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; +} + +.table-bordered thead:last-child tr:last-child > th:first-child, +.table-bordered tbody:last-child tr:last-child > td:first-child, +.table-bordered tbody:last-child tr:last-child > th:first-child, +.table-bordered tfoot:last-child tr:last-child > td:first-child, +.table-bordered tfoot:last-child tr:last-child > th:first-child { + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; +} + +.table-bordered thead:last-child tr:last-child > th:last-child, +.table-bordered tbody:last-child tr:last-child > td:last-child, +.table-bordered tbody:last-child tr:last-child > th:last-child, +.table-bordered tfoot:last-child tr:last-child > td:last-child, +.table-bordered tfoot:last-child tr:last-child > th:last-child { + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-bottomright: 4px; +} + +.table-bordered tfoot + tbody:last-child tr:last-child td:first-child { + -webkit-border-bottom-left-radius: 0; + border-bottom-left-radius: 0; + -moz-border-radius-bottomleft: 0; +} + +.table-bordered tfoot + tbody:last-child tr:last-child td:last-child { + -webkit-border-bottom-right-radius: 0; + border-bottom-right-radius: 0; + -moz-border-radius-bottomright: 0; +} + +.table-bordered caption + thead tr:first-child th:first-child, +.table-bordered caption + tbody tr:first-child td:first-child, +.table-bordered colgroup + thead tr:first-child th:first-child, +.table-bordered colgroup + tbody tr:first-child td:first-child { + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; +} + +.table-bordered caption + thead tr:first-child th:last-child, +.table-bordered caption + tbody tr:first-child td:last-child, +.table-bordered colgroup + thead tr:first-child th:last-child, +.table-bordered colgroup + tbody tr:first-child td:last-child { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; +} + +.table-striped tbody > tr:nth-child(odd) > td, +.table-striped tbody > tr:nth-child(odd) > th { + background-color: #f9f9f9; +} + +.table-hover tbody tr:hover > td, +.table-hover tbody tr:hover > th { + background-color: #f5f5f5; +} + +table td[class*="span"], +table th[class*="span"], +.row-fluid table td[class*="span"], +.row-fluid table th[class*="span"] { + display: table-cell; + float: none; + margin-left: 0; +} + +.table td.span1, +.table th.span1 { + float: none; + width: 44px; + margin-left: 0; +} + +.table td.span2, +.table th.span2 { + float: none; + width: 124px; + margin-left: 0; +} + +.table td.span3, +.table th.span3 { + float: none; + width: 204px; + margin-left: 0; +} + +.table td.span4, +.table th.span4 { + float: none; + width: 284px; + margin-left: 0; +} + +.table td.span5, +.table th.span5 { + float: none; + width: 364px; + margin-left: 0; +} + +.table td.span6, +.table th.span6 { + float: none; + width: 444px; + margin-left: 0; +} + +.table td.span7, +.table th.span7 { + float: none; + width: 524px; + margin-left: 0; +} + +.table td.span8, +.table th.span8 { + float: none; + width: 604px; + margin-left: 0; +} + +.table td.span9, +.table th.span9 { + float: none; + width: 684px; + margin-left: 0; +} + +.table td.span10, +.table th.span10 { + float: none; + width: 764px; + margin-left: 0; +} + +.table td.span11, +.table th.span11 { + float: none; + width: 844px; + margin-left: 0; +} + +.table td.span12, +.table th.span12 { + float: none; + width: 924px; + margin-left: 0; +} + +.table tbody tr.success > td { + background-color: #dff0d8; +} + +.table tbody tr.error > td { + background-color: #f2dede; +} + +.table tbody tr.warning > td { + background-color: #fcf8e3; +} + +.table tbody tr.info > td { + background-color: #d9edf7; +} + +.table-hover tbody tr.success:hover > td { + background-color: #d0e9c6; +} + +.table-hover tbody tr.error:hover > td { + background-color: #ebcccc; +} + +.table-hover tbody tr.warning:hover > td { + background-color: #faf2cc; +} + +.table-hover tbody tr.info:hover > td { + background-color: #c4e3f3; +} + +[class^="icon-"], +[class*=" icon-"] { + display: inline-block; + width: 14px; + height: 14px; + margin-top: 1px; + *margin-right: .3em; + line-height: 14px; + vertical-align: text-top; + background-image: url("../img/glyphicons-halflings.png"); + background-position: 14px 14px; + background-repeat: no-repeat; +} + +/* White icons with optional class, or on hover/focus/active states of certain elements */ + +.icon-white, +.nav-pills > .active > a > [class^="icon-"], +.nav-pills > .active > a > [class*=" icon-"], +.nav-list > .active > a > [class^="icon-"], +.nav-list > .active > a > [class*=" icon-"], +.navbar-inverse .nav > .active > a > [class^="icon-"], +.navbar-inverse .nav > .active > a > [class*=" icon-"], +.dropdown-menu > li > a:hover > [class^="icon-"], +.dropdown-menu > li > a:focus > [class^="icon-"], +.dropdown-menu > li > a:hover > [class*=" icon-"], +.dropdown-menu > li > a:focus > [class*=" icon-"], +.dropdown-menu > .active > a > [class^="icon-"], +.dropdown-menu > .active > a > [class*=" icon-"], +.dropdown-submenu:hover > a > [class^="icon-"], +.dropdown-submenu:focus > a > [class^="icon-"], +.dropdown-submenu:hover > a > [class*=" icon-"], +.dropdown-submenu:focus > a > [class*=" icon-"] { + background-image: url("../img/glyphicons-halflings-white.png"); +} + +.icon-glass { + background-position: 0 0; +} + +.icon-music { + background-position: -24px 0; +} + +.icon-search { + background-position: -48px 0; +} + +.icon-envelope { + background-position: -72px 0; +} + +.icon-heart { + background-position: -96px 0; +} + +.icon-star { + background-position: -120px 0; +} + +.icon-star-empty { + background-position: -144px 0; +} + +.icon-user { + background-position: -168px 0; +} + +.icon-film { + background-position: -192px 0; +} + +.icon-th-large { + background-position: -216px 0; +} + +.icon-th { + background-position: -240px 0; +} + +.icon-th-list { + background-position: -264px 0; +} + +.icon-ok { + background-position: -288px 0; +} + +.icon-remove { + background-position: -312px 0; +} + +.icon-zoom-in { + background-position: -336px 0; +} + +.icon-zoom-out { + background-position: -360px 0; +} + +.icon-off { + background-position: -384px 0; +} + +.icon-signal { + background-position: -408px 0; +} + +.icon-cog { + background-position: -432px 0; +} + +.icon-trash { + background-position: -456px 0; +} + +.icon-home { + background-position: 0 -24px; +} + +.icon-file { + background-position: -24px -24px; +} + +.icon-time { + background-position: -48px -24px; +} + +.icon-road { + background-position: -72px -24px; +} + +.icon-download-alt { + background-position: -96px -24px; +} + +.icon-download { + background-position: -120px -24px; +} + +.icon-upload { + background-position: -144px -24px; +} + +.icon-inbox { + background-position: -168px -24px; +} + +.icon-play-circle { + background-position: -192px -24px; +} + +.icon-repeat { + background-position: -216px -24px; +} + +.icon-refresh { + background-position: -240px -24px; +} + +.icon-list-alt { + background-position: -264px -24px; +} + +.icon-lock { + background-position: -287px -24px; +} + +.icon-flag { + background-position: -312px -24px; +} + +.icon-headphones { + background-position: -336px -24px; +} + +.icon-volume-off { + background-position: -360px -24px; +} + +.icon-volume-down { + background-position: -384px -24px; +} + +.icon-volume-up { + background-position: -408px -24px; +} + +.icon-qrcode { + background-position: -432px -24px; +} + +.icon-barcode { + background-position: -456px -24px; +} + +.icon-tag { + background-position: 0 -48px; +} + +.icon-tags { + background-position: -25px -48px; +} + +.icon-book { + background-position: -48px -48px; +} + +.icon-bookmark { + background-position: -72px -48px; +} + +.icon-print { + background-position: -96px -48px; +} + +.icon-camera { + background-position: -120px -48px; +} + +.icon-font { + background-position: -144px -48px; +} + +.icon-bold { + background-position: -167px -48px; +} + +.icon-italic { + background-position: -192px -48px; +} + +.icon-text-height { + background-position: -216px -48px; +} + +.icon-text-width { + background-position: -240px -48px; +} + +.icon-align-left { + background-position: -264px -48px; +} + +.icon-align-center { + background-position: -288px -48px; +} + +.icon-align-right { + background-position: -312px -48px; +} + +.icon-align-justify { + background-position: -336px -48px; +} + +.icon-list { + background-position: -360px -48px; +} + +.icon-indent-left { + background-position: -384px -48px; +} + +.icon-indent-right { + background-position: -408px -48px; +} + +.icon-facetime-video { + background-position: -432px -48px; +} + +.icon-picture { + background-position: -456px -48px; +} + +.icon-pencil { + background-position: 0 -72px; +} + +.icon-map-marker { + background-position: -24px -72px; +} + +.icon-adjust { + background-position: -48px -72px; +} + +.icon-tint { + background-position: -72px -72px; +} + +.icon-edit { + background-position: -96px -72px; +} + +.icon-share { + background-position: -120px -72px; +} + +.icon-check { + background-position: -144px -72px; +} + +.icon-move { + background-position: -168px -72px; +} + +.icon-step-backward { + background-position: -192px -72px; +} + +.icon-fast-backward { + background-position: -216px -72px; +} + +.icon-backward { + background-position: -240px -72px; +} + +.icon-play { + background-position: -264px -72px; +} + +.icon-pause { + background-position: -288px -72px; +} + +.icon-stop { + background-position: -312px -72px; +} + +.icon-forward { + background-position: -336px -72px; +} + +.icon-fast-forward { + background-position: -360px -72px; +} + +.icon-step-forward { + background-position: -384px -72px; +} + +.icon-eject { + background-position: -408px -72px; +} + +.icon-chevron-left { + background-position: -432px -72px; +} + +.icon-chevron-right { + background-position: -456px -72px; +} + +.icon-plus-sign { + background-position: 0 -96px; +} + +.icon-minus-sign { + background-position: -24px -96px; +} + +.icon-remove-sign { + background-position: -48px -96px; +} + +.icon-ok-sign { + background-position: -72px -96px; +} + +.icon-question-sign { + background-position: -96px -96px; +} + +.icon-info-sign { + background-position: -120px -96px; +} + +.icon-screenshot { + background-position: -144px -96px; +} + +.icon-remove-circle { + background-position: -168px -96px; +} + +.icon-ok-circle { + background-position: -192px -96px; +} + +.icon-ban-circle { + background-position: -216px -96px; +} + +.icon-arrow-left { + background-position: -240px -96px; +} + +.icon-arrow-right { + background-position: -264px -96px; +} + +.icon-arrow-up { + background-position: -289px -96px; +} + +.icon-arrow-down { + background-position: -312px -96px; +} + +.icon-share-alt { + background-position: -336px -96px; +} + +.icon-resize-full { + background-position: -360px -96px; +} + +.icon-resize-small { + background-position: -384px -96px; +} + +.icon-plus { + background-position: -408px -96px; +} + +.icon-minus { + background-position: -433px -96px; +} + +.icon-asterisk { + background-position: -456px -96px; +} + +.icon-exclamation-sign { + background-position: 0 -120px; +} + +.icon-gift { + background-position: -24px -120px; +} + +.icon-leaf { + background-position: -48px -120px; +} + +.icon-fire { + background-position: -72px -120px; +} + +.icon-eye-open { + background-position: -96px -120px; +} + +.icon-eye-close { + background-position: -120px -120px; +} + +.icon-warning-sign { + background-position: -144px -120px; +} + +.icon-plane { + background-position: -168px -120px; +} + +.icon-calendar { + background-position: -192px -120px; +} + +.icon-random { + width: 16px; + background-position: -216px -120px; +} + +.icon-comment { + background-position: -240px -120px; +} + +.icon-magnet { + background-position: -264px -120px; +} + +.icon-chevron-up { + background-position: -288px -120px; +} + +.icon-chevron-down { + background-position: -313px -119px; +} + +.icon-retweet { + background-position: -336px -120px; +} + +.icon-shopping-cart { + background-position: -360px -120px; +} + +.icon-folder-close { + width: 16px; + background-position: -384px -120px; +} + +.icon-folder-open { + width: 16px; + background-position: -408px -120px; +} + +.icon-resize-vertical { + background-position: -432px -119px; +} + +.icon-resize-horizontal { + background-position: -456px -118px; +} + +.icon-hdd { + background-position: 0 -144px; +} + +.icon-bullhorn { + background-position: -24px -144px; +} + +.icon-bell { + background-position: -48px -144px; +} + +.icon-certificate { + background-position: -72px -144px; +} + +.icon-thumbs-up { + background-position: -96px -144px; +} + +.icon-thumbs-down { + background-position: -120px -144px; +} + +.icon-hand-right { + background-position: -144px -144px; +} + +.icon-hand-left { + background-position: -168px -144px; +} + +.icon-hand-up { + background-position: -192px -144px; +} + +.icon-hand-down { + background-position: -216px -144px; +} + +.icon-circle-arrow-right { + background-position: -240px -144px; +} + +.icon-circle-arrow-left { + background-position: -264px -144px; +} + +.icon-circle-arrow-up { + background-position: -288px -144px; +} + +.icon-circle-arrow-down { + background-position: -312px -144px; +} + +.icon-globe { + background-position: -336px -144px; +} + +.icon-wrench { + background-position: -360px -144px; +} + +.icon-tasks { + background-position: -384px -144px; +} + +.icon-filter { + background-position: -408px -144px; +} + +.icon-briefcase { + background-position: -432px -144px; +} + +.icon-fullscreen { + background-position: -456px -144px; +} + +.dropup, +.dropdown { + position: relative; +} + +.dropdown-toggle { + *margin-bottom: -3px; +} + +.dropdown-toggle:active, +.open .dropdown-toggle { + outline: 0; +} + +.caret { + display: inline-block; + width: 0; + height: 0; + vertical-align: top; + border-top: 4px solid #000000; + border-right: 4px solid transparent; + border-left: 4px solid transparent; + content: ""; +} + +.dropdown .caret { + margin-top: 8px; + margin-left: 2px; +} + +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 2px 0 0; + list-style: none; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + *border-right-width: 2px; + *border-bottom-width: 2px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.dropdown-menu .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.dropdown-menu > li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 20px; + color: #333333; + white-space: nowrap; +} + +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus, +.dropdown-submenu:hover > a, +.dropdown-submenu:focus > a { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .active > a, +.dropdown-menu > .active > a:hover, +.dropdown-menu > .active > a:focus { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + outline: 0; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .disabled > a, +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + color: #999999; +} + +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.open { + *z-index: 1000; +} + +.open > .dropdown-menu { + display: block; +} + +.dropdown-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 990; +} + +.pull-right > .dropdown-menu { + right: 0; + left: auto; +} + +.dropup .caret, +.navbar-fixed-bottom .dropdown .caret { + border-top: 0; + border-bottom: 4px solid #000000; + content: ""; +} + +.dropup .dropdown-menu, +.navbar-fixed-bottom .dropdown .dropdown-menu { + top: auto; + bottom: 100%; + margin-bottom: 1px; +} + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu > .dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + -webkit-border-radius: 0 6px 6px 6px; + -moz-border-radius: 0 6px 6px 6px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover > .dropdown-menu { + display: block; +} + +.dropup .dropdown-submenu > .dropdown-menu { + top: auto; + bottom: 0; + margin-top: 0; + margin-bottom: -2px; + -webkit-border-radius: 5px 5px 5px 0; + -moz-border-radius: 5px 5px 5px 0; + border-radius: 5px 5px 5px 0; +} + +.dropdown-submenu > a:after { + display: block; + float: right; + width: 0; + height: 0; + margin-top: 5px; + margin-right: -10px; + border-color: transparent; + border-left-color: #cccccc; + border-style: solid; + border-width: 5px 0 5px 5px; + content: " "; +} + +.dropdown-submenu:hover > a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left > .dropdown-menu { + left: -100%; + margin-left: 10px; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; +} + +.dropdown .dropdown-menu .nav-header { + padding-right: 20px; + padding-left: 20px; +} + +.typeahead { + z-index: 1051; + margin-top: 2px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.well { + min-height: 20px; + padding: 19px; + margin-bottom: 20px; + background-color: #f5f5f5; + border: 1px solid #e3e3e3; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); +} + +.well blockquote { + border-color: #ddd; + border-color: rgba(0, 0, 0, 0.15); +} + +.well-large { + padding: 24px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.well-small { + padding: 9px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.fade { + opacity: 0; + -webkit-transition: opacity 0.15s linear; + -moz-transition: opacity 0.15s linear; + -o-transition: opacity 0.15s linear; + transition: opacity 0.15s linear; +} + +.fade.in { + opacity: 1; +} + +.collapse { + position: relative; + height: 0; + overflow: hidden; + -webkit-transition: height 0.35s ease; + -moz-transition: height 0.35s ease; + -o-transition: height 0.35s ease; + transition: height 0.35s ease; +} + +.collapse.in { + height: auto; +} + +.close { + float: right; + font-size: 20px; + font-weight: bold; + line-height: 20px; + color: #000000; + text-shadow: 0 1px 0 #ffffff; + opacity: 0.2; + filter: alpha(opacity=20); +} + +.close:hover, +.close:focus { + color: #000000; + text-decoration: none; + cursor: pointer; + opacity: 0.4; + filter: alpha(opacity=40); +} + +button.close { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; +} + +.btn { + display: inline-block; + *display: inline; + padding: 4px 12px; + margin-bottom: 0; + *margin-left: .3em; + font-size: 14px; + line-height: 20px; + color: #333333; + text-align: center; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); + vertical-align: middle; + cursor: pointer; + background-color: #f5f5f5; + *background-color: #e6e6e6; + background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); + background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-repeat: repeat-x; + border: 1px solid #cccccc; + *border: 0; + border-color: #e6e6e6 #e6e6e6 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + border-bottom-color: #b3b3b3; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); + *zoom: 1; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn:hover, +.btn:focus, +.btn:active, +.btn.active, +.btn.disabled, +.btn[disabled] { + color: #333333; + background-color: #e6e6e6; + *background-color: #d9d9d9; +} + +.btn:active, +.btn.active { + background-color: #cccccc \9; +} + +.btn:first-child { + *margin-left: 0; +} + +.btn:hover, +.btn:focus { + color: #333333; + text-decoration: none; + background-position: 0 -15px; + -webkit-transition: background-position 0.1s linear; + -moz-transition: background-position 0.1s linear; + -o-transition: background-position 0.1s linear; + transition: background-position 0.1s linear; +} + +.btn:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +.btn.active, +.btn:active { + background-image: none; + outline: 0; + -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn.disabled, +.btn[disabled] { + cursor: default; + background-image: none; + opacity: 0.65; + filter: alpha(opacity=65); + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.btn-large { + padding: 11px 19px; + font-size: 17.5px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.btn-large [class^="icon-"], +.btn-large [class*=" icon-"] { + margin-top: 4px; +} + +.btn-small { + padding: 2px 10px; + font-size: 11.9px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.btn-small [class^="icon-"], +.btn-small [class*=" icon-"] { + margin-top: 0; +} + +.btn-mini [class^="icon-"], +.btn-mini [class*=" icon-"] { + margin-top: -1px; +} + +.btn-mini { + padding: 0 6px; + font-size: 10.5px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.btn-block { + display: block; + width: 100%; + padding-right: 0; + padding-left: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.btn-block + .btn-block { + margin-top: 5px; +} + +input[type="submit"].btn-block, +input[type="reset"].btn-block, +input[type="button"].btn-block { + width: 100%; +} + +.btn-primary.active, +.btn-warning.active, +.btn-danger.active, +.btn-success.active, +.btn-info.active, +.btn-inverse.active { + color: rgba(255, 255, 255, 0.75); +} + +.btn-primary { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #006dcc; + *background-color: #0044cc; + background-image: -moz-linear-gradient(top, #0088cc, #0044cc); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); + background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); + background-image: -o-linear-gradient(top, #0088cc, #0044cc); + background-image: linear-gradient(to bottom, #0088cc, #0044cc); + background-repeat: repeat-x; + border-color: #0044cc #0044cc #002a80; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-primary:hover, +.btn-primary:focus, +.btn-primary:active, +.btn-primary.active, +.btn-primary.disabled, +.btn-primary[disabled] { + color: #ffffff; + background-color: #0044cc; + *background-color: #003bb3; +} + +.btn-primary:active, +.btn-primary.active { + background-color: #003399 \9; +} + +.btn-warning { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #faa732; + *background-color: #f89406; + background-image: -moz-linear-gradient(top, #fbb450, #f89406); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); + background-image: -webkit-linear-gradient(top, #fbb450, #f89406); + background-image: -o-linear-gradient(top, #fbb450, #f89406); + background-image: linear-gradient(to bottom, #fbb450, #f89406); + background-repeat: repeat-x; + border-color: #f89406 #f89406 #ad6704; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-warning:hover, +.btn-warning:focus, +.btn-warning:active, +.btn-warning.active, +.btn-warning.disabled, +.btn-warning[disabled] { + color: #ffffff; + background-color: #f89406; + *background-color: #df8505; +} + +.btn-warning:active, +.btn-warning.active { + background-color: #c67605 \9; +} + +.btn-danger { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #da4f49; + *background-color: #bd362f; + background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f)); + background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f); + background-image: -o-linear-gradient(top, #ee5f5b, #bd362f); + background-image: linear-gradient(to bottom, #ee5f5b, #bd362f); + background-repeat: repeat-x; + border-color: #bd362f #bd362f #802420; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-danger:hover, +.btn-danger:focus, +.btn-danger:active, +.btn-danger.active, +.btn-danger.disabled, +.btn-danger[disabled] { + color: #ffffff; + background-color: #bd362f; + *background-color: #a9302a; +} + +.btn-danger:active, +.btn-danger.active { + background-color: #942a25 \9; +} + +.btn-success { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #5bb75b; + *background-color: #51a351; + background-image: -moz-linear-gradient(top, #62c462, #51a351); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351)); + background-image: -webkit-linear-gradient(top, #62c462, #51a351); + background-image: -o-linear-gradient(top, #62c462, #51a351); + background-image: linear-gradient(to bottom, #62c462, #51a351); + background-repeat: repeat-x; + border-color: #51a351 #51a351 #387038; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-success:hover, +.btn-success:focus, +.btn-success:active, +.btn-success.active, +.btn-success.disabled, +.btn-success[disabled] { + color: #ffffff; + background-color: #51a351; + *background-color: #499249; +} + +.btn-success:active, +.btn-success.active { + background-color: #408140 \9; +} + +.btn-info { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #49afcd; + *background-color: #2f96b4; + background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4)); + background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4); + background-image: -o-linear-gradient(top, #5bc0de, #2f96b4); + background-image: linear-gradient(to bottom, #5bc0de, #2f96b4); + background-repeat: repeat-x; + border-color: #2f96b4 #2f96b4 #1f6377; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-info:hover, +.btn-info:focus, +.btn-info:active, +.btn-info.active, +.btn-info.disabled, +.btn-info[disabled] { + color: #ffffff; + background-color: #2f96b4; + *background-color: #2a85a0; +} + +.btn-info:active, +.btn-info.active { + background-color: #24748c \9; +} + +.btn-inverse { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #363636; + *background-color: #222222; + background-image: -moz-linear-gradient(top, #444444, #222222); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222)); + background-image: -webkit-linear-gradient(top, #444444, #222222); + background-image: -o-linear-gradient(top, #444444, #222222); + background-image: linear-gradient(to bottom, #444444, #222222); + background-repeat: repeat-x; + border-color: #222222 #222222 #000000; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-inverse:hover, +.btn-inverse:focus, +.btn-inverse:active, +.btn-inverse.active, +.btn-inverse.disabled, +.btn-inverse[disabled] { + color: #ffffff; + background-color: #222222; + *background-color: #151515; +} + +.btn-inverse:active, +.btn-inverse.active { + background-color: #080808 \9; +} + +button.btn, +input[type="submit"].btn { + *padding-top: 3px; + *padding-bottom: 3px; +} + +button.btn::-moz-focus-inner, +input[type="submit"].btn::-moz-focus-inner { + padding: 0; + border: 0; +} + +button.btn.btn-large, +input[type="submit"].btn.btn-large { + *padding-top: 7px; + *padding-bottom: 7px; +} + +button.btn.btn-small, +input[type="submit"].btn.btn-small { + *padding-top: 3px; + *padding-bottom: 3px; +} + +button.btn.btn-mini, +input[type="submit"].btn.btn-mini { + *padding-top: 1px; + *padding-bottom: 1px; +} + +.btn-link, +.btn-link:active, +.btn-link[disabled] { + background-color: transparent; + background-image: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.btn-link { + color: #0088cc; + cursor: pointer; + border-color: transparent; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-link:hover, +.btn-link:focus { + color: #005580; + text-decoration: underline; + background-color: transparent; +} + +.btn-link[disabled]:hover, +.btn-link[disabled]:focus { + color: #333333; + text-decoration: none; +} + +.btn-group { + position: relative; + display: inline-block; + *display: inline; + *margin-left: .3em; + font-size: 0; + white-space: nowrap; + vertical-align: middle; + *zoom: 1; +} + +.btn-group:first-child { + *margin-left: 0; +} + +.btn-group + .btn-group { + margin-left: 5px; +} + +.btn-toolbar { + margin-top: 10px; + margin-bottom: 10px; + font-size: 0; +} + +.btn-toolbar > .btn + .btn, +.btn-toolbar > .btn-group + .btn, +.btn-toolbar > .btn + .btn-group { + margin-left: 5px; +} + +.btn-group > .btn { + position: relative; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-group > .btn + .btn { + margin-left: -1px; +} + +.btn-group > .btn, +.btn-group > .dropdown-menu, +.btn-group > .popover { + font-size: 14px; +} + +.btn-group > .btn-mini { + font-size: 10.5px; +} + +.btn-group > .btn-small { + font-size: 11.9px; +} + +.btn-group > .btn-large { + font-size: 17.5px; +} + +.btn-group > .btn:first-child { + margin-left: 0; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-topleft: 4px; +} + +.btn-group > .btn:last-child, +.btn-group > .dropdown-toggle { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-bottomright: 4px; +} + +.btn-group > .btn.large:first-child { + margin-left: 0; + -webkit-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -webkit-border-top-left-radius: 6px; + border-top-left-radius: 6px; + -moz-border-radius-bottomleft: 6px; + -moz-border-radius-topleft: 6px; +} + +.btn-group > .btn.large:last-child, +.btn-group > .large.dropdown-toggle { + -webkit-border-top-right-radius: 6px; + border-top-right-radius: 6px; + -webkit-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + -moz-border-radius-topright: 6px; + -moz-border-radius-bottomright: 6px; +} + +.btn-group > .btn:hover, +.btn-group > .btn:focus, +.btn-group > .btn:active, +.btn-group > .btn.active { + z-index: 2; +} + +.btn-group .dropdown-toggle:active, +.btn-group.open .dropdown-toggle { + outline: 0; +} + +.btn-group > .btn + .dropdown-toggle { + *padding-top: 5px; + padding-right: 8px; + *padding-bottom: 5px; + padding-left: 8px; + -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn-group > .btn-mini + .dropdown-toggle { + *padding-top: 2px; + padding-right: 5px; + *padding-bottom: 2px; + padding-left: 5px; +} + +.btn-group > .btn-small + .dropdown-toggle { + *padding-top: 5px; + *padding-bottom: 4px; +} + +.btn-group > .btn-large + .dropdown-toggle { + *padding-top: 7px; + padding-right: 12px; + *padding-bottom: 7px; + padding-left: 12px; +} + +.btn-group.open .dropdown-toggle { + background-image: none; + -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn-group.open .btn.dropdown-toggle { + background-color: #e6e6e6; +} + +.btn-group.open .btn-primary.dropdown-toggle { + background-color: #0044cc; +} + +.btn-group.open .btn-warning.dropdown-toggle { + background-color: #f89406; +} + +.btn-group.open .btn-danger.dropdown-toggle { + background-color: #bd362f; +} + +.btn-group.open .btn-success.dropdown-toggle { + background-color: #51a351; +} + +.btn-group.open .btn-info.dropdown-toggle { + background-color: #2f96b4; +} + +.btn-group.open .btn-inverse.dropdown-toggle { + background-color: #222222; +} + +.btn .caret { + margin-top: 8px; + margin-left: 0; +} + +.btn-large .caret { + margin-top: 6px; +} + +.btn-large .caret { + border-top-width: 5px; + border-right-width: 5px; + border-left-width: 5px; +} + +.btn-mini .caret, +.btn-small .caret { + margin-top: 8px; +} + +.dropup .btn-large .caret { + border-bottom-width: 5px; +} + +.btn-primary .caret, +.btn-warning .caret, +.btn-danger .caret, +.btn-info .caret, +.btn-success .caret, +.btn-inverse .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.btn-group-vertical { + display: inline-block; + *display: inline; + /* IE7 inline-block hack */ + + *zoom: 1; +} + +.btn-group-vertical > .btn { + display: block; + float: none; + max-width: 100%; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-group-vertical > .btn + .btn { + margin-top: -1px; + margin-left: 0; +} + +.btn-group-vertical > .btn:first-child { + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +.btn-group-vertical > .btn:last-child { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius: 0 0 4px 4px; + border-radius: 0 0 4px 4px; +} + +.btn-group-vertical > .btn-large:first-child { + -webkit-border-radius: 6px 6px 0 0; + -moz-border-radius: 6px 6px 0 0; + border-radius: 6px 6px 0 0; +} + +.btn-group-vertical > .btn-large:last-child { + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; +} + +.alert { + padding: 8px 35px 8px 14px; + margin-bottom: 20px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + background-color: #fcf8e3; + border: 1px solid #fbeed5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.alert, +.alert h4 { + color: #c09853; +} + +.alert h4 { + margin: 0; +} + +.alert .close { + position: relative; + top: -2px; + right: -21px; + line-height: 20px; +} + +.alert-success { + color: #468847; + background-color: #dff0d8; + border-color: #d6e9c6; +} + +.alert-success h4 { + color: #468847; +} + +.alert-danger, +.alert-error { + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; +} + +.alert-danger h4, +.alert-error h4 { + color: #b94a48; +} + +.alert-info { + color: #3a87ad; + background-color: #d9edf7; + border-color: #bce8f1; +} + +.alert-info h4 { + color: #3a87ad; +} + +.alert-block { + padding-top: 14px; + padding-bottom: 14px; +} + +.alert-block > p, +.alert-block > ul { + margin-bottom: 0; +} + +.alert-block p + p { + margin-top: 5px; +} + +.nav { + margin-bottom: 20px; + margin-left: 0; + list-style: none; +} + +.nav > li > a { + display: block; +} + +.nav > li > a:hover, +.nav > li > a:focus { + text-decoration: none; + background-color: #eeeeee; +} + +.nav > li > a > img { + max-width: none; +} + +.nav > .pull-right { + float: right; +} + +.nav-header { + display: block; + padding: 3px 15px; + font-size: 11px; + font-weight: bold; + line-height: 20px; + color: #999999; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + text-transform: uppercase; +} + +.nav li + .nav-header { + margin-top: 9px; +} + +.nav-list { + padding-right: 15px; + padding-left: 15px; + margin-bottom: 0; +} + +.nav-list > li > a, +.nav-list .nav-header { + margin-right: -15px; + margin-left: -15px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); +} + +.nav-list > li > a { + padding: 3px 15px; +} + +.nav-list > .active > a, +.nav-list > .active > a:hover, +.nav-list > .active > a:focus { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); + background-color: #0088cc; +} + +.nav-list [class^="icon-"], +.nav-list [class*=" icon-"] { + margin-right: 2px; +} + +.nav-list .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.nav-tabs, +.nav-pills { + *zoom: 1; +} + +.nav-tabs:before, +.nav-pills:before, +.nav-tabs:after, +.nav-pills:after { + display: table; + line-height: 0; + content: ""; +} + +.nav-tabs:after, +.nav-pills:after { + clear: both; +} + +.nav-tabs > li, +.nav-pills > li { + float: left; +} + +.nav-tabs > li > a, +.nav-pills > li > a { + padding-right: 12px; + padding-left: 12px; + margin-right: 2px; + line-height: 14px; +} + +.nav-tabs { + border-bottom: 1px solid #ddd; +} + +.nav-tabs > li { + margin-bottom: -1px; +} + +.nav-tabs > li > a { + padding-top: 8px; + padding-bottom: 8px; + line-height: 20px; + border: 1px solid transparent; + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +.nav-tabs > li > a:hover, +.nav-tabs > li > a:focus { + border-color: #eeeeee #eeeeee #dddddd; +} + +.nav-tabs > .active > a, +.nav-tabs > .active > a:hover, +.nav-tabs > .active > a:focus { + color: #555555; + cursor: default; + background-color: #ffffff; + border: 1px solid #ddd; + border-bottom-color: transparent; +} + +.nav-pills > li > a { + padding-top: 8px; + padding-bottom: 8px; + margin-top: 2px; + margin-bottom: 2px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.nav-pills > .active > a, +.nav-pills > .active > a:hover, +.nav-pills > .active > a:focus { + color: #ffffff; + background-color: #0088cc; +} + +.nav-stacked > li { + float: none; +} + +.nav-stacked > li > a { + margin-right: 0; +} + +.nav-tabs.nav-stacked { + border-bottom: 0; +} + +.nav-tabs.nav-stacked > li > a { + border: 1px solid #ddd; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.nav-tabs.nav-stacked > li:first-child > a { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-topleft: 4px; +} + +.nav-tabs.nav-stacked > li:last-child > a { + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomright: 4px; + -moz-border-radius-bottomleft: 4px; +} + +.nav-tabs.nav-stacked > li > a:hover, +.nav-tabs.nav-stacked > li > a:focus { + z-index: 2; + border-color: #ddd; +} + +.nav-pills.nav-stacked > li > a { + margin-bottom: 3px; +} + +.nav-pills.nav-stacked > li:last-child > a { + margin-bottom: 1px; +} + +.nav-tabs .dropdown-menu { + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; +} + +.nav-pills .dropdown-menu { + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.nav .dropdown-toggle .caret { + margin-top: 6px; + border-top-color: #0088cc; + border-bottom-color: #0088cc; +} + +.nav .dropdown-toggle:hover .caret, +.nav .dropdown-toggle:focus .caret { + border-top-color: #005580; + border-bottom-color: #005580; +} + +/* move down carets for tabs */ + +.nav-tabs .dropdown-toggle .caret { + margin-top: 8px; +} + +.nav .active .dropdown-toggle .caret { + border-top-color: #fff; + border-bottom-color: #fff; +} + +.nav-tabs .active .dropdown-toggle .caret { + border-top-color: #555555; + border-bottom-color: #555555; +} + +.nav > .dropdown.active > a:hover, +.nav > .dropdown.active > a:focus { + cursor: pointer; +} + +.nav-tabs .open .dropdown-toggle, +.nav-pills .open .dropdown-toggle, +.nav > li.dropdown.open.active > a:hover, +.nav > li.dropdown.open.active > a:focus { + color: #ffffff; + background-color: #999999; + border-color: #999999; +} + +.nav li.dropdown.open .caret, +.nav li.dropdown.open.active .caret, +.nav li.dropdown.open a:hover .caret, +.nav li.dropdown.open a:focus .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; + opacity: 1; + filter: alpha(opacity=100); +} + +.tabs-stacked .open > a:hover, +.tabs-stacked .open > a:focus { + border-color: #999999; +} + +.tabbable { + *zoom: 1; +} + +.tabbable:before, +.tabbable:after { + display: table; + line-height: 0; + content: ""; +} + +.tabbable:after { + clear: both; +} + +.tab-content { + overflow: auto; +} + +.tabs-below > .nav-tabs, +.tabs-right > .nav-tabs, +.tabs-left > .nav-tabs { + border-bottom: 0; +} + +.tab-content > .tab-pane, +.pill-content > .pill-pane { + display: none; +} + +.tab-content > .active, +.pill-content > .active { + display: block; +} + +.tabs-below > .nav-tabs { + border-top: 1px solid #ddd; +} + +.tabs-below > .nav-tabs > li { + margin-top: -1px; + margin-bottom: 0; +} + +.tabs-below > .nav-tabs > li > a { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius: 0 0 4px 4px; + border-radius: 0 0 4px 4px; +} + +.tabs-below > .nav-tabs > li > a:hover, +.tabs-below > .nav-tabs > li > a:focus { + border-top-color: #ddd; + border-bottom-color: transparent; +} + +.tabs-below > .nav-tabs > .active > a, +.tabs-below > .nav-tabs > .active > a:hover, +.tabs-below > .nav-tabs > .active > a:focus { + border-color: transparent #ddd #ddd #ddd; +} + +.tabs-left > .nav-tabs > li, +.tabs-right > .nav-tabs > li { + float: none; +} + +.tabs-left > .nav-tabs > li > a, +.tabs-right > .nav-tabs > li > a { + min-width: 74px; + margin-right: 0; + margin-bottom: 3px; +} + +.tabs-left > .nav-tabs { + float: left; + margin-right: 19px; + border-right: 1px solid #ddd; +} + +.tabs-left > .nav-tabs > li > a { + margin-right: -1px; + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.tabs-left > .nav-tabs > li > a:hover, +.tabs-left > .nav-tabs > li > a:focus { + border-color: #eeeeee #dddddd #eeeeee #eeeeee; +} + +.tabs-left > .nav-tabs .active > a, +.tabs-left > .nav-tabs .active > a:hover, +.tabs-left > .nav-tabs .active > a:focus { + border-color: #ddd transparent #ddd #ddd; + *border-right-color: #ffffff; +} + +.tabs-right > .nav-tabs { + float: right; + margin-left: 19px; + border-left: 1px solid #ddd; +} + +.tabs-right > .nav-tabs > li > a { + margin-left: -1px; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.tabs-right > .nav-tabs > li > a:hover, +.tabs-right > .nav-tabs > li > a:focus { + border-color: #eeeeee #eeeeee #eeeeee #dddddd; +} + +.tabs-right > .nav-tabs .active > a, +.tabs-right > .nav-tabs .active > a:hover, +.tabs-right > .nav-tabs .active > a:focus { + border-color: #ddd #ddd #ddd transparent; + *border-left-color: #ffffff; +} + +.nav > .disabled > a { + color: #999999; +} + +.nav > .disabled > a:hover, +.nav > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; +} + +.navbar { + *position: relative; + *z-index: 2; + margin-bottom: 20px; + overflow: visible; +} + +.navbar-inner { + min-height: 40px; + padding-right: 20px; + padding-left: 20px; + background-color: #fafafa; + background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2)); + background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2); + background-image: -o-linear-gradient(top, #ffffff, #f2f2f2); + background-image: linear-gradient(to bottom, #ffffff, #f2f2f2); + background-repeat: repeat-x; + border: 1px solid #d4d4d4; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0); + *zoom: 1; + -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); + -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); + box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); +} + +.navbar-inner:before, +.navbar-inner:after { + display: table; + line-height: 0; + content: ""; +} + +.navbar-inner:after { + clear: both; +} + +.navbar .container { + width: auto; +} + +.nav-collapse.collapse { + height: auto; + overflow: visible; +} + +.navbar .brand { + display: block; + float: left; + padding: 10px 20px 10px; + margin-left: -20px; + font-size: 20px; + font-weight: 200; + color: #777777; + text-shadow: 0 1px 0 #ffffff; +} + +.navbar .brand:hover, +.navbar .brand:focus { + text-decoration: none; +} + +.navbar-text { + margin-bottom: 0; + line-height: 40px; + color: #777777; +} + +.navbar-link { + color: #777777; +} + +.navbar-link:hover, +.navbar-link:focus { + color: #333333; +} + +.navbar .divider-vertical { + height: 40px; + margin: 0 9px; + border-right: 1px solid #ffffff; + border-left: 1px solid #f2f2f2; +} + +.navbar .btn, +.navbar .btn-group { + margin-top: 5px; +} + +.navbar .btn-group .btn, +.navbar .input-prepend .btn, +.navbar .input-append .btn, +.navbar .input-prepend .btn-group, +.navbar .input-append .btn-group { + margin-top: 0; +} + +.navbar-form { + margin-bottom: 0; + *zoom: 1; +} + +.navbar-form:before, +.navbar-form:after { + display: table; + line-height: 0; + content: ""; +} + +.navbar-form:after { + clear: both; +} + +.navbar-form input, +.navbar-form select, +.navbar-form .radio, +.navbar-form .checkbox { + margin-top: 5px; +} + +.navbar-form input, +.navbar-form select, +.navbar-form .btn { + display: inline-block; + margin-bottom: 0; +} + +.navbar-form input[type="image"], +.navbar-form input[type="checkbox"], +.navbar-form input[type="radio"] { + margin-top: 3px; +} + +.navbar-form .input-append, +.navbar-form .input-prepend { + margin-top: 5px; + white-space: nowrap; +} + +.navbar-form .input-append input, +.navbar-form .input-prepend input { + margin-top: 0; +} + +.navbar-search { + position: relative; + float: left; + margin-top: 5px; + margin-bottom: 0; +} + +.navbar-search .search-query { + padding: 4px 14px; + margin-bottom: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 13px; + font-weight: normal; + line-height: 1; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +.navbar-static-top { + position: static; + margin-bottom: 0; +} + +.navbar-static-top .navbar-inner { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.navbar-fixed-top, +.navbar-fixed-bottom { + position: fixed; + right: 0; + left: 0; + z-index: 1030; + margin-bottom: 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-static-top .navbar-inner { + border-width: 0 0 1px; +} + +.navbar-fixed-bottom .navbar-inner { + border-width: 1px 0 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-fixed-bottom .navbar-inner { + padding-right: 0; + padding-left: 0; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.navbar-static-top .container, +.navbar-fixed-top .container, +.navbar-fixed-bottom .container { + width: 940px; +} + +.navbar-fixed-top { + top: 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-static-top .navbar-inner { + -webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); +} + +.navbar-fixed-bottom { + bottom: 0; +} + +.navbar-fixed-bottom .navbar-inner { + -webkit-box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); + box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); +} + +.navbar .nav { + position: relative; + left: 0; + display: block; + float: left; + margin: 0 10px 0 0; +} + +.navbar .nav.pull-right { + float: right; + margin-right: 0; +} + +.navbar .nav > li { + float: left; +} + +.navbar .nav > li > a { + float: none; + padding: 10px 15px 10px; + color: #777777; + text-decoration: none; + text-shadow: 0 1px 0 #ffffff; +} + +.navbar .nav .dropdown-toggle .caret { + margin-top: 8px; +} + +.navbar .nav > li > a:focus, +.navbar .nav > li > a:hover { + color: #333333; + text-decoration: none; + background-color: transparent; +} + +.navbar .nav > .active > a, +.navbar .nav > .active > a:hover, +.navbar .nav > .active > a:focus { + color: #555555; + text-decoration: none; + background-color: #e5e5e5; + -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); + -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); + box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); +} + +.navbar .btn-navbar { + display: none; + float: right; + padding: 7px 10px; + margin-right: 5px; + margin-left: 5px; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #ededed; + *background-color: #e5e5e5; + background-image: -moz-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#e5e5e5)); + background-image: -webkit-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: -o-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: linear-gradient(to bottom, #f2f2f2, #e5e5e5); + background-repeat: repeat-x; + border-color: #e5e5e5 #e5e5e5 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffe5e5e5', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); +} + +.navbar .btn-navbar:hover, +.navbar .btn-navbar:focus, +.navbar .btn-navbar:active, +.navbar .btn-navbar.active, +.navbar .btn-navbar.disabled, +.navbar .btn-navbar[disabled] { + color: #ffffff; + background-color: #e5e5e5; + *background-color: #d9d9d9; +} + +.navbar .btn-navbar:active, +.navbar .btn-navbar.active { + background-color: #cccccc \9; +} + +.navbar .btn-navbar .icon-bar { + display: block; + width: 18px; + height: 2px; + background-color: #f5f5f5; + -webkit-border-radius: 1px; + -moz-border-radius: 1px; + border-radius: 1px; + -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); + -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-navbar .icon-bar + .icon-bar { + margin-top: 3px; +} + +.navbar .nav > li > .dropdown-menu:before { + position: absolute; + top: -7px; + left: 9px; + display: inline-block; + border-right: 7px solid transparent; + border-bottom: 7px solid #ccc; + border-left: 7px solid transparent; + border-bottom-color: rgba(0, 0, 0, 0.2); + content: ''; +} + +.navbar .nav > li > .dropdown-menu:after { + position: absolute; + top: -6px; + left: 10px; + display: inline-block; + border-right: 6px solid transparent; + border-bottom: 6px solid #ffffff; + border-left: 6px solid transparent; + content: ''; +} + +.navbar-fixed-bottom .nav > li > .dropdown-menu:before { + top: auto; + bottom: -7px; + border-top: 7px solid #ccc; + border-bottom: 0; + border-top-color: rgba(0, 0, 0, 0.2); +} + +.navbar-fixed-bottom .nav > li > .dropdown-menu:after { + top: auto; + bottom: -6px; + border-top: 6px solid #ffffff; + border-bottom: 0; +} + +.navbar .nav li.dropdown > a:hover .caret, +.navbar .nav li.dropdown > a:focus .caret { + border-top-color: #333333; + border-bottom-color: #333333; +} + +.navbar .nav li.dropdown.open > .dropdown-toggle, +.navbar .nav li.dropdown.active > .dropdown-toggle, +.navbar .nav li.dropdown.open.active > .dropdown-toggle { + color: #555555; + background-color: #e5e5e5; +} + +.navbar .nav li.dropdown > .dropdown-toggle .caret { + border-top-color: #777777; + border-bottom-color: #777777; +} + +.navbar .nav li.dropdown.open > .dropdown-toggle .caret, +.navbar .nav li.dropdown.active > .dropdown-toggle .caret, +.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret { + border-top-color: #555555; + border-bottom-color: #555555; +} + +.navbar .pull-right > li > .dropdown-menu, +.navbar .nav > li > .dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu:before, +.navbar .nav > li > .dropdown-menu.pull-right:before { + right: 12px; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu:after, +.navbar .nav > li > .dropdown-menu.pull-right:after { + right: 13px; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu .dropdown-menu, +.navbar .nav > li > .dropdown-menu.pull-right .dropdown-menu { + right: 100%; + left: auto; + margin-right: -1px; + margin-left: 0; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; +} + +.navbar-inverse .navbar-inner { + background-color: #1b1b1b; + background-image: -moz-linear-gradient(top, #222222, #111111); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#222222), to(#111111)); + background-image: -webkit-linear-gradient(top, #222222, #111111); + background-image: -o-linear-gradient(top, #222222, #111111); + background-image: linear-gradient(to bottom, #222222, #111111); + background-repeat: repeat-x; + border-color: #252525; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff222222', endColorstr='#ff111111', GradientType=0); +} + +.navbar-inverse .brand, +.navbar-inverse .nav > li > a { + color: #999999; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.navbar-inverse .brand:hover, +.navbar-inverse .nav > li > a:hover, +.navbar-inverse .brand:focus, +.navbar-inverse .nav > li > a:focus { + color: #ffffff; +} + +.navbar-inverse .brand { + color: #999999; +} + +.navbar-inverse .navbar-text { + color: #999999; +} + +.navbar-inverse .nav > li > a:focus, +.navbar-inverse .nav > li > a:hover { + color: #ffffff; + background-color: transparent; +} + +.navbar-inverse .nav .active > a, +.navbar-inverse .nav .active > a:hover, +.navbar-inverse .nav .active > a:focus { + color: #ffffff; + background-color: #111111; +} + +.navbar-inverse .navbar-link { + color: #999999; +} + +.navbar-inverse .navbar-link:hover, +.navbar-inverse .navbar-link:focus { + color: #ffffff; +} + +.navbar-inverse .divider-vertical { + border-right-color: #222222; + border-left-color: #111111; +} + +.navbar-inverse .nav li.dropdown.open > .dropdown-toggle, +.navbar-inverse .nav li.dropdown.active > .dropdown-toggle, +.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle { + color: #ffffff; + background-color: #111111; +} + +.navbar-inverse .nav li.dropdown > a:hover .caret, +.navbar-inverse .nav li.dropdown > a:focus .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.navbar-inverse .nav li.dropdown > .dropdown-toggle .caret { + border-top-color: #999999; + border-bottom-color: #999999; +} + +.navbar-inverse .nav li.dropdown.open > .dropdown-toggle .caret, +.navbar-inverse .nav li.dropdown.active > .dropdown-toggle .caret, +.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.navbar-inverse .navbar-search .search-query { + color: #ffffff; + background-color: #515151; + border-color: #111111; + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + -webkit-transition: none; + -moz-transition: none; + -o-transition: none; + transition: none; +} + +.navbar-inverse .navbar-search .search-query:-moz-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query:-ms-input-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query:focus, +.navbar-inverse .navbar-search .search-query.focused { + padding: 5px 15px; + color: #333333; + text-shadow: 0 1px 0 #ffffff; + background-color: #ffffff; + border: 0; + outline: 0; + -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); + -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); + box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); +} + +.navbar-inverse .btn-navbar { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #0e0e0e; + *background-color: #040404; + background-image: -moz-linear-gradient(top, #151515, #040404); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#151515), to(#040404)); + background-image: -webkit-linear-gradient(top, #151515, #040404); + background-image: -o-linear-gradient(top, #151515, #040404); + background-image: linear-gradient(to bottom, #151515, #040404); + background-repeat: repeat-x; + border-color: #040404 #040404 #000000; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515', endColorstr='#ff040404', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.navbar-inverse .btn-navbar:hover, +.navbar-inverse .btn-navbar:focus, +.navbar-inverse .btn-navbar:active, +.navbar-inverse .btn-navbar.active, +.navbar-inverse .btn-navbar.disabled, +.navbar-inverse .btn-navbar[disabled] { + color: #ffffff; + background-color: #040404; + *background-color: #000000; +} + +.navbar-inverse .btn-navbar:active, +.navbar-inverse .btn-navbar.active { + background-color: #000000 \9; +} + +.breadcrumb { + padding: 8px 15px; + margin: 0 0 20px; + list-style: none; + background-color: #f5f5f5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.breadcrumb > li { + display: inline-block; + *display: inline; + text-shadow: 0 1px 0 #ffffff; + *zoom: 1; +} + +.breadcrumb > li > .divider { + padding: 0 5px; + color: #ccc; +} + +.breadcrumb > .active { + color: #999999; +} + +.pagination { + margin: 20px 0; +} + +.pagination ul { + display: inline-block; + *display: inline; + margin-bottom: 0; + margin-left: 0; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + *zoom: 1; + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.pagination ul > li { + display: inline; +} + +.pagination ul > li > a, +.pagination ul > li > span { + float: left; + padding: 4px 12px; + line-height: 20px; + text-decoration: none; + background-color: #ffffff; + border: 1px solid #dddddd; + border-left-width: 0; +} + +.pagination ul > li > a:hover, +.pagination ul > li > a:focus, +.pagination ul > .active > a, +.pagination ul > .active > span { + background-color: #f5f5f5; +} + +.pagination ul > .active > a, +.pagination ul > .active > span { + color: #999999; + cursor: default; +} + +.pagination ul > .disabled > span, +.pagination ul > .disabled > a, +.pagination ul > .disabled > a:hover, +.pagination ul > .disabled > a:focus { + color: #999999; + cursor: default; + background-color: transparent; +} + +.pagination ul > li:first-child > a, +.pagination ul > li:first-child > span { + border-left-width: 1px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-topleft: 4px; +} + +.pagination ul > li:last-child > a, +.pagination ul > li:last-child > span { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-bottomright: 4px; +} + +.pagination-centered { + text-align: center; +} + +.pagination-right { + text-align: right; +} + +.pagination-large ul > li > a, +.pagination-large ul > li > span { + padding: 11px 19px; + font-size: 17.5px; +} + +.pagination-large ul > li:first-child > a, +.pagination-large ul > li:first-child > span { + -webkit-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -webkit-border-top-left-radius: 6px; + border-top-left-radius: 6px; + -moz-border-radius-bottomleft: 6px; + -moz-border-radius-topleft: 6px; +} + +.pagination-large ul > li:last-child > a, +.pagination-large ul > li:last-child > span { + -webkit-border-top-right-radius: 6px; + border-top-right-radius: 6px; + -webkit-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + -moz-border-radius-topright: 6px; + -moz-border-radius-bottomright: 6px; +} + +.pagination-mini ul > li:first-child > a, +.pagination-small ul > li:first-child > a, +.pagination-mini ul > li:first-child > span, +.pagination-small ul > li:first-child > span { + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -moz-border-radius-topleft: 3px; +} + +.pagination-mini ul > li:last-child > a, +.pagination-small ul > li:last-child > a, +.pagination-mini ul > li:last-child > span, +.pagination-small ul > li:last-child > span { + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; + -webkit-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; + -moz-border-radius-topright: 3px; + -moz-border-radius-bottomright: 3px; +} + +.pagination-small ul > li > a, +.pagination-small ul > li > span { + padding: 2px 10px; + font-size: 11.9px; +} + +.pagination-mini ul > li > a, +.pagination-mini ul > li > span { + padding: 0 6px; + font-size: 10.5px; +} + +.pager { + margin: 20px 0; + text-align: center; + list-style: none; + *zoom: 1; +} + +.pager:before, +.pager:after { + display: table; + line-height: 0; + content: ""; +} + +.pager:after { + clear: both; +} + +.pager li { + display: inline; +} + +.pager li > a, +.pager li > span { + display: inline-block; + padding: 5px 14px; + background-color: #fff; + border: 1px solid #ddd; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +.pager li > a:hover, +.pager li > a:focus { + text-decoration: none; + background-color: #f5f5f5; +} + +.pager .next > a, +.pager .next > span { + float: right; +} + +.pager .previous > a, +.pager .previous > span { + float: left; +} + +.pager .disabled > a, +.pager .disabled > a:hover, +.pager .disabled > a:focus, +.pager .disabled > span { + color: #999999; + cursor: default; + background-color: #fff; +} + +.modal-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1040; + background-color: #000000; +} + +.modal-backdrop.fade { + opacity: 0; +} + +.modal-backdrop, +.modal-backdrop.fade.in { + opacity: 0.8; + filter: alpha(opacity=80); +} + +.modal { + position: fixed; + top: 10%; + left: 50%; + z-index: 1050; + width: 560px; + margin-left: -280px; + background-color: #ffffff; + border: 1px solid #999; + border: 1px solid rgba(0, 0, 0, 0.3); + *border: 1px solid #999; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + outline: none; + -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + -webkit-background-clip: padding-box; + -moz-background-clip: padding-box; + background-clip: padding-box; +} + +.modal.fade { + top: -25%; + -webkit-transition: opacity 0.3s linear, top 0.3s ease-out; + -moz-transition: opacity 0.3s linear, top 0.3s ease-out; + -o-transition: opacity 0.3s linear, top 0.3s ease-out; + transition: opacity 0.3s linear, top 0.3s ease-out; +} + +.modal.fade.in { + top: 10%; +} + +.modal-header { + padding: 9px 15px; + border-bottom: 1px solid #eee; +} + +.modal-header .close { + margin-top: 2px; +} + +.modal-header h3 { + margin: 0; + line-height: 30px; +} + +.modal-body { + position: relative; + max-height: 400px; + padding: 15px; + overflow-y: auto; +} + +.modal-form { + margin-bottom: 0; +} + +.modal-footer { + padding: 14px 15px 15px; + margin-bottom: 0; + text-align: right; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; + *zoom: 1; + -webkit-box-shadow: inset 0 1px 0 #ffffff; + -moz-box-shadow: inset 0 1px 0 #ffffff; + box-shadow: inset 0 1px 0 #ffffff; +} + +.modal-footer:before, +.modal-footer:after { + display: table; + line-height: 0; + content: ""; +} + +.modal-footer:after { + clear: both; +} + +.modal-footer .btn + .btn { + margin-bottom: 0; + margin-left: 5px; +} + +.modal-footer .btn-group .btn + .btn { + margin-left: -1px; +} + +.modal-footer .btn-block + .btn-block { + margin-left: 0; +} + +.tooltip { + position: absolute; + z-index: 1030; + display: block; + font-size: 11px; + line-height: 1.4; + opacity: 0; + filter: alpha(opacity=0); + visibility: visible; +} + +.tooltip.in { + opacity: 0.8; + filter: alpha(opacity=80); +} + +.tooltip.top { + padding: 5px 0; + margin-top: -3px; +} + +.tooltip.right { + padding: 0 5px; + margin-left: 3px; +} + +.tooltip.bottom { + padding: 5px 0; + margin-top: 3px; +} + +.tooltip.left { + padding: 0 5px; + margin-left: -3px; +} + +.tooltip-inner { + max-width: 200px; + padding: 8px; + color: #ffffff; + text-align: center; + text-decoration: none; + background-color: #000000; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.tooltip-arrow { + position: absolute; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} + +.tooltip.top .tooltip-arrow { + bottom: 0; + left: 50%; + margin-left: -5px; + border-top-color: #000000; + border-width: 5px 5px 0; +} + +.tooltip.right .tooltip-arrow { + top: 50%; + left: 0; + margin-top: -5px; + border-right-color: #000000; + border-width: 5px 5px 5px 0; +} + +.tooltip.left .tooltip-arrow { + top: 50%; + right: 0; + margin-top: -5px; + border-left-color: #000000; + border-width: 5px 0 5px 5px; +} + +.tooltip.bottom .tooltip-arrow { + top: 0; + left: 50%; + margin-left: -5px; + border-bottom-color: #000000; + border-width: 0 5px 5px; +} + +.popover { + position: absolute; + top: 0; + left: 0; + z-index: 1010; + display: none; + max-width: 276px; + padding: 1px; + text-align: left; + white-space: normal; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.popover.top { + margin-top: -10px; +} + +.popover.right { + margin-left: 10px; +} + +.popover.bottom { + margin-top: 10px; +} + +.popover.left { + margin-left: -10px; +} + +.popover-title { + padding: 8px 14px; + margin: 0; + font-size: 14px; + font-weight: normal; + line-height: 18px; + background-color: #f7f7f7; + border-bottom: 1px solid #ebebeb; + -webkit-border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + border-radius: 5px 5px 0 0; +} + +.popover-title:empty { + display: none; +} + +.popover-content { + padding: 9px 14px; +} + +.popover .arrow, +.popover .arrow:after { + position: absolute; + display: block; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} + +.popover .arrow { + border-width: 11px; +} + +.popover .arrow:after { + border-width: 10px; + content: ""; +} + +.popover.top .arrow { + bottom: -11px; + left: 50%; + margin-left: -11px; + border-top-color: #999; + border-top-color: rgba(0, 0, 0, 0.25); + border-bottom-width: 0; +} + +.popover.top .arrow:after { + bottom: 1px; + margin-left: -10px; + border-top-color: #ffffff; + border-bottom-width: 0; +} + +.popover.right .arrow { + top: 50%; + left: -11px; + margin-top: -11px; + border-right-color: #999; + border-right-color: rgba(0, 0, 0, 0.25); + border-left-width: 0; +} + +.popover.right .arrow:after { + bottom: -10px; + left: 1px; + border-right-color: #ffffff; + border-left-width: 0; +} + +.popover.bottom .arrow { + top: -11px; + left: 50%; + margin-left: -11px; + border-bottom-color: #999; + border-bottom-color: rgba(0, 0, 0, 0.25); + border-top-width: 0; +} + +.popover.bottom .arrow:after { + top: 1px; + margin-left: -10px; + border-bottom-color: #ffffff; + border-top-width: 0; +} + +.popover.left .arrow { + top: 50%; + right: -11px; + margin-top: -11px; + border-left-color: #999; + border-left-color: rgba(0, 0, 0, 0.25); + border-right-width: 0; +} + +.popover.left .arrow:after { + right: 1px; + bottom: -10px; + border-left-color: #ffffff; + border-right-width: 0; +} + +.thumbnails { + margin-left: -20px; + list-style: none; + *zoom: 1; +} + +.thumbnails:before, +.thumbnails:after { + display: table; + line-height: 0; + content: ""; +} + +.thumbnails:after { + clear: both; +} + +.row-fluid .thumbnails { + margin-left: 0; +} + +.thumbnails > li { + float: left; + margin-bottom: 20px; + margin-left: 20px; +} + +.thumbnail { + display: block; + padding: 4px; + line-height: 20px; + border: 1px solid #ddd; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + -webkit-transition: all 0.2s ease-in-out; + -moz-transition: all 0.2s ease-in-out; + -o-transition: all 0.2s ease-in-out; + transition: all 0.2s ease-in-out; +} + +a.thumbnail:hover, +a.thumbnail:focus { + border-color: #0088cc; + -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); + -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); + box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); +} + +.thumbnail > img { + display: block; + max-width: 100%; + margin-right: auto; + margin-left: auto; +} + +.thumbnail .caption { + padding: 9px; + color: #555555; +} + +.media, +.media-body { + overflow: hidden; + *overflow: visible; + zoom: 1; +} + +.media, +.media .media { + margin-top: 15px; +} + +.media:first-child { + margin-top: 0; +} + +.media-object { + display: block; +} + +.media-heading { + margin: 0 0 5px; +} + +.media > .pull-left { + margin-right: 10px; +} + +.media > .pull-right { + margin-left: 10px; +} + +.media-list { + margin-left: 0; + list-style: none; +} + +.label, +.badge { + display: inline-block; + padding: 2px 4px; + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + white-space: nowrap; + vertical-align: baseline; + background-color: #999999; +} + +.label { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.badge { + padding-right: 9px; + padding-left: 9px; + -webkit-border-radius: 9px; + -moz-border-radius: 9px; + border-radius: 9px; +} + +.label:empty, +.badge:empty { + display: none; +} + +a.label:hover, +a.label:focus, +a.badge:hover, +a.badge:focus { + color: #ffffff; + text-decoration: none; + cursor: pointer; +} + +.label-important, +.badge-important { + background-color: #b94a48; +} + +.label-important[href], +.badge-important[href] { + background-color: #953b39; +} + +.label-warning, +.badge-warning { + background-color: #f89406; +} + +.label-warning[href], +.badge-warning[href] { + background-color: #c67605; +} + +.label-success, +.badge-success { + background-color: #468847; +} + +.label-success[href], +.badge-success[href] { + background-color: #356635; +} + +.label-info, +.badge-info { + background-color: #3a87ad; +} + +.label-info[href], +.badge-info[href] { + background-color: #2d6987; +} + +.label-inverse, +.badge-inverse { + background-color: #333333; +} + +.label-inverse[href], +.badge-inverse[href] { + background-color: #1a1a1a; +} + +.btn .label, +.btn .badge { + position: relative; + top: -1px; +} + +.btn-mini .label, +.btn-mini .badge { + top: 0; +} + +@-webkit-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-moz-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-ms-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-o-keyframes progress-bar-stripes { + from { + background-position: 0 0; + } + to { + background-position: 40px 0; + } +} + +@keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +.progress { + height: 20px; + margin-bottom: 20px; + overflow: hidden; + background-color: #f7f7f7; + background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9)); + background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9); + background-repeat: repeat-x; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0); + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); +} + +.progress .bar { + float: left; + width: 0; + height: 100%; + font-size: 12px; + color: #ffffff; + text-align: center; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #0e90d2; + background-image: -moz-linear-gradient(top, #149bdf, #0480be); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be)); + background-image: -webkit-linear-gradient(top, #149bdf, #0480be); + background-image: -o-linear-gradient(top, #149bdf, #0480be); + background-image: linear-gradient(to bottom, #149bdf, #0480be); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0); + -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-transition: width 0.6s ease; + -moz-transition: width 0.6s ease; + -o-transition: width 0.6s ease; + transition: width 0.6s ease; +} + +.progress .bar + .bar { + -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); +} + +.progress-striped .bar { + background-color: #149bdf; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + -webkit-background-size: 40px 40px; + -moz-background-size: 40px 40px; + -o-background-size: 40px 40px; + background-size: 40px 40px; +} + +.progress.active .bar { + -webkit-animation: progress-bar-stripes 2s linear infinite; + -moz-animation: progress-bar-stripes 2s linear infinite; + -ms-animation: progress-bar-stripes 2s linear infinite; + -o-animation: progress-bar-stripes 2s linear infinite; + animation: progress-bar-stripes 2s linear infinite; +} + +.progress-danger .bar, +.progress .bar-danger { + background-color: #dd514c; + background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35)); + background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -o-linear-gradient(top, #ee5f5b, #c43c35); + background-image: linear-gradient(to bottom, #ee5f5b, #c43c35); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0); +} + +.progress-danger.progress-striped .bar, +.progress-striped .bar-danger { + background-color: #ee5f5b; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-success .bar, +.progress .bar-success { + background-color: #5eb95e; + background-image: -moz-linear-gradient(top, #62c462, #57a957); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957)); + background-image: -webkit-linear-gradient(top, #62c462, #57a957); + background-image: -o-linear-gradient(top, #62c462, #57a957); + background-image: linear-gradient(to bottom, #62c462, #57a957); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0); +} + +.progress-success.progress-striped .bar, +.progress-striped .bar-success { + background-color: #62c462; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-info .bar, +.progress .bar-info { + background-color: #4bb1cf; + background-image: -moz-linear-gradient(top, #5bc0de, #339bb9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9)); + background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9); + background-image: -o-linear-gradient(top, #5bc0de, #339bb9); + background-image: linear-gradient(to bottom, #5bc0de, #339bb9); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0); +} + +.progress-info.progress-striped .bar, +.progress-striped .bar-info { + background-color: #5bc0de; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-warning .bar, +.progress .bar-warning { + background-color: #faa732; + background-image: -moz-linear-gradient(top, #fbb450, #f89406); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); + background-image: -webkit-linear-gradient(top, #fbb450, #f89406); + background-image: -o-linear-gradient(top, #fbb450, #f89406); + background-image: linear-gradient(to bottom, #fbb450, #f89406); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0); +} + +.progress-warning.progress-striped .bar, +.progress-striped .bar-warning { + background-color: #fbb450; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.accordion { + margin-bottom: 20px; +} + +.accordion-group { + margin-bottom: 2px; + border: 1px solid #e5e5e5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.accordion-heading { + border-bottom: 0; +} + +.accordion-heading .accordion-toggle { + display: block; + padding: 8px 15px; +} + +.accordion-toggle { + cursor: pointer; +} + +.accordion-inner { + padding: 9px 15px; + border-top: 1px solid #e5e5e5; +} + +.carousel { + position: relative; + margin-bottom: 20px; + line-height: 1; +} + +.carousel-inner { + position: relative; + width: 100%; + overflow: hidden; +} + +.carousel-inner > .item { + position: relative; + display: none; + -webkit-transition: 0.6s ease-in-out left; + -moz-transition: 0.6s ease-in-out left; + -o-transition: 0.6s ease-in-out left; + transition: 0.6s ease-in-out left; +} + +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + line-height: 1; +} + +.carousel-inner > .active, +.carousel-inner > .next, +.carousel-inner > .prev { + display: block; +} + +.carousel-inner > .active { + left: 0; +} + +.carousel-inner > .next, +.carousel-inner > .prev { + position: absolute; + top: 0; + width: 100%; +} + +.carousel-inner > .next { + left: 100%; +} + +.carousel-inner > .prev { + left: -100%; +} + +.carousel-inner > .next.left, +.carousel-inner > .prev.right { + left: 0; +} + +.carousel-inner > .active.left { + left: -100%; +} + +.carousel-inner > .active.right { + left: 100%; +} + +.carousel-control { + position: absolute; + top: 40%; + left: 15px; + width: 40px; + height: 40px; + margin-top: -20px; + font-size: 60px; + font-weight: 100; + line-height: 30px; + color: #ffffff; + text-align: center; + background: #222222; + border: 3px solid #ffffff; + -webkit-border-radius: 23px; + -moz-border-radius: 23px; + border-radius: 23px; + opacity: 0.5; + filter: alpha(opacity=50); +} + +.carousel-control.right { + right: 15px; + left: auto; +} + +.carousel-control:hover, +.carousel-control:focus { + color: #ffffff; + text-decoration: none; + opacity: 0.9; + filter: alpha(opacity=90); +} + +.carousel-indicators { + position: absolute; + top: 15px; + right: 15px; + z-index: 5; + margin: 0; + list-style: none; +} + +.carousel-indicators li { + display: block; + float: left; + width: 10px; + height: 10px; + margin-left: 5px; + text-indent: -999px; + background-color: #ccc; + background-color: rgba(255, 255, 255, 0.25); + border-radius: 5px; +} + +.carousel-indicators .active { + background-color: #fff; +} + +.carousel-caption { + position: absolute; + right: 0; + bottom: 0; + left: 0; + padding: 15px; + background: #333333; + background: rgba(0, 0, 0, 0.75); +} + +.carousel-caption h4, +.carousel-caption p { + line-height: 20px; + color: #ffffff; +} + +.carousel-caption h4 { + margin: 0 0 5px; +} + +.carousel-caption p { + margin-bottom: 0; +} + +.hero-unit { + padding: 60px; + margin-bottom: 30px; + font-size: 18px; + font-weight: 200; + line-height: 30px; + color: inherit; + background-color: #eeeeee; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.hero-unit h1 { + margin-bottom: 0; + font-size: 60px; + line-height: 1; + letter-spacing: -1px; + color: inherit; +} + +.hero-unit li { + line-height: 30px; +} + +.pull-right { + float: right; +} + +.pull-left { + float: left; +} + +.hide { + display: none; +} + +.show { + display: block; +} + +.invisible { + visibility: hidden; +} + +.affix { + position: fixed; +} diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/mvc-servlet.xml b/handling-spring-static-resources/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 000000000000..94bd63e068a3 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/home.jsp b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/home.jsp new file mode 100644 index 000000000000..468603a039c0 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/home.jsp @@ -0,0 +1,17 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ page session="false" %> + + +" rel="stylesheet"> + + Home + + +

    + This is Home! +

    +bunny hop image"> + + + diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp new file mode 100644 index 000000000000..1b09f7c634da --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp @@ -0,0 +1,65 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" + uri="http://www.springframework.org/security/tags"%> +<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> + +<%@ page session="true"%> + + + + + +" rel="stylesheet"> + + +
    + +
    +
    + + + +

    + +
    + + + + + + + + + + + + +
    />
    + +
    + +
    + + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/web.xml b/handling-spring-static-resources/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..26ac5be1e0e8 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,49 @@ + + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + localizationFilter + org.springframework.web.filter.RequestContextFilter + + + localizationFilter + /* + + + \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/js/app.js b/handling-spring-static-resources/src/main/webapp/js/app.js new file mode 100644 index 000000000000..e312d6d6708a --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/app.js @@ -0,0 +1,4 @@ +/** + * + */ +window.Todos = Ember.Application.create(); \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/js/bootstrap.css b/handling-spring-static-resources/src/main/webapp/js/bootstrap.css new file mode 100644 index 000000000000..5b7fe7e8562e --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/bootstrap.css @@ -0,0 +1,6167 @@ +/*! + * Bootstrap v2.3.2 + * + * Copyright 2013 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world by @mdo and @fat. + */ + +.clearfix { + *zoom: 1; +} + +.clearfix:before, +.clearfix:after { + display: table; + line-height: 0; + content: ""; +} + +.clearfix:after { + clear: both; +} + +.hide-text { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} + +.input-block-level { + display: block; + width: 100%; + min-height: 30px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section { + display: block; +} + +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +audio:not([controls]) { + display: none; +} + +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +a:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +a:hover, +a:active { + outline: 0; +} + +sub, +sup { + position: relative; + font-size: 75%; + line-height: 0; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +img { + width: auto\9; + height: auto; + max-width: 100%; + vertical-align: middle; + border: 0; + -ms-interpolation-mode: bicubic; +} + +#map_canvas img, +.google-maps img { + max-width: none; +} + +button, +input, +select, +textarea { + margin: 0; + font-size: 100%; + vertical-align: middle; +} + +button, +input { + *overflow: visible; + line-height: normal; +} + +button::-moz-focus-inner, +input::-moz-focus-inner { + padding: 0; + border: 0; +} + +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + -webkit-appearance: button; +} + +label, +select, +button, +input[type="button"], +input[type="reset"], +input[type="submit"], +input[type="radio"], +input[type="checkbox"] { + cursor: pointer; +} + +input[type="search"] { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +textarea { + overflow: auto; + vertical-align: top; +} + +@media print { + * { + color: #000 !important; + text-shadow: none !important; + background: transparent !important; + box-shadow: none !important; + } + a, + a:visited { + text-decoration: underline; + } + a[href]:after { + content: " (" attr(href) ")"; + } + abbr[title]:after { + content: " (" attr(title) ")"; + } + .ir a:after, + a[href^="javascript:"]:after, + a[href^="#"]:after { + content: ""; + } + pre, + blockquote { + border: 1px solid #999; + page-break-inside: avoid; + } + thead { + display: table-header-group; + } + tr, + img { + page-break-inside: avoid; + } + img { + max-width: 100% !important; + } + @page { + margin: 0.5cm; + } + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + h2, + h3 { + page-break-after: avoid; + } +} + +body { + margin: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 20px; + color: #333333; + background-color: #ffffff; +} + +a { + color: #0088cc; + text-decoration: none; +} + +a:hover, +a:focus { + color: #005580; + text-decoration: underline; +} + +.img-rounded { + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.img-polaroid { + padding: 4px; + background-color: #fff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.img-circle { + -webkit-border-radius: 500px; + -moz-border-radius: 500px; + border-radius: 500px; +} + +.row { + margin-left: -20px; + *zoom: 1; +} + +.row:before, +.row:after { + display: table; + line-height: 0; + content: ""; +} + +.row:after { + clear: both; +} + +[class*="span"] { + float: left; + min-height: 1px; + margin-left: 20px; +} + +.container, +.navbar-static-top .container, +.navbar-fixed-top .container, +.navbar-fixed-bottom .container { + width: 940px; +} + +.span12 { + width: 940px; +} + +.span11 { + width: 860px; +} + +.span10 { + width: 780px; +} + +.span9 { + width: 700px; +} + +.span8 { + width: 620px; +} + +.span7 { + width: 540px; +} + +.span6 { + width: 460px; +} + +.span5 { + width: 380px; +} + +.span4 { + width: 300px; +} + +.span3 { + width: 220px; +} + +.span2 { + width: 140px; +} + +.span1 { + width: 60px; +} + +.offset12 { + margin-left: 980px; +} + +.offset11 { + margin-left: 900px; +} + +.offset10 { + margin-left: 820px; +} + +.offset9 { + margin-left: 740px; +} + +.offset8 { + margin-left: 660px; +} + +.offset7 { + margin-left: 580px; +} + +.offset6 { + margin-left: 500px; +} + +.offset5 { + margin-left: 420px; +} + +.offset4 { + margin-left: 340px; +} + +.offset3 { + margin-left: 260px; +} + +.offset2 { + margin-left: 180px; +} + +.offset1 { + margin-left: 100px; +} + +.row-fluid { + width: 100%; + *zoom: 1; +} + +.row-fluid:before, +.row-fluid:after { + display: table; + line-height: 0; + content: ""; +} + +.row-fluid:after { + clear: both; +} + +.row-fluid [class*="span"] { + display: block; + float: left; + width: 100%; + min-height: 30px; + margin-left: 2.127659574468085%; + *margin-left: 2.074468085106383%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.row-fluid [class*="span"]:first-child { + margin-left: 0; +} + +.row-fluid .controls-row [class*="span"] + [class*="span"] { + margin-left: 2.127659574468085%; +} + +.row-fluid .span12 { + width: 100%; + *width: 99.94680851063829%; +} + +.row-fluid .span11 { + width: 91.48936170212765%; + *width: 91.43617021276594%; +} + +.row-fluid .span10 { + width: 82.97872340425532%; + *width: 82.92553191489361%; +} + +.row-fluid .span9 { + width: 74.46808510638297%; + *width: 74.41489361702126%; +} + +.row-fluid .span8 { + width: 65.95744680851064%; + *width: 65.90425531914893%; +} + +.row-fluid .span7 { + width: 57.44680851063829%; + *width: 57.39361702127659%; +} + +.row-fluid .span6 { + width: 48.93617021276595%; + *width: 48.88297872340425%; +} + +.row-fluid .span5 { + width: 40.42553191489362%; + *width: 40.37234042553192%; +} + +.row-fluid .span4 { + width: 31.914893617021278%; + *width: 31.861702127659576%; +} + +.row-fluid .span3 { + width: 23.404255319148934%; + *width: 23.351063829787233%; +} + +.row-fluid .span2 { + width: 14.893617021276595%; + *width: 14.840425531914894%; +} + +.row-fluid .span1 { + width: 6.382978723404255%; + *width: 6.329787234042553%; +} + +.row-fluid .offset12 { + margin-left: 104.25531914893617%; + *margin-left: 104.14893617021275%; +} + +.row-fluid .offset12:first-child { + margin-left: 102.12765957446808%; + *margin-left: 102.02127659574467%; +} + +.row-fluid .offset11 { + margin-left: 95.74468085106382%; + *margin-left: 95.6382978723404%; +} + +.row-fluid .offset11:first-child { + margin-left: 93.61702127659574%; + *margin-left: 93.51063829787232%; +} + +.row-fluid .offset10 { + margin-left: 87.23404255319149%; + *margin-left: 87.12765957446807%; +} + +.row-fluid .offset10:first-child { + margin-left: 85.1063829787234%; + *margin-left: 84.99999999999999%; +} + +.row-fluid .offset9 { + margin-left: 78.72340425531914%; + *margin-left: 78.61702127659572%; +} + +.row-fluid .offset9:first-child { + margin-left: 76.59574468085106%; + *margin-left: 76.48936170212764%; +} + +.row-fluid .offset8 { + margin-left: 70.2127659574468%; + *margin-left: 70.10638297872339%; +} + +.row-fluid .offset8:first-child { + margin-left: 68.08510638297872%; + *margin-left: 67.9787234042553%; +} + +.row-fluid .offset7 { + margin-left: 61.70212765957446%; + *margin-left: 61.59574468085106%; +} + +.row-fluid .offset7:first-child { + margin-left: 59.574468085106375%; + *margin-left: 59.46808510638297%; +} + +.row-fluid .offset6 { + margin-left: 53.191489361702125%; + *margin-left: 53.085106382978715%; +} + +.row-fluid .offset6:first-child { + margin-left: 51.063829787234035%; + *margin-left: 50.95744680851063%; +} + +.row-fluid .offset5 { + margin-left: 44.68085106382979%; + *margin-left: 44.57446808510638%; +} + +.row-fluid .offset5:first-child { + margin-left: 42.5531914893617%; + *margin-left: 42.4468085106383%; +} + +.row-fluid .offset4 { + margin-left: 36.170212765957444%; + *margin-left: 36.06382978723405%; +} + +.row-fluid .offset4:first-child { + margin-left: 34.04255319148936%; + *margin-left: 33.93617021276596%; +} + +.row-fluid .offset3 { + margin-left: 27.659574468085104%; + *margin-left: 27.5531914893617%; +} + +.row-fluid .offset3:first-child { + margin-left: 25.53191489361702%; + *margin-left: 25.425531914893618%; +} + +.row-fluid .offset2 { + margin-left: 19.148936170212764%; + *margin-left: 19.04255319148936%; +} + +.row-fluid .offset2:first-child { + margin-left: 17.02127659574468%; + *margin-left: 16.914893617021278%; +} + +.row-fluid .offset1 { + margin-left: 10.638297872340425%; + *margin-left: 10.53191489361702%; +} + +.row-fluid .offset1:first-child { + margin-left: 8.51063829787234%; + *margin-left: 8.404255319148938%; +} + +[class*="span"].hide, +.row-fluid [class*="span"].hide { + display: none; +} + +[class*="span"].pull-right, +.row-fluid [class*="span"].pull-right { + float: right; +} + +.container { + margin-right: auto; + margin-left: auto; + *zoom: 1; +} + +.container:before, +.container:after { + display: table; + line-height: 0; + content: ""; +} + +.container:after { + clear: both; +} + +.container-fluid { + padding-right: 20px; + padding-left: 20px; + *zoom: 1; +} + +.container-fluid:before, +.container-fluid:after { + display: table; + line-height: 0; + content: ""; +} + +.container-fluid:after { + clear: both; +} + +p { + margin: 0 0 10px; +} + +.lead { + margin-bottom: 20px; + font-size: 21px; + font-weight: 200; + line-height: 30px; +} + +small { + font-size: 85%; +} + +strong { + font-weight: bold; +} + +em { + font-style: italic; +} + +cite { + font-style: normal; +} + +.muted { + color: #999999; +} + +a.muted:hover, +a.muted:focus { + color: #808080; +} + +.text-warning { + color: #c09853; +} + +a.text-warning:hover, +a.text-warning:focus { + color: #a47e3c; +} + +.text-error { + color: #b94a48; +} + +a.text-error:hover, +a.text-error:focus { + color: #953b39; +} + +.text-info { + color: #3a87ad; +} + +a.text-info:hover, +a.text-info:focus { + color: #2d6987; +} + +.text-success { + color: #468847; +} + +a.text-success:hover, +a.text-success:focus { + color: #356635; +} + +.text-left { + text-align: left; +} + +.text-right { + text-align: right; +} + +.text-center { + text-align: center; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 10px 0; + font-family: inherit; + font-weight: bold; + line-height: 20px; + color: inherit; + text-rendering: optimizelegibility; +} + +h1 small, +h2 small, +h3 small, +h4 small, +h5 small, +h6 small { + font-weight: normal; + line-height: 1; + color: #999999; +} + +h1, +h2, +h3 { + line-height: 40px; +} + +h1 { + font-size: 38.5px; +} + +h2 { + font-size: 31.5px; +} + +h3 { + font-size: 24.5px; +} + +h4 { + font-size: 17.5px; +} + +h5 { + font-size: 14px; +} + +h6 { + font-size: 11.9px; +} + +h1 small { + font-size: 24.5px; +} + +h2 small { + font-size: 17.5px; +} + +h3 small { + font-size: 14px; +} + +h4 small { + font-size: 14px; +} + +.page-header { + padding-bottom: 9px; + margin: 20px 0 30px; + border-bottom: 1px solid #eeeeee; +} + +ul, +ol { + padding: 0; + margin: 0 0 10px 25px; +} + +ul ul, +ul ol, +ol ol, +ol ul { + margin-bottom: 0; +} + +li { + line-height: 20px; +} + +ul.unstyled, +ol.unstyled { + margin-left: 0; + list-style: none; +} + +ul.inline, +ol.inline { + margin-left: 0; + list-style: none; +} + +ul.inline > li, +ol.inline > li { + display: inline-block; + *display: inline; + padding-right: 5px; + padding-left: 5px; + *zoom: 1; +} + +dl { + margin-bottom: 20px; +} + +dt, +dd { + line-height: 20px; +} + +dt { + font-weight: bold; +} + +dd { + margin-left: 10px; +} + +.dl-horizontal { + *zoom: 1; +} + +.dl-horizontal:before, +.dl-horizontal:after { + display: table; + line-height: 0; + content: ""; +} + +.dl-horizontal:after { + clear: both; +} + +.dl-horizontal dt { + float: left; + width: 160px; + overflow: hidden; + clear: left; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +.dl-horizontal dd { + margin-left: 180px; +} + +hr { + margin: 20px 0; + border: 0; + border-top: 1px solid #eeeeee; + border-bottom: 1px solid #ffffff; +} + +abbr[title], +abbr[data-original-title] { + cursor: help; + border-bottom: 1px dotted #999999; +} + +abbr.initialism { + font-size: 90%; + text-transform: uppercase; +} + +blockquote { + padding: 0 0 0 15px; + margin: 0 0 20px; + border-left: 5px solid #eeeeee; +} + +blockquote p { + margin-bottom: 0; + font-size: 17.5px; + font-weight: 300; + line-height: 1.25; +} + +blockquote small { + display: block; + line-height: 20px; + color: #999999; +} + +blockquote small:before { + content: '\2014 \00A0'; +} + +blockquote.pull-right { + float: right; + padding-right: 15px; + padding-left: 0; + border-right: 5px solid #eeeeee; + border-left: 0; +} + +blockquote.pull-right p, +blockquote.pull-right small { + text-align: right; +} + +blockquote.pull-right small:before { + content: ''; +} + +blockquote.pull-right small:after { + content: '\00A0 \2014'; +} + +q:before, +q:after, +blockquote:before, +blockquote:after { + content: ""; +} + +address { + display: block; + margin-bottom: 20px; + font-style: normal; + line-height: 20px; +} + +code, +pre { + padding: 0 3px 2px; + font-family: Monaco, Menlo, Consolas, "Courier New", monospace; + font-size: 12px; + color: #333333; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +code { + padding: 2px 4px; + color: #d14; + white-space: nowrap; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; +} + +pre { + display: block; + padding: 9.5px; + margin: 0 0 10px; + font-size: 13px; + line-height: 20px; + word-break: break-all; + word-wrap: break-word; + white-space: pre; + white-space: pre-wrap; + background-color: #f5f5f5; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.15); + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +pre.prettyprint { + margin-bottom: 20px; +} + +pre code { + padding: 0; + color: inherit; + white-space: pre; + white-space: pre-wrap; + background-color: transparent; + border: 0; +} + +.pre-scrollable { + max-height: 340px; + overflow-y: scroll; +} + +form { + margin: 0 0 20px; +} + +fieldset { + padding: 0; + margin: 0; + border: 0; +} + +legend { + display: block; + width: 100%; + padding: 0; + margin-bottom: 20px; + font-size: 21px; + line-height: 40px; + color: #333333; + border: 0; + border-bottom: 1px solid #e5e5e5; +} + +legend small { + font-size: 15px; + color: #999999; +} + +label, +input, +button, +select, +textarea { + font-size: 14px; + font-weight: normal; + line-height: 20px; +} + +input, +button, +select, +textarea { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +label { + display: block; + margin-bottom: 5px; +} + +select, +textarea, +input[type="text"], +input[type="password"], +input[type="datetime"], +input[type="datetime-local"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="week"], +input[type="number"], +input[type="email"], +input[type="url"], +input[type="search"], +input[type="tel"], +input[type="color"], +.uneditable-input { + display: inline-block; + height: 20px; + padding: 4px 6px; + margin-bottom: 10px; + font-size: 14px; + line-height: 20px; + color: #555555; + vertical-align: middle; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +input, +textarea, +.uneditable-input { + width: 206px; +} + +textarea { + height: auto; +} + +textarea, +input[type="text"], +input[type="password"], +input[type="datetime"], +input[type="datetime-local"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="week"], +input[type="number"], +input[type="email"], +input[type="url"], +input[type="search"], +input[type="tel"], +input[type="color"], +.uneditable-input { + background-color: #ffffff; + border: 1px solid #cccccc; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; + -moz-transition: border linear 0.2s, box-shadow linear 0.2s; + -o-transition: border linear 0.2s, box-shadow linear 0.2s; + transition: border linear 0.2s, box-shadow linear 0.2s; +} + +textarea:focus, +input[type="text"]:focus, +input[type="password"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="date"]:focus, +input[type="month"]:focus, +input[type="time"]:focus, +input[type="week"]:focus, +input[type="number"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="color"]:focus, +.uneditable-input:focus { + border-color: rgba(82, 168, 236, 0.8); + outline: 0; + outline: thin dotted \9; + /* IE6-9 */ + + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); +} + +input[type="radio"], +input[type="checkbox"] { + margin: 4px 0 0; + margin-top: 1px \9; + *margin-top: 0; + line-height: normal; +} + +input[type="file"], +input[type="image"], +input[type="submit"], +input[type="reset"], +input[type="button"], +input[type="radio"], +input[type="checkbox"] { + width: auto; +} + +select, +input[type="file"] { + height: 30px; + /* In IE7, the height of the select element cannot be changed by height, only font-size */ + + *margin-top: 4px; + /* For IE7, add top margin to align select with labels */ + + line-height: 30px; +} + +select { + width: 220px; + background-color: #ffffff; + border: 1px solid #cccccc; +} + +select[multiple], +select[size] { + height: auto; +} + +select:focus, +input[type="file"]:focus, +input[type="radio"]:focus, +input[type="checkbox"]:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +.uneditable-input, +.uneditable-textarea { + color: #999999; + cursor: not-allowed; + background-color: #fcfcfc; + border-color: #cccccc; + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025); +} + +.uneditable-input { + overflow: hidden; + white-space: nowrap; +} + +.uneditable-textarea { + width: auto; + height: auto; +} + +input:-moz-placeholder, +textarea:-moz-placeholder { + color: #999999; +} + +input:-ms-input-placeholder, +textarea:-ms-input-placeholder { + color: #999999; +} + +input::-webkit-input-placeholder, +textarea::-webkit-input-placeholder { + color: #999999; +} + +.radio, +.checkbox { + min-height: 20px; + padding-left: 20px; +} + +.radio input[type="radio"], +.checkbox input[type="checkbox"] { + float: left; + margin-left: -20px; +} + +.controls > .radio:first-child, +.controls > .checkbox:first-child { + padding-top: 5px; +} + +.radio.inline, +.checkbox.inline { + display: inline-block; + padding-top: 5px; + margin-bottom: 0; + vertical-align: middle; +} + +.radio.inline + .radio.inline, +.checkbox.inline + .checkbox.inline { + margin-left: 10px; +} + +.input-mini { + width: 60px; +} + +.input-small { + width: 90px; +} + +.input-medium { + width: 150px; +} + +.input-large { + width: 210px; +} + +.input-xlarge { + width: 270px; +} + +.input-xxlarge { + width: 530px; +} + +input[class*="span"], +select[class*="span"], +textarea[class*="span"], +.uneditable-input[class*="span"], +.row-fluid input[class*="span"], +.row-fluid select[class*="span"], +.row-fluid textarea[class*="span"], +.row-fluid .uneditable-input[class*="span"] { + float: none; + margin-left: 0; +} + +.input-append input[class*="span"], +.input-append .uneditable-input[class*="span"], +.input-prepend input[class*="span"], +.input-prepend .uneditable-input[class*="span"], +.row-fluid input[class*="span"], +.row-fluid select[class*="span"], +.row-fluid textarea[class*="span"], +.row-fluid .uneditable-input[class*="span"], +.row-fluid .input-prepend [class*="span"], +.row-fluid .input-append [class*="span"] { + display: inline-block; +} + +input, +textarea, +.uneditable-input { + margin-left: 0; +} + +.controls-row [class*="span"] + [class*="span"] { + margin-left: 20px; +} + +input.span12, +textarea.span12, +.uneditable-input.span12 { + width: 926px; +} + +input.span11, +textarea.span11, +.uneditable-input.span11 { + width: 846px; +} + +input.span10, +textarea.span10, +.uneditable-input.span10 { + width: 766px; +} + +input.span9, +textarea.span9, +.uneditable-input.span9 { + width: 686px; +} + +input.span8, +textarea.span8, +.uneditable-input.span8 { + width: 606px; +} + +input.span7, +textarea.span7, +.uneditable-input.span7 { + width: 526px; +} + +input.span6, +textarea.span6, +.uneditable-input.span6 { + width: 446px; +} + +input.span5, +textarea.span5, +.uneditable-input.span5 { + width: 366px; +} + +input.span4, +textarea.span4, +.uneditable-input.span4 { + width: 286px; +} + +input.span3, +textarea.span3, +.uneditable-input.span3 { + width: 206px; +} + +input.span2, +textarea.span2, +.uneditable-input.span2 { + width: 126px; +} + +input.span1, +textarea.span1, +.uneditable-input.span1 { + width: 46px; +} + +.controls-row { + *zoom: 1; +} + +.controls-row:before, +.controls-row:after { + display: table; + line-height: 0; + content: ""; +} + +.controls-row:after { + clear: both; +} + +.controls-row [class*="span"], +.row-fluid .controls-row [class*="span"] { + float: left; +} + +.controls-row .checkbox[class*="span"], +.controls-row .radio[class*="span"] { + padding-top: 5px; +} + +input[disabled], +select[disabled], +textarea[disabled], +input[readonly], +select[readonly], +textarea[readonly] { + cursor: not-allowed; + background-color: #eeeeee; +} + +input[type="radio"][disabled], +input[type="checkbox"][disabled], +input[type="radio"][readonly], +input[type="checkbox"][readonly] { + background-color: transparent; +} + +.control-group.warning .control-label, +.control-group.warning .help-block, +.control-group.warning .help-inline { + color: #c09853; +} + +.control-group.warning .checkbox, +.control-group.warning .radio, +.control-group.warning input, +.control-group.warning select, +.control-group.warning textarea { + color: #c09853; +} + +.control-group.warning input, +.control-group.warning select, +.control-group.warning textarea { + border-color: #c09853; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.warning input:focus, +.control-group.warning select:focus, +.control-group.warning textarea:focus { + border-color: #a47e3c; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; +} + +.control-group.warning .input-prepend .add-on, +.control-group.warning .input-append .add-on { + color: #c09853; + background-color: #fcf8e3; + border-color: #c09853; +} + +.control-group.error .control-label, +.control-group.error .help-block, +.control-group.error .help-inline { + color: #b94a48; +} + +.control-group.error .checkbox, +.control-group.error .radio, +.control-group.error input, +.control-group.error select, +.control-group.error textarea { + color: #b94a48; +} + +.control-group.error input, +.control-group.error select, +.control-group.error textarea { + border-color: #b94a48; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.error input:focus, +.control-group.error select:focus, +.control-group.error textarea:focus { + border-color: #953b39; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; +} + +.control-group.error .input-prepend .add-on, +.control-group.error .input-append .add-on { + color: #b94a48; + background-color: #f2dede; + border-color: #b94a48; +} + +.control-group.success .control-label, +.control-group.success .help-block, +.control-group.success .help-inline { + color: #468847; +} + +.control-group.success .checkbox, +.control-group.success .radio, +.control-group.success input, +.control-group.success select, +.control-group.success textarea { + color: #468847; +} + +.control-group.success input, +.control-group.success select, +.control-group.success textarea { + border-color: #468847; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.success input:focus, +.control-group.success select:focus, +.control-group.success textarea:focus { + border-color: #356635; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; +} + +.control-group.success .input-prepend .add-on, +.control-group.success .input-append .add-on { + color: #468847; + background-color: #dff0d8; + border-color: #468847; +} + +.control-group.info .control-label, +.control-group.info .help-block, +.control-group.info .help-inline { + color: #3a87ad; +} + +.control-group.info .checkbox, +.control-group.info .radio, +.control-group.info input, +.control-group.info select, +.control-group.info textarea { + color: #3a87ad; +} + +.control-group.info input, +.control-group.info select, +.control-group.info textarea { + border-color: #3a87ad; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.control-group.info input:focus, +.control-group.info select:focus, +.control-group.info textarea:focus { + border-color: #2d6987; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; +} + +.control-group.info .input-prepend .add-on, +.control-group.info .input-append .add-on { + color: #3a87ad; + background-color: #d9edf7; + border-color: #3a87ad; +} + +input:focus:invalid, +textarea:focus:invalid, +select:focus:invalid { + color: #b94a48; + border-color: #ee5f5b; +} + +input:focus:invalid:focus, +textarea:focus:invalid:focus, +select:focus:invalid:focus { + border-color: #e9322d; + -webkit-box-shadow: 0 0 6px #f8b9b7; + -moz-box-shadow: 0 0 6px #f8b9b7; + box-shadow: 0 0 6px #f8b9b7; +} + +.form-actions { + padding: 19px 20px 20px; + margin-top: 20px; + margin-bottom: 20px; + background-color: #f5f5f5; + border-top: 1px solid #e5e5e5; + *zoom: 1; +} + +.form-actions:before, +.form-actions:after { + display: table; + line-height: 0; + content: ""; +} + +.form-actions:after { + clear: both; +} + +.help-block, +.help-inline { + color: #595959; +} + +.help-block { + display: block; + margin-bottom: 10px; +} + +.help-inline { + display: inline-block; + *display: inline; + padding-left: 5px; + vertical-align: middle; + *zoom: 1; +} + +.input-append, +.input-prepend { + display: inline-block; + margin-bottom: 10px; + font-size: 0; + white-space: nowrap; + vertical-align: middle; +} + +.input-append input, +.input-prepend input, +.input-append select, +.input-prepend select, +.input-append .uneditable-input, +.input-prepend .uneditable-input, +.input-append .dropdown-menu, +.input-prepend .dropdown-menu, +.input-append .popover, +.input-prepend .popover { + font-size: 14px; +} + +.input-append input, +.input-prepend input, +.input-append select, +.input-prepend select, +.input-append .uneditable-input, +.input-prepend .uneditable-input { + position: relative; + margin-bottom: 0; + *margin-left: 0; + vertical-align: top; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-append input:focus, +.input-prepend input:focus, +.input-append select:focus, +.input-prepend select:focus, +.input-append .uneditable-input:focus, +.input-prepend .uneditable-input:focus { + z-index: 2; +} + +.input-append .add-on, +.input-prepend .add-on { + display: inline-block; + width: auto; + height: 20px; + min-width: 16px; + padding: 4px 5px; + font-size: 14px; + font-weight: normal; + line-height: 20px; + text-align: center; + text-shadow: 0 1px 0 #ffffff; + background-color: #eeeeee; + border: 1px solid #ccc; +} + +.input-append .add-on, +.input-prepend .add-on, +.input-append .btn, +.input-prepend .btn, +.input-append .btn-group > .dropdown-toggle, +.input-prepend .btn-group > .dropdown-toggle { + vertical-align: top; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.input-append .active, +.input-prepend .active { + background-color: #a9dba9; + border-color: #46a546; +} + +.input-prepend .add-on, +.input-prepend .btn { + margin-right: -1px; +} + +.input-prepend .add-on:first-child, +.input-prepend .btn:first-child { + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-append input, +.input-append select, +.input-append .uneditable-input { + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-append input + .btn-group .btn:last-child, +.input-append select + .btn-group .btn:last-child, +.input-append .uneditable-input + .btn-group .btn:last-child { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-append .add-on, +.input-append .btn, +.input-append .btn-group { + margin-left: -1px; +} + +.input-append .add-on:last-child, +.input-append .btn:last-child, +.input-append .btn-group:last-child > .dropdown-toggle { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append input, +.input-prepend.input-append select, +.input-prepend.input-append .uneditable-input { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.input-prepend.input-append input + .btn-group .btn, +.input-prepend.input-append select + .btn-group .btn, +.input-prepend.input-append .uneditable-input + .btn-group .btn { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append .add-on:first-child, +.input-prepend.input-append .btn:first-child { + margin-right: -1px; + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.input-prepend.input-append .add-on:last-child, +.input-prepend.input-append .btn:last-child { + margin-left: -1px; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.input-prepend.input-append .btn-group:first-child { + margin-left: 0; +} + +input.search-query { + padding-right: 14px; + padding-right: 4px \9; + padding-left: 14px; + padding-left: 4px \9; + /* IE7-8 doesn't have border-radius, so don't indent the padding */ + + margin-bottom: 0; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +/* Allow for input prepend/append in search forms */ + +.form-search .input-append .search-query, +.form-search .input-prepend .search-query { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.form-search .input-append .search-query { + -webkit-border-radius: 14px 0 0 14px; + -moz-border-radius: 14px 0 0 14px; + border-radius: 14px 0 0 14px; +} + +.form-search .input-append .btn { + -webkit-border-radius: 0 14px 14px 0; + -moz-border-radius: 0 14px 14px 0; + border-radius: 0 14px 14px 0; +} + +.form-search .input-prepend .search-query { + -webkit-border-radius: 0 14px 14px 0; + -moz-border-radius: 0 14px 14px 0; + border-radius: 0 14px 14px 0; +} + +.form-search .input-prepend .btn { + -webkit-border-radius: 14px 0 0 14px; + -moz-border-radius: 14px 0 0 14px; + border-radius: 14px 0 0 14px; +} + +.form-search input, +.form-inline input, +.form-horizontal input, +.form-search textarea, +.form-inline textarea, +.form-horizontal textarea, +.form-search select, +.form-inline select, +.form-horizontal select, +.form-search .help-inline, +.form-inline .help-inline, +.form-horizontal .help-inline, +.form-search .uneditable-input, +.form-inline .uneditable-input, +.form-horizontal .uneditable-input, +.form-search .input-prepend, +.form-inline .input-prepend, +.form-horizontal .input-prepend, +.form-search .input-append, +.form-inline .input-append, +.form-horizontal .input-append { + display: inline-block; + *display: inline; + margin-bottom: 0; + vertical-align: middle; + *zoom: 1; +} + +.form-search .hide, +.form-inline .hide, +.form-horizontal .hide { + display: none; +} + +.form-search label, +.form-inline label, +.form-search .btn-group, +.form-inline .btn-group { + display: inline-block; +} + +.form-search .input-append, +.form-inline .input-append, +.form-search .input-prepend, +.form-inline .input-prepend { + margin-bottom: 0; +} + +.form-search .radio, +.form-search .checkbox, +.form-inline .radio, +.form-inline .checkbox { + padding-left: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.form-search .radio input[type="radio"], +.form-search .checkbox input[type="checkbox"], +.form-inline .radio input[type="radio"], +.form-inline .checkbox input[type="checkbox"] { + float: left; + margin-right: 3px; + margin-left: 0; +} + +.control-group { + margin-bottom: 10px; +} + +legend + .control-group { + margin-top: 20px; + -webkit-margin-top-collapse: separate; +} + +.form-horizontal .control-group { + margin-bottom: 20px; + *zoom: 1; +} + +.form-horizontal .control-group:before, +.form-horizontal .control-group:after { + display: table; + line-height: 0; + content: ""; +} + +.form-horizontal .control-group:after { + clear: both; +} + +.form-horizontal .control-label { + float: left; + width: 160px; + padding-top: 5px; + text-align: right; +} + +.form-horizontal .controls { + *display: inline-block; + *padding-left: 20px; + margin-left: 180px; + *margin-left: 0; +} + +.form-horizontal .controls:first-child { + *padding-left: 180px; +} + +.form-horizontal .help-block { + margin-bottom: 0; +} + +.form-horizontal input + .help-block, +.form-horizontal select + .help-block, +.form-horizontal textarea + .help-block, +.form-horizontal .uneditable-input + .help-block, +.form-horizontal .input-prepend + .help-block, +.form-horizontal .input-append + .help-block { + margin-top: 10px; +} + +.form-horizontal .form-actions { + padding-left: 180px; +} + +table { + max-width: 100%; + background-color: transparent; + border-collapse: collapse; + border-spacing: 0; +} + +.table { + width: 100%; + margin-bottom: 20px; +} + +.table th, +.table td { + padding: 8px; + line-height: 20px; + text-align: left; + vertical-align: top; + border-top: 1px solid #dddddd; +} + +.table th { + font-weight: bold; +} + +.table thead th { + vertical-align: bottom; +} + +.table caption + thead tr:first-child th, +.table caption + thead tr:first-child td, +.table colgroup + thead tr:first-child th, +.table colgroup + thead tr:first-child td, +.table thead:first-child tr:first-child th, +.table thead:first-child tr:first-child td { + border-top: 0; +} + +.table tbody + tbody { + border-top: 2px solid #dddddd; +} + +.table .table { + background-color: #ffffff; +} + +.table-condensed th, +.table-condensed td { + padding: 4px 5px; +} + +.table-bordered { + border: 1px solid #dddddd; + border-collapse: separate; + *border-collapse: collapse; + border-left: 0; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.table-bordered th, +.table-bordered td { + border-left: 1px solid #dddddd; +} + +.table-bordered caption + thead tr:first-child th, +.table-bordered caption + tbody tr:first-child th, +.table-bordered caption + tbody tr:first-child td, +.table-bordered colgroup + thead tr:first-child th, +.table-bordered colgroup + tbody tr:first-child th, +.table-bordered colgroup + tbody tr:first-child td, +.table-bordered thead:first-child tr:first-child th, +.table-bordered tbody:first-child tr:first-child th, +.table-bordered tbody:first-child tr:first-child td { + border-top: 0; +} + +.table-bordered thead:first-child tr:first-child > th:first-child, +.table-bordered tbody:first-child tr:first-child > td:first-child, +.table-bordered tbody:first-child tr:first-child > th:first-child { + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; +} + +.table-bordered thead:first-child tr:first-child > th:last-child, +.table-bordered tbody:first-child tr:first-child > td:last-child, +.table-bordered tbody:first-child tr:first-child > th:last-child { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; +} + +.table-bordered thead:last-child tr:last-child > th:first-child, +.table-bordered tbody:last-child tr:last-child > td:first-child, +.table-bordered tbody:last-child tr:last-child > th:first-child, +.table-bordered tfoot:last-child tr:last-child > td:first-child, +.table-bordered tfoot:last-child tr:last-child > th:first-child { + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; +} + +.table-bordered thead:last-child tr:last-child > th:last-child, +.table-bordered tbody:last-child tr:last-child > td:last-child, +.table-bordered tbody:last-child tr:last-child > th:last-child, +.table-bordered tfoot:last-child tr:last-child > td:last-child, +.table-bordered tfoot:last-child tr:last-child > th:last-child { + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-bottomright: 4px; +} + +.table-bordered tfoot + tbody:last-child tr:last-child td:first-child { + -webkit-border-bottom-left-radius: 0; + border-bottom-left-radius: 0; + -moz-border-radius-bottomleft: 0; +} + +.table-bordered tfoot + tbody:last-child tr:last-child td:last-child { + -webkit-border-bottom-right-radius: 0; + border-bottom-right-radius: 0; + -moz-border-radius-bottomright: 0; +} + +.table-bordered caption + thead tr:first-child th:first-child, +.table-bordered caption + tbody tr:first-child td:first-child, +.table-bordered colgroup + thead tr:first-child th:first-child, +.table-bordered colgroup + tbody tr:first-child td:first-child { + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; +} + +.table-bordered caption + thead tr:first-child th:last-child, +.table-bordered caption + tbody tr:first-child td:last-child, +.table-bordered colgroup + thead tr:first-child th:last-child, +.table-bordered colgroup + tbody tr:first-child td:last-child { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; +} + +.table-striped tbody > tr:nth-child(odd) > td, +.table-striped tbody > tr:nth-child(odd) > th { + background-color: #f9f9f9; +} + +.table-hover tbody tr:hover > td, +.table-hover tbody tr:hover > th { + background-color: #f5f5f5; +} + +table td[class*="span"], +table th[class*="span"], +.row-fluid table td[class*="span"], +.row-fluid table th[class*="span"] { + display: table-cell; + float: none; + margin-left: 0; +} + +.table td.span1, +.table th.span1 { + float: none; + width: 44px; + margin-left: 0; +} + +.table td.span2, +.table th.span2 { + float: none; + width: 124px; + margin-left: 0; +} + +.table td.span3, +.table th.span3 { + float: none; + width: 204px; + margin-left: 0; +} + +.table td.span4, +.table th.span4 { + float: none; + width: 284px; + margin-left: 0; +} + +.table td.span5, +.table th.span5 { + float: none; + width: 364px; + margin-left: 0; +} + +.table td.span6, +.table th.span6 { + float: none; + width: 444px; + margin-left: 0; +} + +.table td.span7, +.table th.span7 { + float: none; + width: 524px; + margin-left: 0; +} + +.table td.span8, +.table th.span8 { + float: none; + width: 604px; + margin-left: 0; +} + +.table td.span9, +.table th.span9 { + float: none; + width: 684px; + margin-left: 0; +} + +.table td.span10, +.table th.span10 { + float: none; + width: 764px; + margin-left: 0; +} + +.table td.span11, +.table th.span11 { + float: none; + width: 844px; + margin-left: 0; +} + +.table td.span12, +.table th.span12 { + float: none; + width: 924px; + margin-left: 0; +} + +.table tbody tr.success > td { + background-color: #dff0d8; +} + +.table tbody tr.error > td { + background-color: #f2dede; +} + +.table tbody tr.warning > td { + background-color: #fcf8e3; +} + +.table tbody tr.info > td { + background-color: #d9edf7; +} + +.table-hover tbody tr.success:hover > td { + background-color: #d0e9c6; +} + +.table-hover tbody tr.error:hover > td { + background-color: #ebcccc; +} + +.table-hover tbody tr.warning:hover > td { + background-color: #faf2cc; +} + +.table-hover tbody tr.info:hover > td { + background-color: #c4e3f3; +} + +[class^="icon-"], +[class*=" icon-"] { + display: inline-block; + width: 14px; + height: 14px; + margin-top: 1px; + *margin-right: .3em; + line-height: 14px; + vertical-align: text-top; + background-image: url("../img/glyphicons-halflings.png"); + background-position: 14px 14px; + background-repeat: no-repeat; +} + +/* White icons with optional class, or on hover/focus/active states of certain elements */ + +.icon-white, +.nav-pills > .active > a > [class^="icon-"], +.nav-pills > .active > a > [class*=" icon-"], +.nav-list > .active > a > [class^="icon-"], +.nav-list > .active > a > [class*=" icon-"], +.navbar-inverse .nav > .active > a > [class^="icon-"], +.navbar-inverse .nav > .active > a > [class*=" icon-"], +.dropdown-menu > li > a:hover > [class^="icon-"], +.dropdown-menu > li > a:focus > [class^="icon-"], +.dropdown-menu > li > a:hover > [class*=" icon-"], +.dropdown-menu > li > a:focus > [class*=" icon-"], +.dropdown-menu > .active > a > [class^="icon-"], +.dropdown-menu > .active > a > [class*=" icon-"], +.dropdown-submenu:hover > a > [class^="icon-"], +.dropdown-submenu:focus > a > [class^="icon-"], +.dropdown-submenu:hover > a > [class*=" icon-"], +.dropdown-submenu:focus > a > [class*=" icon-"] { + background-image: url("../img/glyphicons-halflings-white.png"); +} + +.icon-glass { + background-position: 0 0; +} + +.icon-music { + background-position: -24px 0; +} + +.icon-search { + background-position: -48px 0; +} + +.icon-envelope { + background-position: -72px 0; +} + +.icon-heart { + background-position: -96px 0; +} + +.icon-star { + background-position: -120px 0; +} + +.icon-star-empty { + background-position: -144px 0; +} + +.icon-user { + background-position: -168px 0; +} + +.icon-film { + background-position: -192px 0; +} + +.icon-th-large { + background-position: -216px 0; +} + +.icon-th { + background-position: -240px 0; +} + +.icon-th-list { + background-position: -264px 0; +} + +.icon-ok { + background-position: -288px 0; +} + +.icon-remove { + background-position: -312px 0; +} + +.icon-zoom-in { + background-position: -336px 0; +} + +.icon-zoom-out { + background-position: -360px 0; +} + +.icon-off { + background-position: -384px 0; +} + +.icon-signal { + background-position: -408px 0; +} + +.icon-cog { + background-position: -432px 0; +} + +.icon-trash { + background-position: -456px 0; +} + +.icon-home { + background-position: 0 -24px; +} + +.icon-file { + background-position: -24px -24px; +} + +.icon-time { + background-position: -48px -24px; +} + +.icon-road { + background-position: -72px -24px; +} + +.icon-download-alt { + background-position: -96px -24px; +} + +.icon-download { + background-position: -120px -24px; +} + +.icon-upload { + background-position: -144px -24px; +} + +.icon-inbox { + background-position: -168px -24px; +} + +.icon-play-circle { + background-position: -192px -24px; +} + +.icon-repeat { + background-position: -216px -24px; +} + +.icon-refresh { + background-position: -240px -24px; +} + +.icon-list-alt { + background-position: -264px -24px; +} + +.icon-lock { + background-position: -287px -24px; +} + +.icon-flag { + background-position: -312px -24px; +} + +.icon-headphones { + background-position: -336px -24px; +} + +.icon-volume-off { + background-position: -360px -24px; +} + +.icon-volume-down { + background-position: -384px -24px; +} + +.icon-volume-up { + background-position: -408px -24px; +} + +.icon-qrcode { + background-position: -432px -24px; +} + +.icon-barcode { + background-position: -456px -24px; +} + +.icon-tag { + background-position: 0 -48px; +} + +.icon-tags { + background-position: -25px -48px; +} + +.icon-book { + background-position: -48px -48px; +} + +.icon-bookmark { + background-position: -72px -48px; +} + +.icon-print { + background-position: -96px -48px; +} + +.icon-camera { + background-position: -120px -48px; +} + +.icon-font { + background-position: -144px -48px; +} + +.icon-bold { + background-position: -167px -48px; +} + +.icon-italic { + background-position: -192px -48px; +} + +.icon-text-height { + background-position: -216px -48px; +} + +.icon-text-width { + background-position: -240px -48px; +} + +.icon-align-left { + background-position: -264px -48px; +} + +.icon-align-center { + background-position: -288px -48px; +} + +.icon-align-right { + background-position: -312px -48px; +} + +.icon-align-justify { + background-position: -336px -48px; +} + +.icon-list { + background-position: -360px -48px; +} + +.icon-indent-left { + background-position: -384px -48px; +} + +.icon-indent-right { + background-position: -408px -48px; +} + +.icon-facetime-video { + background-position: -432px -48px; +} + +.icon-picture { + background-position: -456px -48px; +} + +.icon-pencil { + background-position: 0 -72px; +} + +.icon-map-marker { + background-position: -24px -72px; +} + +.icon-adjust { + background-position: -48px -72px; +} + +.icon-tint { + background-position: -72px -72px; +} + +.icon-edit { + background-position: -96px -72px; +} + +.icon-share { + background-position: -120px -72px; +} + +.icon-check { + background-position: -144px -72px; +} + +.icon-move { + background-position: -168px -72px; +} + +.icon-step-backward { + background-position: -192px -72px; +} + +.icon-fast-backward { + background-position: -216px -72px; +} + +.icon-backward { + background-position: -240px -72px; +} + +.icon-play { + background-position: -264px -72px; +} + +.icon-pause { + background-position: -288px -72px; +} + +.icon-stop { + background-position: -312px -72px; +} + +.icon-forward { + background-position: -336px -72px; +} + +.icon-fast-forward { + background-position: -360px -72px; +} + +.icon-step-forward { + background-position: -384px -72px; +} + +.icon-eject { + background-position: -408px -72px; +} + +.icon-chevron-left { + background-position: -432px -72px; +} + +.icon-chevron-right { + background-position: -456px -72px; +} + +.icon-plus-sign { + background-position: 0 -96px; +} + +.icon-minus-sign { + background-position: -24px -96px; +} + +.icon-remove-sign { + background-position: -48px -96px; +} + +.icon-ok-sign { + background-position: -72px -96px; +} + +.icon-question-sign { + background-position: -96px -96px; +} + +.icon-info-sign { + background-position: -120px -96px; +} + +.icon-screenshot { + background-position: -144px -96px; +} + +.icon-remove-circle { + background-position: -168px -96px; +} + +.icon-ok-circle { + background-position: -192px -96px; +} + +.icon-ban-circle { + background-position: -216px -96px; +} + +.icon-arrow-left { + background-position: -240px -96px; +} + +.icon-arrow-right { + background-position: -264px -96px; +} + +.icon-arrow-up { + background-position: -289px -96px; +} + +.icon-arrow-down { + background-position: -312px -96px; +} + +.icon-share-alt { + background-position: -336px -96px; +} + +.icon-resize-full { + background-position: -360px -96px; +} + +.icon-resize-small { + background-position: -384px -96px; +} + +.icon-plus { + background-position: -408px -96px; +} + +.icon-minus { + background-position: -433px -96px; +} + +.icon-asterisk { + background-position: -456px -96px; +} + +.icon-exclamation-sign { + background-position: 0 -120px; +} + +.icon-gift { + background-position: -24px -120px; +} + +.icon-leaf { + background-position: -48px -120px; +} + +.icon-fire { + background-position: -72px -120px; +} + +.icon-eye-open { + background-position: -96px -120px; +} + +.icon-eye-close { + background-position: -120px -120px; +} + +.icon-warning-sign { + background-position: -144px -120px; +} + +.icon-plane { + background-position: -168px -120px; +} + +.icon-calendar { + background-position: -192px -120px; +} + +.icon-random { + width: 16px; + background-position: -216px -120px; +} + +.icon-comment { + background-position: -240px -120px; +} + +.icon-magnet { + background-position: -264px -120px; +} + +.icon-chevron-up { + background-position: -288px -120px; +} + +.icon-chevron-down { + background-position: -313px -119px; +} + +.icon-retweet { + background-position: -336px -120px; +} + +.icon-shopping-cart { + background-position: -360px -120px; +} + +.icon-folder-close { + width: 16px; + background-position: -384px -120px; +} + +.icon-folder-open { + width: 16px; + background-position: -408px -120px; +} + +.icon-resize-vertical { + background-position: -432px -119px; +} + +.icon-resize-horizontal { + background-position: -456px -118px; +} + +.icon-hdd { + background-position: 0 -144px; +} + +.icon-bullhorn { + background-position: -24px -144px; +} + +.icon-bell { + background-position: -48px -144px; +} + +.icon-certificate { + background-position: -72px -144px; +} + +.icon-thumbs-up { + background-position: -96px -144px; +} + +.icon-thumbs-down { + background-position: -120px -144px; +} + +.icon-hand-right { + background-position: -144px -144px; +} + +.icon-hand-left { + background-position: -168px -144px; +} + +.icon-hand-up { + background-position: -192px -144px; +} + +.icon-hand-down { + background-position: -216px -144px; +} + +.icon-circle-arrow-right { + background-position: -240px -144px; +} + +.icon-circle-arrow-left { + background-position: -264px -144px; +} + +.icon-circle-arrow-up { + background-position: -288px -144px; +} + +.icon-circle-arrow-down { + background-position: -312px -144px; +} + +.icon-globe { + background-position: -336px -144px; +} + +.icon-wrench { + background-position: -360px -144px; +} + +.icon-tasks { + background-position: -384px -144px; +} + +.icon-filter { + background-position: -408px -144px; +} + +.icon-briefcase { + background-position: -432px -144px; +} + +.icon-fullscreen { + background-position: -456px -144px; +} + +.dropup, +.dropdown { + position: relative; +} + +.dropdown-toggle { + *margin-bottom: -3px; +} + +.dropdown-toggle:active, +.open .dropdown-toggle { + outline: 0; +} + +.caret { + display: inline-block; + width: 0; + height: 0; + vertical-align: top; + border-top: 4px solid #000000; + border-right: 4px solid transparent; + border-left: 4px solid transparent; + content: ""; +} + +.dropdown .caret { + margin-top: 8px; + margin-left: 2px; +} + +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 2px 0 0; + list-style: none; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + *border-right-width: 2px; + *border-bottom-width: 2px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.dropdown-menu .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.dropdown-menu > li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 20px; + color: #333333; + white-space: nowrap; +} + +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus, +.dropdown-submenu:hover > a, +.dropdown-submenu:focus > a { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .active > a, +.dropdown-menu > .active > a:hover, +.dropdown-menu > .active > a:focus { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + outline: 0; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .disabled > a, +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + color: #999999; +} + +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.open { + *z-index: 1000; +} + +.open > .dropdown-menu { + display: block; +} + +.dropdown-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 990; +} + +.pull-right > .dropdown-menu { + right: 0; + left: auto; +} + +.dropup .caret, +.navbar-fixed-bottom .dropdown .caret { + border-top: 0; + border-bottom: 4px solid #000000; + content: ""; +} + +.dropup .dropdown-menu, +.navbar-fixed-bottom .dropdown .dropdown-menu { + top: auto; + bottom: 100%; + margin-bottom: 1px; +} + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu > .dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + -webkit-border-radius: 0 6px 6px 6px; + -moz-border-radius: 0 6px 6px 6px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover > .dropdown-menu { + display: block; +} + +.dropup .dropdown-submenu > .dropdown-menu { + top: auto; + bottom: 0; + margin-top: 0; + margin-bottom: -2px; + -webkit-border-radius: 5px 5px 5px 0; + -moz-border-radius: 5px 5px 5px 0; + border-radius: 5px 5px 5px 0; +} + +.dropdown-submenu > a:after { + display: block; + float: right; + width: 0; + height: 0; + margin-top: 5px; + margin-right: -10px; + border-color: transparent; + border-left-color: #cccccc; + border-style: solid; + border-width: 5px 0 5px 5px; + content: " "; +} + +.dropdown-submenu:hover > a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left > .dropdown-menu { + left: -100%; + margin-left: 10px; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; +} + +.dropdown .dropdown-menu .nav-header { + padding-right: 20px; + padding-left: 20px; +} + +.typeahead { + z-index: 1051; + margin-top: 2px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.well { + min-height: 20px; + padding: 19px; + margin-bottom: 20px; + background-color: #f5f5f5; + border: 1px solid #e3e3e3; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); +} + +.well blockquote { + border-color: #ddd; + border-color: rgba(0, 0, 0, 0.15); +} + +.well-large { + padding: 24px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.well-small { + padding: 9px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.fade { + opacity: 0; + -webkit-transition: opacity 0.15s linear; + -moz-transition: opacity 0.15s linear; + -o-transition: opacity 0.15s linear; + transition: opacity 0.15s linear; +} + +.fade.in { + opacity: 1; +} + +.collapse { + position: relative; + height: 0; + overflow: hidden; + -webkit-transition: height 0.35s ease; + -moz-transition: height 0.35s ease; + -o-transition: height 0.35s ease; + transition: height 0.35s ease; +} + +.collapse.in { + height: auto; +} + +.close { + float: right; + font-size: 20px; + font-weight: bold; + line-height: 20px; + color: #000000; + text-shadow: 0 1px 0 #ffffff; + opacity: 0.2; + filter: alpha(opacity=20); +} + +.close:hover, +.close:focus { + color: #000000; + text-decoration: none; + cursor: pointer; + opacity: 0.4; + filter: alpha(opacity=40); +} + +button.close { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; +} + +.btn { + display: inline-block; + *display: inline; + padding: 4px 12px; + margin-bottom: 0; + *margin-left: .3em; + font-size: 14px; + line-height: 20px; + color: #333333; + text-align: center; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); + vertical-align: middle; + cursor: pointer; + background-color: #f5f5f5; + *background-color: #e6e6e6; + background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); + background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-repeat: repeat-x; + border: 1px solid #cccccc; + *border: 0; + border-color: #e6e6e6 #e6e6e6 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + border-bottom-color: #b3b3b3; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); + *zoom: 1; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn:hover, +.btn:focus, +.btn:active, +.btn.active, +.btn.disabled, +.btn[disabled] { + color: #333333; + background-color: #e6e6e6; + *background-color: #d9d9d9; +} + +.btn:active, +.btn.active { + background-color: #cccccc \9; +} + +.btn:first-child { + *margin-left: 0; +} + +.btn:hover, +.btn:focus { + color: #333333; + text-decoration: none; + background-position: 0 -15px; + -webkit-transition: background-position 0.1s linear; + -moz-transition: background-position 0.1s linear; + -o-transition: background-position 0.1s linear; + transition: background-position 0.1s linear; +} + +.btn:focus { + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} + +.btn.active, +.btn:active { + background-image: none; + outline: 0; + -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn.disabled, +.btn[disabled] { + cursor: default; + background-image: none; + opacity: 0.65; + filter: alpha(opacity=65); + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.btn-large { + padding: 11px 19px; + font-size: 17.5px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.btn-large [class^="icon-"], +.btn-large [class*=" icon-"] { + margin-top: 4px; +} + +.btn-small { + padding: 2px 10px; + font-size: 11.9px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.btn-small [class^="icon-"], +.btn-small [class*=" icon-"] { + margin-top: 0; +} + +.btn-mini [class^="icon-"], +.btn-mini [class*=" icon-"] { + margin-top: -1px; +} + +.btn-mini { + padding: 0 6px; + font-size: 10.5px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.btn-block { + display: block; + width: 100%; + padding-right: 0; + padding-left: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.btn-block + .btn-block { + margin-top: 5px; +} + +input[type="submit"].btn-block, +input[type="reset"].btn-block, +input[type="button"].btn-block { + width: 100%; +} + +.btn-primary.active, +.btn-warning.active, +.btn-danger.active, +.btn-success.active, +.btn-info.active, +.btn-inverse.active { + color: rgba(255, 255, 255, 0.75); +} + +.btn-primary { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #006dcc; + *background-color: #0044cc; + background-image: -moz-linear-gradient(top, #0088cc, #0044cc); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); + background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); + background-image: -o-linear-gradient(top, #0088cc, #0044cc); + background-image: linear-gradient(to bottom, #0088cc, #0044cc); + background-repeat: repeat-x; + border-color: #0044cc #0044cc #002a80; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-primary:hover, +.btn-primary:focus, +.btn-primary:active, +.btn-primary.active, +.btn-primary.disabled, +.btn-primary[disabled] { + color: #ffffff; + background-color: #0044cc; + *background-color: #003bb3; +} + +.btn-primary:active, +.btn-primary.active { + background-color: #003399 \9; +} + +.btn-warning { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #faa732; + *background-color: #f89406; + background-image: -moz-linear-gradient(top, #fbb450, #f89406); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); + background-image: -webkit-linear-gradient(top, #fbb450, #f89406); + background-image: -o-linear-gradient(top, #fbb450, #f89406); + background-image: linear-gradient(to bottom, #fbb450, #f89406); + background-repeat: repeat-x; + border-color: #f89406 #f89406 #ad6704; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-warning:hover, +.btn-warning:focus, +.btn-warning:active, +.btn-warning.active, +.btn-warning.disabled, +.btn-warning[disabled] { + color: #ffffff; + background-color: #f89406; + *background-color: #df8505; +} + +.btn-warning:active, +.btn-warning.active { + background-color: #c67605 \9; +} + +.btn-danger { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #da4f49; + *background-color: #bd362f; + background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f)); + background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f); + background-image: -o-linear-gradient(top, #ee5f5b, #bd362f); + background-image: linear-gradient(to bottom, #ee5f5b, #bd362f); + background-repeat: repeat-x; + border-color: #bd362f #bd362f #802420; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-danger:hover, +.btn-danger:focus, +.btn-danger:active, +.btn-danger.active, +.btn-danger.disabled, +.btn-danger[disabled] { + color: #ffffff; + background-color: #bd362f; + *background-color: #a9302a; +} + +.btn-danger:active, +.btn-danger.active { + background-color: #942a25 \9; +} + +.btn-success { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #5bb75b; + *background-color: #51a351; + background-image: -moz-linear-gradient(top, #62c462, #51a351); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351)); + background-image: -webkit-linear-gradient(top, #62c462, #51a351); + background-image: -o-linear-gradient(top, #62c462, #51a351); + background-image: linear-gradient(to bottom, #62c462, #51a351); + background-repeat: repeat-x; + border-color: #51a351 #51a351 #387038; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-success:hover, +.btn-success:focus, +.btn-success:active, +.btn-success.active, +.btn-success.disabled, +.btn-success[disabled] { + color: #ffffff; + background-color: #51a351; + *background-color: #499249; +} + +.btn-success:active, +.btn-success.active { + background-color: #408140 \9; +} + +.btn-info { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #49afcd; + *background-color: #2f96b4; + background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4)); + background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4); + background-image: -o-linear-gradient(top, #5bc0de, #2f96b4); + background-image: linear-gradient(to bottom, #5bc0de, #2f96b4); + background-repeat: repeat-x; + border-color: #2f96b4 #2f96b4 #1f6377; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-info:hover, +.btn-info:focus, +.btn-info:active, +.btn-info.active, +.btn-info.disabled, +.btn-info[disabled] { + color: #ffffff; + background-color: #2f96b4; + *background-color: #2a85a0; +} + +.btn-info:active, +.btn-info.active { + background-color: #24748c \9; +} + +.btn-inverse { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #363636; + *background-color: #222222; + background-image: -moz-linear-gradient(top, #444444, #222222); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222)); + background-image: -webkit-linear-gradient(top, #444444, #222222); + background-image: -o-linear-gradient(top, #444444, #222222); + background-image: linear-gradient(to bottom, #444444, #222222); + background-repeat: repeat-x; + border-color: #222222 #222222 #000000; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.btn-inverse:hover, +.btn-inverse:focus, +.btn-inverse:active, +.btn-inverse.active, +.btn-inverse.disabled, +.btn-inverse[disabled] { + color: #ffffff; + background-color: #222222; + *background-color: #151515; +} + +.btn-inverse:active, +.btn-inverse.active { + background-color: #080808 \9; +} + +button.btn, +input[type="submit"].btn { + *padding-top: 3px; + *padding-bottom: 3px; +} + +button.btn::-moz-focus-inner, +input[type="submit"].btn::-moz-focus-inner { + padding: 0; + border: 0; +} + +button.btn.btn-large, +input[type="submit"].btn.btn-large { + *padding-top: 7px; + *padding-bottom: 7px; +} + +button.btn.btn-small, +input[type="submit"].btn.btn-small { + *padding-top: 3px; + *padding-bottom: 3px; +} + +button.btn.btn-mini, +input[type="submit"].btn.btn-mini { + *padding-top: 1px; + *padding-bottom: 1px; +} + +.btn-link, +.btn-link:active, +.btn-link[disabled] { + background-color: transparent; + background-image: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.btn-link { + color: #0088cc; + cursor: pointer; + border-color: transparent; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-link:hover, +.btn-link:focus { + color: #005580; + text-decoration: underline; + background-color: transparent; +} + +.btn-link[disabled]:hover, +.btn-link[disabled]:focus { + color: #333333; + text-decoration: none; +} + +.btn-group { + position: relative; + display: inline-block; + *display: inline; + *margin-left: .3em; + font-size: 0; + white-space: nowrap; + vertical-align: middle; + *zoom: 1; +} + +.btn-group:first-child { + *margin-left: 0; +} + +.btn-group + .btn-group { + margin-left: 5px; +} + +.btn-toolbar { + margin-top: 10px; + margin-bottom: 10px; + font-size: 0; +} + +.btn-toolbar > .btn + .btn, +.btn-toolbar > .btn-group + .btn, +.btn-toolbar > .btn + .btn-group { + margin-left: 5px; +} + +.btn-group > .btn { + position: relative; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-group > .btn + .btn { + margin-left: -1px; +} + +.btn-group > .btn, +.btn-group > .dropdown-menu, +.btn-group > .popover { + font-size: 14px; +} + +.btn-group > .btn-mini { + font-size: 10.5px; +} + +.btn-group > .btn-small { + font-size: 11.9px; +} + +.btn-group > .btn-large { + font-size: 17.5px; +} + +.btn-group > .btn:first-child { + margin-left: 0; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-topleft: 4px; +} + +.btn-group > .btn:last-child, +.btn-group > .dropdown-toggle { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-bottomright: 4px; +} + +.btn-group > .btn.large:first-child { + margin-left: 0; + -webkit-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -webkit-border-top-left-radius: 6px; + border-top-left-radius: 6px; + -moz-border-radius-bottomleft: 6px; + -moz-border-radius-topleft: 6px; +} + +.btn-group > .btn.large:last-child, +.btn-group > .large.dropdown-toggle { + -webkit-border-top-right-radius: 6px; + border-top-right-radius: 6px; + -webkit-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + -moz-border-radius-topright: 6px; + -moz-border-radius-bottomright: 6px; +} + +.btn-group > .btn:hover, +.btn-group > .btn:focus, +.btn-group > .btn:active, +.btn-group > .btn.active { + z-index: 2; +} + +.btn-group .dropdown-toggle:active, +.btn-group.open .dropdown-toggle { + outline: 0; +} + +.btn-group > .btn + .dropdown-toggle { + *padding-top: 5px; + padding-right: 8px; + *padding-bottom: 5px; + padding-left: 8px; + -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn-group > .btn-mini + .dropdown-toggle { + *padding-top: 2px; + padding-right: 5px; + *padding-bottom: 2px; + padding-left: 5px; +} + +.btn-group > .btn-small + .dropdown-toggle { + *padding-top: 5px; + *padding-bottom: 4px; +} + +.btn-group > .btn-large + .dropdown-toggle { + *padding-top: 7px; + padding-right: 12px; + *padding-bottom: 7px; + padding-left: 12px; +} + +.btn-group.open .dropdown-toggle { + background-image: none; + -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.btn-group.open .btn.dropdown-toggle { + background-color: #e6e6e6; +} + +.btn-group.open .btn-primary.dropdown-toggle { + background-color: #0044cc; +} + +.btn-group.open .btn-warning.dropdown-toggle { + background-color: #f89406; +} + +.btn-group.open .btn-danger.dropdown-toggle { + background-color: #bd362f; +} + +.btn-group.open .btn-success.dropdown-toggle { + background-color: #51a351; +} + +.btn-group.open .btn-info.dropdown-toggle { + background-color: #2f96b4; +} + +.btn-group.open .btn-inverse.dropdown-toggle { + background-color: #222222; +} + +.btn .caret { + margin-top: 8px; + margin-left: 0; +} + +.btn-large .caret { + margin-top: 6px; +} + +.btn-large .caret { + border-top-width: 5px; + border-right-width: 5px; + border-left-width: 5px; +} + +.btn-mini .caret, +.btn-small .caret { + margin-top: 8px; +} + +.dropup .btn-large .caret { + border-bottom-width: 5px; +} + +.btn-primary .caret, +.btn-warning .caret, +.btn-danger .caret, +.btn-info .caret, +.btn-success .caret, +.btn-inverse .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.btn-group-vertical { + display: inline-block; + *display: inline; + /* IE7 inline-block hack */ + + *zoom: 1; +} + +.btn-group-vertical > .btn { + display: block; + float: none; + max-width: 100%; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.btn-group-vertical > .btn + .btn { + margin-top: -1px; + margin-left: 0; +} + +.btn-group-vertical > .btn:first-child { + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +.btn-group-vertical > .btn:last-child { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius: 0 0 4px 4px; + border-radius: 0 0 4px 4px; +} + +.btn-group-vertical > .btn-large:first-child { + -webkit-border-radius: 6px 6px 0 0; + -moz-border-radius: 6px 6px 0 0; + border-radius: 6px 6px 0 0; +} + +.btn-group-vertical > .btn-large:last-child { + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; +} + +.alert { + padding: 8px 35px 8px 14px; + margin-bottom: 20px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + background-color: #fcf8e3; + border: 1px solid #fbeed5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.alert, +.alert h4 { + color: #c09853; +} + +.alert h4 { + margin: 0; +} + +.alert .close { + position: relative; + top: -2px; + right: -21px; + line-height: 20px; +} + +.alert-success { + color: #468847; + background-color: #dff0d8; + border-color: #d6e9c6; +} + +.alert-success h4 { + color: #468847; +} + +.alert-danger, +.alert-error { + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; +} + +.alert-danger h4, +.alert-error h4 { + color: #b94a48; +} + +.alert-info { + color: #3a87ad; + background-color: #d9edf7; + border-color: #bce8f1; +} + +.alert-info h4 { + color: #3a87ad; +} + +.alert-block { + padding-top: 14px; + padding-bottom: 14px; +} + +.alert-block > p, +.alert-block > ul { + margin-bottom: 0; +} + +.alert-block p + p { + margin-top: 5px; +} + +.nav { + margin-bottom: 20px; + margin-left: 0; + list-style: none; +} + +.nav > li > a { + display: block; +} + +.nav > li > a:hover, +.nav > li > a:focus { + text-decoration: none; + background-color: #eeeeee; +} + +.nav > li > a > img { + max-width: none; +} + +.nav > .pull-right { + float: right; +} + +.nav-header { + display: block; + padding: 3px 15px; + font-size: 11px; + font-weight: bold; + line-height: 20px; + color: #999999; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + text-transform: uppercase; +} + +.nav li + .nav-header { + margin-top: 9px; +} + +.nav-list { + padding-right: 15px; + padding-left: 15px; + margin-bottom: 0; +} + +.nav-list > li > a, +.nav-list .nav-header { + margin-right: -15px; + margin-left: -15px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); +} + +.nav-list > li > a { + padding: 3px 15px; +} + +.nav-list > .active > a, +.nav-list > .active > a:hover, +.nav-list > .active > a:focus { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); + background-color: #0088cc; +} + +.nav-list [class^="icon-"], +.nav-list [class*=" icon-"] { + margin-right: 2px; +} + +.nav-list .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.nav-tabs, +.nav-pills { + *zoom: 1; +} + +.nav-tabs:before, +.nav-pills:before, +.nav-tabs:after, +.nav-pills:after { + display: table; + line-height: 0; + content: ""; +} + +.nav-tabs:after, +.nav-pills:after { + clear: both; +} + +.nav-tabs > li, +.nav-pills > li { + float: left; +} + +.nav-tabs > li > a, +.nav-pills > li > a { + padding-right: 12px; + padding-left: 12px; + margin-right: 2px; + line-height: 14px; +} + +.nav-tabs { + border-bottom: 1px solid #ddd; +} + +.nav-tabs > li { + margin-bottom: -1px; +} + +.nav-tabs > li > a { + padding-top: 8px; + padding-bottom: 8px; + line-height: 20px; + border: 1px solid transparent; + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +.nav-tabs > li > a:hover, +.nav-tabs > li > a:focus { + border-color: #eeeeee #eeeeee #dddddd; +} + +.nav-tabs > .active > a, +.nav-tabs > .active > a:hover, +.nav-tabs > .active > a:focus { + color: #555555; + cursor: default; + background-color: #ffffff; + border: 1px solid #ddd; + border-bottom-color: transparent; +} + +.nav-pills > li > a { + padding-top: 8px; + padding-bottom: 8px; + margin-top: 2px; + margin-bottom: 2px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.nav-pills > .active > a, +.nav-pills > .active > a:hover, +.nav-pills > .active > a:focus { + color: #ffffff; + background-color: #0088cc; +} + +.nav-stacked > li { + float: none; +} + +.nav-stacked > li > a { + margin-right: 0; +} + +.nav-tabs.nav-stacked { + border-bottom: 0; +} + +.nav-tabs.nav-stacked > li > a { + border: 1px solid #ddd; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.nav-tabs.nav-stacked > li:first-child > a { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-topleft: 4px; +} + +.nav-tabs.nav-stacked > li:last-child > a { + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomright: 4px; + -moz-border-radius-bottomleft: 4px; +} + +.nav-tabs.nav-stacked > li > a:hover, +.nav-tabs.nav-stacked > li > a:focus { + z-index: 2; + border-color: #ddd; +} + +.nav-pills.nav-stacked > li > a { + margin-bottom: 3px; +} + +.nav-pills.nav-stacked > li:last-child > a { + margin-bottom: 1px; +} + +.nav-tabs .dropdown-menu { + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; +} + +.nav-pills .dropdown-menu { + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.nav .dropdown-toggle .caret { + margin-top: 6px; + border-top-color: #0088cc; + border-bottom-color: #0088cc; +} + +.nav .dropdown-toggle:hover .caret, +.nav .dropdown-toggle:focus .caret { + border-top-color: #005580; + border-bottom-color: #005580; +} + +/* move down carets for tabs */ + +.nav-tabs .dropdown-toggle .caret { + margin-top: 8px; +} + +.nav .active .dropdown-toggle .caret { + border-top-color: #fff; + border-bottom-color: #fff; +} + +.nav-tabs .active .dropdown-toggle .caret { + border-top-color: #555555; + border-bottom-color: #555555; +} + +.nav > .dropdown.active > a:hover, +.nav > .dropdown.active > a:focus { + cursor: pointer; +} + +.nav-tabs .open .dropdown-toggle, +.nav-pills .open .dropdown-toggle, +.nav > li.dropdown.open.active > a:hover, +.nav > li.dropdown.open.active > a:focus { + color: #ffffff; + background-color: #999999; + border-color: #999999; +} + +.nav li.dropdown.open .caret, +.nav li.dropdown.open.active .caret, +.nav li.dropdown.open a:hover .caret, +.nav li.dropdown.open a:focus .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; + opacity: 1; + filter: alpha(opacity=100); +} + +.tabs-stacked .open > a:hover, +.tabs-stacked .open > a:focus { + border-color: #999999; +} + +.tabbable { + *zoom: 1; +} + +.tabbable:before, +.tabbable:after { + display: table; + line-height: 0; + content: ""; +} + +.tabbable:after { + clear: both; +} + +.tab-content { + overflow: auto; +} + +.tabs-below > .nav-tabs, +.tabs-right > .nav-tabs, +.tabs-left > .nav-tabs { + border-bottom: 0; +} + +.tab-content > .tab-pane, +.pill-content > .pill-pane { + display: none; +} + +.tab-content > .active, +.pill-content > .active { + display: block; +} + +.tabs-below > .nav-tabs { + border-top: 1px solid #ddd; +} + +.tabs-below > .nav-tabs > li { + margin-top: -1px; + margin-bottom: 0; +} + +.tabs-below > .nav-tabs > li > a { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius: 0 0 4px 4px; + border-radius: 0 0 4px 4px; +} + +.tabs-below > .nav-tabs > li > a:hover, +.tabs-below > .nav-tabs > li > a:focus { + border-top-color: #ddd; + border-bottom-color: transparent; +} + +.tabs-below > .nav-tabs > .active > a, +.tabs-below > .nav-tabs > .active > a:hover, +.tabs-below > .nav-tabs > .active > a:focus { + border-color: transparent #ddd #ddd #ddd; +} + +.tabs-left > .nav-tabs > li, +.tabs-right > .nav-tabs > li { + float: none; +} + +.tabs-left > .nav-tabs > li > a, +.tabs-right > .nav-tabs > li > a { + min-width: 74px; + margin-right: 0; + margin-bottom: 3px; +} + +.tabs-left > .nav-tabs { + float: left; + margin-right: 19px; + border-right: 1px solid #ddd; +} + +.tabs-left > .nav-tabs > li > a { + margin-right: -1px; + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.tabs-left > .nav-tabs > li > a:hover, +.tabs-left > .nav-tabs > li > a:focus { + border-color: #eeeeee #dddddd #eeeeee #eeeeee; +} + +.tabs-left > .nav-tabs .active > a, +.tabs-left > .nav-tabs .active > a:hover, +.tabs-left > .nav-tabs .active > a:focus { + border-color: #ddd transparent #ddd #ddd; + *border-right-color: #ffffff; +} + +.tabs-right > .nav-tabs { + float: right; + margin-left: 19px; + border-left: 1px solid #ddd; +} + +.tabs-right > .nav-tabs > li > a { + margin-left: -1px; + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.tabs-right > .nav-tabs > li > a:hover, +.tabs-right > .nav-tabs > li > a:focus { + border-color: #eeeeee #eeeeee #eeeeee #dddddd; +} + +.tabs-right > .nav-tabs .active > a, +.tabs-right > .nav-tabs .active > a:hover, +.tabs-right > .nav-tabs .active > a:focus { + border-color: #ddd #ddd #ddd transparent; + *border-left-color: #ffffff; +} + +.nav > .disabled > a { + color: #999999; +} + +.nav > .disabled > a:hover, +.nav > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; +} + +.navbar { + *position: relative; + *z-index: 2; + margin-bottom: 20px; + overflow: visible; +} + +.navbar-inner { + min-height: 40px; + padding-right: 20px; + padding-left: 20px; + background-color: #fafafa; + background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2)); + background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2); + background-image: -o-linear-gradient(top, #ffffff, #f2f2f2); + background-image: linear-gradient(to bottom, #ffffff, #f2f2f2); + background-repeat: repeat-x; + border: 1px solid #d4d4d4; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0); + *zoom: 1; + -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); + -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); + box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065); +} + +.navbar-inner:before, +.navbar-inner:after { + display: table; + line-height: 0; + content: ""; +} + +.navbar-inner:after { + clear: both; +} + +.navbar .container { + width: auto; +} + +.nav-collapse.collapse { + height: auto; + overflow: visible; +} + +.navbar .brand { + display: block; + float: left; + padding: 10px 20px 10px; + margin-left: -20px; + font-size: 20px; + font-weight: 200; + color: #777777; + text-shadow: 0 1px 0 #ffffff; +} + +.navbar .brand:hover, +.navbar .brand:focus { + text-decoration: none; +} + +.navbar-text { + margin-bottom: 0; + line-height: 40px; + color: #777777; +} + +.navbar-link { + color: #777777; +} + +.navbar-link:hover, +.navbar-link:focus { + color: #333333; +} + +.navbar .divider-vertical { + height: 40px; + margin: 0 9px; + border-right: 1px solid #ffffff; + border-left: 1px solid #f2f2f2; +} + +.navbar .btn, +.navbar .btn-group { + margin-top: 5px; +} + +.navbar .btn-group .btn, +.navbar .input-prepend .btn, +.navbar .input-append .btn, +.navbar .input-prepend .btn-group, +.navbar .input-append .btn-group { + margin-top: 0; +} + +.navbar-form { + margin-bottom: 0; + *zoom: 1; +} + +.navbar-form:before, +.navbar-form:after { + display: table; + line-height: 0; + content: ""; +} + +.navbar-form:after { + clear: both; +} + +.navbar-form input, +.navbar-form select, +.navbar-form .radio, +.navbar-form .checkbox { + margin-top: 5px; +} + +.navbar-form input, +.navbar-form select, +.navbar-form .btn { + display: inline-block; + margin-bottom: 0; +} + +.navbar-form input[type="image"], +.navbar-form input[type="checkbox"], +.navbar-form input[type="radio"] { + margin-top: 3px; +} + +.navbar-form .input-append, +.navbar-form .input-prepend { + margin-top: 5px; + white-space: nowrap; +} + +.navbar-form .input-append input, +.navbar-form .input-prepend input { + margin-top: 0; +} + +.navbar-search { + position: relative; + float: left; + margin-top: 5px; + margin-bottom: 0; +} + +.navbar-search .search-query { + padding: 4px 14px; + margin-bottom: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 13px; + font-weight: normal; + line-height: 1; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +.navbar-static-top { + position: static; + margin-bottom: 0; +} + +.navbar-static-top .navbar-inner { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.navbar-fixed-top, +.navbar-fixed-bottom { + position: fixed; + right: 0; + left: 0; + z-index: 1030; + margin-bottom: 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-static-top .navbar-inner { + border-width: 0 0 1px; +} + +.navbar-fixed-bottom .navbar-inner { + border-width: 1px 0 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-fixed-bottom .navbar-inner { + padding-right: 0; + padding-left: 0; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; +} + +.navbar-static-top .container, +.navbar-fixed-top .container, +.navbar-fixed-bottom .container { + width: 940px; +} + +.navbar-fixed-top { + top: 0; +} + +.navbar-fixed-top .navbar-inner, +.navbar-static-top .navbar-inner { + -webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1); +} + +.navbar-fixed-bottom { + bottom: 0; +} + +.navbar-fixed-bottom .navbar-inner { + -webkit-box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); + box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.1); +} + +.navbar .nav { + position: relative; + left: 0; + display: block; + float: left; + margin: 0 10px 0 0; +} + +.navbar .nav.pull-right { + float: right; + margin-right: 0; +} + +.navbar .nav > li { + float: left; +} + +.navbar .nav > li > a { + float: none; + padding: 10px 15px 10px; + color: #777777; + text-decoration: none; + text-shadow: 0 1px 0 #ffffff; +} + +.navbar .nav .dropdown-toggle .caret { + margin-top: 8px; +} + +.navbar .nav > li > a:focus, +.navbar .nav > li > a:hover { + color: #333333; + text-decoration: none; + background-color: transparent; +} + +.navbar .nav > .active > a, +.navbar .nav > .active > a:hover, +.navbar .nav > .active > a:focus { + color: #555555; + text-decoration: none; + background-color: #e5e5e5; + -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); + -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); + box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); +} + +.navbar .btn-navbar { + display: none; + float: right; + padding: 7px 10px; + margin-right: 5px; + margin-left: 5px; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #ededed; + *background-color: #e5e5e5; + background-image: -moz-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#e5e5e5)); + background-image: -webkit-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: -o-linear-gradient(top, #f2f2f2, #e5e5e5); + background-image: linear-gradient(to bottom, #f2f2f2, #e5e5e5); + background-repeat: repeat-x; + border-color: #e5e5e5 #e5e5e5 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffe5e5e5', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); +} + +.navbar .btn-navbar:hover, +.navbar .btn-navbar:focus, +.navbar .btn-navbar:active, +.navbar .btn-navbar.active, +.navbar .btn-navbar.disabled, +.navbar .btn-navbar[disabled] { + color: #ffffff; + background-color: #e5e5e5; + *background-color: #d9d9d9; +} + +.navbar .btn-navbar:active, +.navbar .btn-navbar.active { + background-color: #cccccc \9; +} + +.navbar .btn-navbar .icon-bar { + display: block; + width: 18px; + height: 2px; + background-color: #f5f5f5; + -webkit-border-radius: 1px; + -moz-border-radius: 1px; + border-radius: 1px; + -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); + -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-navbar .icon-bar + .icon-bar { + margin-top: 3px; +} + +.navbar .nav > li > .dropdown-menu:before { + position: absolute; + top: -7px; + left: 9px; + display: inline-block; + border-right: 7px solid transparent; + border-bottom: 7px solid #ccc; + border-left: 7px solid transparent; + border-bottom-color: rgba(0, 0, 0, 0.2); + content: ''; +} + +.navbar .nav > li > .dropdown-menu:after { + position: absolute; + top: -6px; + left: 10px; + display: inline-block; + border-right: 6px solid transparent; + border-bottom: 6px solid #ffffff; + border-left: 6px solid transparent; + content: ''; +} + +.navbar-fixed-bottom .nav > li > .dropdown-menu:before { + top: auto; + bottom: -7px; + border-top: 7px solid #ccc; + border-bottom: 0; + border-top-color: rgba(0, 0, 0, 0.2); +} + +.navbar-fixed-bottom .nav > li > .dropdown-menu:after { + top: auto; + bottom: -6px; + border-top: 6px solid #ffffff; + border-bottom: 0; +} + +.navbar .nav li.dropdown > a:hover .caret, +.navbar .nav li.dropdown > a:focus .caret { + border-top-color: #333333; + border-bottom-color: #333333; +} + +.navbar .nav li.dropdown.open > .dropdown-toggle, +.navbar .nav li.dropdown.active > .dropdown-toggle, +.navbar .nav li.dropdown.open.active > .dropdown-toggle { + color: #555555; + background-color: #e5e5e5; +} + +.navbar .nav li.dropdown > .dropdown-toggle .caret { + border-top-color: #777777; + border-bottom-color: #777777; +} + +.navbar .nav li.dropdown.open > .dropdown-toggle .caret, +.navbar .nav li.dropdown.active > .dropdown-toggle .caret, +.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret { + border-top-color: #555555; + border-bottom-color: #555555; +} + +.navbar .pull-right > li > .dropdown-menu, +.navbar .nav > li > .dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu:before, +.navbar .nav > li > .dropdown-menu.pull-right:before { + right: 12px; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu:after, +.navbar .nav > li > .dropdown-menu.pull-right:after { + right: 13px; + left: auto; +} + +.navbar .pull-right > li > .dropdown-menu .dropdown-menu, +.navbar .nav > li > .dropdown-menu.pull-right .dropdown-menu { + right: 100%; + left: auto; + margin-right: -1px; + margin-left: 0; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; +} + +.navbar-inverse .navbar-inner { + background-color: #1b1b1b; + background-image: -moz-linear-gradient(top, #222222, #111111); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#222222), to(#111111)); + background-image: -webkit-linear-gradient(top, #222222, #111111); + background-image: -o-linear-gradient(top, #222222, #111111); + background-image: linear-gradient(to bottom, #222222, #111111); + background-repeat: repeat-x; + border-color: #252525; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff222222', endColorstr='#ff111111', GradientType=0); +} + +.navbar-inverse .brand, +.navbar-inverse .nav > li > a { + color: #999999; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.navbar-inverse .brand:hover, +.navbar-inverse .nav > li > a:hover, +.navbar-inverse .brand:focus, +.navbar-inverse .nav > li > a:focus { + color: #ffffff; +} + +.navbar-inverse .brand { + color: #999999; +} + +.navbar-inverse .navbar-text { + color: #999999; +} + +.navbar-inverse .nav > li > a:focus, +.navbar-inverse .nav > li > a:hover { + color: #ffffff; + background-color: transparent; +} + +.navbar-inverse .nav .active > a, +.navbar-inverse .nav .active > a:hover, +.navbar-inverse .nav .active > a:focus { + color: #ffffff; + background-color: #111111; +} + +.navbar-inverse .navbar-link { + color: #999999; +} + +.navbar-inverse .navbar-link:hover, +.navbar-inverse .navbar-link:focus { + color: #ffffff; +} + +.navbar-inverse .divider-vertical { + border-right-color: #222222; + border-left-color: #111111; +} + +.navbar-inverse .nav li.dropdown.open > .dropdown-toggle, +.navbar-inverse .nav li.dropdown.active > .dropdown-toggle, +.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle { + color: #ffffff; + background-color: #111111; +} + +.navbar-inverse .nav li.dropdown > a:hover .caret, +.navbar-inverse .nav li.dropdown > a:focus .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.navbar-inverse .nav li.dropdown > .dropdown-toggle .caret { + border-top-color: #999999; + border-bottom-color: #999999; +} + +.navbar-inverse .nav li.dropdown.open > .dropdown-toggle .caret, +.navbar-inverse .nav li.dropdown.active > .dropdown-toggle .caret, +.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle .caret { + border-top-color: #ffffff; + border-bottom-color: #ffffff; +} + +.navbar-inverse .navbar-search .search-query { + color: #ffffff; + background-color: #515151; + border-color: #111111; + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15); + -webkit-transition: none; + -moz-transition: none; + -o-transition: none; + transition: none; +} + +.navbar-inverse .navbar-search .search-query:-moz-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query:-ms-input-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder { + color: #cccccc; +} + +.navbar-inverse .navbar-search .search-query:focus, +.navbar-inverse .navbar-search .search-query.focused { + padding: 5px 15px; + color: #333333; + text-shadow: 0 1px 0 #ffffff; + background-color: #ffffff; + border: 0; + outline: 0; + -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); + -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); + box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); +} + +.navbar-inverse .btn-navbar { + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #0e0e0e; + *background-color: #040404; + background-image: -moz-linear-gradient(top, #151515, #040404); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#151515), to(#040404)); + background-image: -webkit-linear-gradient(top, #151515, #040404); + background-image: -o-linear-gradient(top, #151515, #040404); + background-image: linear-gradient(to bottom, #151515, #040404); + background-repeat: repeat-x; + border-color: #040404 #040404 #000000; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515', endColorstr='#ff040404', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.navbar-inverse .btn-navbar:hover, +.navbar-inverse .btn-navbar:focus, +.navbar-inverse .btn-navbar:active, +.navbar-inverse .btn-navbar.active, +.navbar-inverse .btn-navbar.disabled, +.navbar-inverse .btn-navbar[disabled] { + color: #ffffff; + background-color: #040404; + *background-color: #000000; +} + +.navbar-inverse .btn-navbar:active, +.navbar-inverse .btn-navbar.active { + background-color: #000000 \9; +} + +.breadcrumb { + padding: 8px 15px; + margin: 0 0 20px; + list-style: none; + background-color: #f5f5f5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.breadcrumb > li { + display: inline-block; + *display: inline; + text-shadow: 0 1px 0 #ffffff; + *zoom: 1; +} + +.breadcrumb > li > .divider { + padding: 0 5px; + color: #ccc; +} + +.breadcrumb > .active { + color: #999999; +} + +.pagination { + margin: 20px 0; +} + +.pagination ul { + display: inline-block; + *display: inline; + margin-bottom: 0; + margin-left: 0; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + *zoom: 1; + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.pagination ul > li { + display: inline; +} + +.pagination ul > li > a, +.pagination ul > li > span { + float: left; + padding: 4px 12px; + line-height: 20px; + text-decoration: none; + background-color: #ffffff; + border: 1px solid #dddddd; + border-left-width: 0; +} + +.pagination ul > li > a:hover, +.pagination ul > li > a:focus, +.pagination ul > .active > a, +.pagination ul > .active > span { + background-color: #f5f5f5; +} + +.pagination ul > .active > a, +.pagination ul > .active > span { + color: #999999; + cursor: default; +} + +.pagination ul > .disabled > span, +.pagination ul > .disabled > a, +.pagination ul > .disabled > a:hover, +.pagination ul > .disabled > a:focus { + color: #999999; + cursor: default; + background-color: transparent; +} + +.pagination ul > li:first-child > a, +.pagination ul > li:first-child > span { + border-left-width: 1px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-topleft: 4px; +} + +.pagination ul > li:last-child > a, +.pagination ul > li:last-child > span { + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-bottomright: 4px; +} + +.pagination-centered { + text-align: center; +} + +.pagination-right { + text-align: right; +} + +.pagination-large ul > li > a, +.pagination-large ul > li > span { + padding: 11px 19px; + font-size: 17.5px; +} + +.pagination-large ul > li:first-child > a, +.pagination-large ul > li:first-child > span { + -webkit-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -webkit-border-top-left-radius: 6px; + border-top-left-radius: 6px; + -moz-border-radius-bottomleft: 6px; + -moz-border-radius-topleft: 6px; +} + +.pagination-large ul > li:last-child > a, +.pagination-large ul > li:last-child > span { + -webkit-border-top-right-radius: 6px; + border-top-right-radius: 6px; + -webkit-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + -moz-border-radius-topright: 6px; + -moz-border-radius-bottomright: 6px; +} + +.pagination-mini ul > li:first-child > a, +.pagination-small ul > li:first-child > a, +.pagination-mini ul > li:first-child > span, +.pagination-small ul > li:first-child > span { + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -moz-border-radius-topleft: 3px; +} + +.pagination-mini ul > li:last-child > a, +.pagination-small ul > li:last-child > a, +.pagination-mini ul > li:last-child > span, +.pagination-small ul > li:last-child > span { + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; + -webkit-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; + -moz-border-radius-topright: 3px; + -moz-border-radius-bottomright: 3px; +} + +.pagination-small ul > li > a, +.pagination-small ul > li > span { + padding: 2px 10px; + font-size: 11.9px; +} + +.pagination-mini ul > li > a, +.pagination-mini ul > li > span { + padding: 0 6px; + font-size: 10.5px; +} + +.pager { + margin: 20px 0; + text-align: center; + list-style: none; + *zoom: 1; +} + +.pager:before, +.pager:after { + display: table; + line-height: 0; + content: ""; +} + +.pager:after { + clear: both; +} + +.pager li { + display: inline; +} + +.pager li > a, +.pager li > span { + display: inline-block; + padding: 5px 14px; + background-color: #fff; + border: 1px solid #ddd; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; +} + +.pager li > a:hover, +.pager li > a:focus { + text-decoration: none; + background-color: #f5f5f5; +} + +.pager .next > a, +.pager .next > span { + float: right; +} + +.pager .previous > a, +.pager .previous > span { + float: left; +} + +.pager .disabled > a, +.pager .disabled > a:hover, +.pager .disabled > a:focus, +.pager .disabled > span { + color: #999999; + cursor: default; + background-color: #fff; +} + +.modal-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1040; + background-color: #000000; +} + +.modal-backdrop.fade { + opacity: 0; +} + +.modal-backdrop, +.modal-backdrop.fade.in { + opacity: 0.8; + filter: alpha(opacity=80); +} + +.modal { + position: fixed; + top: 10%; + left: 50%; + z-index: 1050; + width: 560px; + margin-left: -280px; + background-color: #ffffff; + border: 1px solid #999; + border: 1px solid rgba(0, 0, 0, 0.3); + *border: 1px solid #999; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + outline: none; + -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); + -webkit-background-clip: padding-box; + -moz-background-clip: padding-box; + background-clip: padding-box; +} + +.modal.fade { + top: -25%; + -webkit-transition: opacity 0.3s linear, top 0.3s ease-out; + -moz-transition: opacity 0.3s linear, top 0.3s ease-out; + -o-transition: opacity 0.3s linear, top 0.3s ease-out; + transition: opacity 0.3s linear, top 0.3s ease-out; +} + +.modal.fade.in { + top: 10%; +} + +.modal-header { + padding: 9px 15px; + border-bottom: 1px solid #eee; +} + +.modal-header .close { + margin-top: 2px; +} + +.modal-header h3 { + margin: 0; + line-height: 30px; +} + +.modal-body { + position: relative; + max-height: 400px; + padding: 15px; + overflow-y: auto; +} + +.modal-form { + margin-bottom: 0; +} + +.modal-footer { + padding: 14px 15px 15px; + margin-bottom: 0; + text-align: right; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + -webkit-border-radius: 0 0 6px 6px; + -moz-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; + *zoom: 1; + -webkit-box-shadow: inset 0 1px 0 #ffffff; + -moz-box-shadow: inset 0 1px 0 #ffffff; + box-shadow: inset 0 1px 0 #ffffff; +} + +.modal-footer:before, +.modal-footer:after { + display: table; + line-height: 0; + content: ""; +} + +.modal-footer:after { + clear: both; +} + +.modal-footer .btn + .btn { + margin-bottom: 0; + margin-left: 5px; +} + +.modal-footer .btn-group .btn + .btn { + margin-left: -1px; +} + +.modal-footer .btn-block + .btn-block { + margin-left: 0; +} + +.tooltip { + position: absolute; + z-index: 1030; + display: block; + font-size: 11px; + line-height: 1.4; + opacity: 0; + filter: alpha(opacity=0); + visibility: visible; +} + +.tooltip.in { + opacity: 0.8; + filter: alpha(opacity=80); +} + +.tooltip.top { + padding: 5px 0; + margin-top: -3px; +} + +.tooltip.right { + padding: 0 5px; + margin-left: 3px; +} + +.tooltip.bottom { + padding: 5px 0; + margin-top: 3px; +} + +.tooltip.left { + padding: 0 5px; + margin-left: -3px; +} + +.tooltip-inner { + max-width: 200px; + padding: 8px; + color: #ffffff; + text-align: center; + text-decoration: none; + background-color: #000000; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.tooltip-arrow { + position: absolute; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} + +.tooltip.top .tooltip-arrow { + bottom: 0; + left: 50%; + margin-left: -5px; + border-top-color: #000000; + border-width: 5px 5px 0; +} + +.tooltip.right .tooltip-arrow { + top: 50%; + left: 0; + margin-top: -5px; + border-right-color: #000000; + border-width: 5px 5px 5px 0; +} + +.tooltip.left .tooltip-arrow { + top: 50%; + right: 0; + margin-top: -5px; + border-left-color: #000000; + border-width: 5px 0 5px 5px; +} + +.tooltip.bottom .tooltip-arrow { + top: 0; + left: 50%; + margin-left: -5px; + border-bottom-color: #000000; + border-width: 0 5px 5px; +} + +.popover { + position: absolute; + top: 0; + left: 0; + z-index: 1010; + display: none; + max-width: 276px; + padding: 1px; + text-align: left; + white-space: normal; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.popover.top { + margin-top: -10px; +} + +.popover.right { + margin-left: 10px; +} + +.popover.bottom { + margin-top: 10px; +} + +.popover.left { + margin-left: -10px; +} + +.popover-title { + padding: 8px 14px; + margin: 0; + font-size: 14px; + font-weight: normal; + line-height: 18px; + background-color: #f7f7f7; + border-bottom: 1px solid #ebebeb; + -webkit-border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + border-radius: 5px 5px 0 0; +} + +.popover-title:empty { + display: none; +} + +.popover-content { + padding: 9px 14px; +} + +.popover .arrow, +.popover .arrow:after { + position: absolute; + display: block; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} + +.popover .arrow { + border-width: 11px; +} + +.popover .arrow:after { + border-width: 10px; + content: ""; +} + +.popover.top .arrow { + bottom: -11px; + left: 50%; + margin-left: -11px; + border-top-color: #999; + border-top-color: rgba(0, 0, 0, 0.25); + border-bottom-width: 0; +} + +.popover.top .arrow:after { + bottom: 1px; + margin-left: -10px; + border-top-color: #ffffff; + border-bottom-width: 0; +} + +.popover.right .arrow { + top: 50%; + left: -11px; + margin-top: -11px; + border-right-color: #999; + border-right-color: rgba(0, 0, 0, 0.25); + border-left-width: 0; +} + +.popover.right .arrow:after { + bottom: -10px; + left: 1px; + border-right-color: #ffffff; + border-left-width: 0; +} + +.popover.bottom .arrow { + top: -11px; + left: 50%; + margin-left: -11px; + border-bottom-color: #999; + border-bottom-color: rgba(0, 0, 0, 0.25); + border-top-width: 0; +} + +.popover.bottom .arrow:after { + top: 1px; + margin-left: -10px; + border-bottom-color: #ffffff; + border-top-width: 0; +} + +.popover.left .arrow { + top: 50%; + right: -11px; + margin-top: -11px; + border-left-color: #999; + border-left-color: rgba(0, 0, 0, 0.25); + border-right-width: 0; +} + +.popover.left .arrow:after { + right: 1px; + bottom: -10px; + border-left-color: #ffffff; + border-right-width: 0; +} + +.thumbnails { + margin-left: -20px; + list-style: none; + *zoom: 1; +} + +.thumbnails:before, +.thumbnails:after { + display: table; + line-height: 0; + content: ""; +} + +.thumbnails:after { + clear: both; +} + +.row-fluid .thumbnails { + margin-left: 0; +} + +.thumbnails > li { + float: left; + margin-bottom: 20px; + margin-left: 20px; +} + +.thumbnail { + display: block; + padding: 4px; + line-height: 20px; + border: 1px solid #ddd; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); + -webkit-transition: all 0.2s ease-in-out; + -moz-transition: all 0.2s ease-in-out; + -o-transition: all 0.2s ease-in-out; + transition: all 0.2s ease-in-out; +} + +a.thumbnail:hover, +a.thumbnail:focus { + border-color: #0088cc; + -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); + -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); + box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); +} + +.thumbnail > img { + display: block; + max-width: 100%; + margin-right: auto; + margin-left: auto; +} + +.thumbnail .caption { + padding: 9px; + color: #555555; +} + +.media, +.media-body { + overflow: hidden; + *overflow: visible; + zoom: 1; +} + +.media, +.media .media { + margin-top: 15px; +} + +.media:first-child { + margin-top: 0; +} + +.media-object { + display: block; +} + +.media-heading { + margin: 0 0 5px; +} + +.media > .pull-left { + margin-right: 10px; +} + +.media > .pull-right { + margin-left: 10px; +} + +.media-list { + margin-left: 0; + list-style: none; +} + +.label, +.badge { + display: inline-block; + padding: 2px 4px; + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + white-space: nowrap; + vertical-align: baseline; + background-color: #999999; +} + +.label { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +.badge { + padding-right: 9px; + padding-left: 9px; + -webkit-border-radius: 9px; + -moz-border-radius: 9px; + border-radius: 9px; +} + +.label:empty, +.badge:empty { + display: none; +} + +a.label:hover, +a.label:focus, +a.badge:hover, +a.badge:focus { + color: #ffffff; + text-decoration: none; + cursor: pointer; +} + +.label-important, +.badge-important { + background-color: #b94a48; +} + +.label-important[href], +.badge-important[href] { + background-color: #953b39; +} + +.label-warning, +.badge-warning { + background-color: #f89406; +} + +.label-warning[href], +.badge-warning[href] { + background-color: #c67605; +} + +.label-success, +.badge-success { + background-color: #468847; +} + +.label-success[href], +.badge-success[href] { + background-color: #356635; +} + +.label-info, +.badge-info { + background-color: #3a87ad; +} + +.label-info[href], +.badge-info[href] { + background-color: #2d6987; +} + +.label-inverse, +.badge-inverse { + background-color: #333333; +} + +.label-inverse[href], +.badge-inverse[href] { + background-color: #1a1a1a; +} + +.btn .label, +.btn .badge { + position: relative; + top: -1px; +} + +.btn-mini .label, +.btn-mini .badge { + top: 0; +} + +@-webkit-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-moz-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-ms-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-o-keyframes progress-bar-stripes { + from { + background-position: 0 0; + } + to { + background-position: 40px 0; + } +} + +@keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +.progress { + height: 20px; + margin-bottom: 20px; + overflow: hidden; + background-color: #f7f7f7; + background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9)); + background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9); + background-repeat: repeat-x; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0); + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); +} + +.progress .bar { + float: left; + width: 0; + height: 100%; + font-size: 12px; + color: #ffffff; + text-align: center; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #0e90d2; + background-image: -moz-linear-gradient(top, #149bdf, #0480be); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be)); + background-image: -webkit-linear-gradient(top, #149bdf, #0480be); + background-image: -o-linear-gradient(top, #149bdf, #0480be); + background-image: linear-gradient(to bottom, #149bdf, #0480be); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0); + -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-transition: width 0.6s ease; + -moz-transition: width 0.6s ease; + -o-transition: width 0.6s ease; + transition: width 0.6s ease; +} + +.progress .bar + .bar { + -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); +} + +.progress-striped .bar { + background-color: #149bdf; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + -webkit-background-size: 40px 40px; + -moz-background-size: 40px 40px; + -o-background-size: 40px 40px; + background-size: 40px 40px; +} + +.progress.active .bar { + -webkit-animation: progress-bar-stripes 2s linear infinite; + -moz-animation: progress-bar-stripes 2s linear infinite; + -ms-animation: progress-bar-stripes 2s linear infinite; + -o-animation: progress-bar-stripes 2s linear infinite; + animation: progress-bar-stripes 2s linear infinite; +} + +.progress-danger .bar, +.progress .bar-danger { + background-color: #dd514c; + background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35)); + background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -o-linear-gradient(top, #ee5f5b, #c43c35); + background-image: linear-gradient(to bottom, #ee5f5b, #c43c35); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0); +} + +.progress-danger.progress-striped .bar, +.progress-striped .bar-danger { + background-color: #ee5f5b; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-success .bar, +.progress .bar-success { + background-color: #5eb95e; + background-image: -moz-linear-gradient(top, #62c462, #57a957); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957)); + background-image: -webkit-linear-gradient(top, #62c462, #57a957); + background-image: -o-linear-gradient(top, #62c462, #57a957); + background-image: linear-gradient(to bottom, #62c462, #57a957); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0); +} + +.progress-success.progress-striped .bar, +.progress-striped .bar-success { + background-color: #62c462; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-info .bar, +.progress .bar-info { + background-color: #4bb1cf; + background-image: -moz-linear-gradient(top, #5bc0de, #339bb9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9)); + background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9); + background-image: -o-linear-gradient(top, #5bc0de, #339bb9); + background-image: linear-gradient(to bottom, #5bc0de, #339bb9); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0); +} + +.progress-info.progress-striped .bar, +.progress-striped .bar-info { + background-color: #5bc0de; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-warning .bar, +.progress .bar-warning { + background-color: #faa732; + background-image: -moz-linear-gradient(top, #fbb450, #f89406); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); + background-image: -webkit-linear-gradient(top, #fbb450, #f89406); + background-image: -o-linear-gradient(top, #fbb450, #f89406); + background-image: linear-gradient(to bottom, #fbb450, #f89406); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0); +} + +.progress-warning.progress-striped .bar, +.progress-striped .bar-warning { + background-color: #fbb450; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.accordion { + margin-bottom: 20px; +} + +.accordion-group { + margin-bottom: 2px; + border: 1px solid #e5e5e5; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.accordion-heading { + border-bottom: 0; +} + +.accordion-heading .accordion-toggle { + display: block; + padding: 8px 15px; +} + +.accordion-toggle { + cursor: pointer; +} + +.accordion-inner { + padding: 9px 15px; + border-top: 1px solid #e5e5e5; +} + +.carousel { + position: relative; + margin-bottom: 20px; + line-height: 1; +} + +.carousel-inner { + position: relative; + width: 100%; + overflow: hidden; +} + +.carousel-inner > .item { + position: relative; + display: none; + -webkit-transition: 0.6s ease-in-out left; + -moz-transition: 0.6s ease-in-out left; + -o-transition: 0.6s ease-in-out left; + transition: 0.6s ease-in-out left; +} + +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + line-height: 1; +} + +.carousel-inner > .active, +.carousel-inner > .next, +.carousel-inner > .prev { + display: block; +} + +.carousel-inner > .active { + left: 0; +} + +.carousel-inner > .next, +.carousel-inner > .prev { + position: absolute; + top: 0; + width: 100%; +} + +.carousel-inner > .next { + left: 100%; +} + +.carousel-inner > .prev { + left: -100%; +} + +.carousel-inner > .next.left, +.carousel-inner > .prev.right { + left: 0; +} + +.carousel-inner > .active.left { + left: -100%; +} + +.carousel-inner > .active.right { + left: 100%; +} + +.carousel-control { + position: absolute; + top: 40%; + left: 15px; + width: 40px; + height: 40px; + margin-top: -20px; + font-size: 60px; + font-weight: 100; + line-height: 30px; + color: #ffffff; + text-align: center; + background: #222222; + border: 3px solid #ffffff; + -webkit-border-radius: 23px; + -moz-border-radius: 23px; + border-radius: 23px; + opacity: 0.5; + filter: alpha(opacity=50); +} + +.carousel-control.right { + right: 15px; + left: auto; +} + +.carousel-control:hover, +.carousel-control:focus { + color: #ffffff; + text-decoration: none; + opacity: 0.9; + filter: alpha(opacity=90); +} + +.carousel-indicators { + position: absolute; + top: 15px; + right: 15px; + z-index: 5; + margin: 0; + list-style: none; +} + +.carousel-indicators li { + display: block; + float: left; + width: 10px; + height: 10px; + margin-left: 5px; + text-indent: -999px; + background-color: #ccc; + background-color: rgba(255, 255, 255, 0.25); + border-radius: 5px; +} + +.carousel-indicators .active { + background-color: #fff; +} + +.carousel-caption { + position: absolute; + right: 0; + bottom: 0; + left: 0; + padding: 15px; + background: #333333; + background: rgba(0, 0, 0, 0.75); +} + +.carousel-caption h4, +.carousel-caption p { + line-height: 20px; + color: #ffffff; +} + +.carousel-caption h4 { + margin: 0 0 5px; +} + +.carousel-caption p { + margin-bottom: 0; +} + +.hero-unit { + padding: 60px; + margin-bottom: 30px; + font-size: 18px; + font-weight: 200; + line-height: 30px; + color: inherit; + background-color: #eeeeee; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.hero-unit h1 { + margin-bottom: 0; + font-size: 60px; + line-height: 1; + letter-spacing: -1px; + color: inherit; +} + +.hero-unit li { + line-height: 30px; +} + +.pull-right { + float: right; +} + +.pull-left { + float: left; +} + +.hide { + display: none; +} + +.show { + display: block; +} + +.invisible { + visibility: hidden; +} + +.affix { + position: fixed; +} diff --git a/handling-spring-static-resources/src/main/webapp/js/ember-data.js b/handling-spring-static-resources/src/main/webapp/js/ember-data.js new file mode 100644 index 000000000000..689e0d3cdaf0 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/ember-data.js @@ -0,0 +1,10548 @@ +/*! + * @overview Ember Data + * @copyright Copyright 2011-2014 Tilde Inc. and contributors. + * Portions Copyright 2011 LivingSocial Inc. + * @license Licensed under MIT license (see license.js) + * @version 1.0.0-beta.5 + */ + + +(function() { +var define, requireModule; + +(function() { + var registry = {}, seen = {}; + + define = function(name, deps, callback) { + registry[name] = { deps: deps, callback: callback }; + }; + + requireModule = function(name) { + if (seen[name]) { return seen[name]; } + seen[name] = {}; + + var mod, deps, callback, reified , exports; + + mod = registry[name]; + + if (!mod) { + throw new Error("Module '" + name + "' not found."); + } + + deps = mod.deps; + callback = mod.callback; + reified = []; + exports; + + for (var i=0, l=deps.length; i self.attributeLimit) { return false; } + var desc = capitalize(underscore(name).replace('_', ' ')); + columns.push({ name: name, desc: desc }); + }); + return columns; + }, + + getRecords: function(type) { + return this.get('store').all(type); + }, + + getRecordColumnValues: function(record) { + var self = this, count = 0, + columnValues = { id: get(record, 'id') }; + + record.eachAttribute(function(key) { + if (count++ > self.attributeLimit) { + return false; + } + var value = get(record, key); + columnValues[key] = value; + }); + return columnValues; + }, + + getRecordKeywords: function(record) { + var keywords = [], keys = Ember.A(['id']); + record.eachAttribute(function(key) { + keys.push(key); + }); + keys.forEach(function(key) { + keywords.push(get(record, key)); + }); + return keywords; + }, + + getRecordFilterValues: function(record) { + return { + isNew: record.get('isNew'), + isModified: record.get('isDirty') && !record.get('isNew'), + isClean: !record.get('isDirty') + }; + }, + + getRecordColor: function(record) { + var color = 'black'; + if (record.get('isNew')) { + color = 'green'; + } else if (record.get('isDirty')) { + color = 'blue'; + } + return color; + }, + + observeRecord: function(record, recordUpdated) { + var releaseMethods = Ember.A(), self = this, + keysToObserve = Ember.A(['id', 'isNew', 'isDirty']); + + record.eachAttribute(function(key) { + keysToObserve.push(key); + }); + + keysToObserve.forEach(function(key) { + var handler = function() { + recordUpdated(self.wrapRecord(record)); + }; + Ember.addObserver(record, key, handler); + releaseMethods.push(function() { + Ember.removeObserver(record, key, handler); + }); + }); + + var release = function() { + releaseMethods.forEach(function(fn) { fn(); } ); + }; + + return release; + } + +}); + +})(); + + + +(function() { +/** + The `DS.Transform` class is used to serialize and deserialize model + attributes when they are saved or loaded from an + adapter. Subclassing `DS.Transform` is useful for creating custom + attributes. All subclasses of `DS.Transform` must implement a + `serialize` and a `deserialize` method. + + Example + + ```javascript + App.RawTransform = DS.Transform.extend({ + deserialize: function(serialized) { + return serialized; + }, + serialize: function(deserialized) { + return deserialized; + } + }); + ``` + + Usage + + ```javascript + var attr = DS.attr; + App.Requirement = DS.Model.extend({ + name: attr('string'), + optionsArray: attr('raw') + }); + ``` + + @class Transform + @namespace DS + */ +DS.Transform = Ember.Object.extend({ + /** + When given a deserialized value from a record attribute this + method must return the serialized value. + + Example + + ```javascript + serialize: function(deserialized) { + return Ember.isEmpty(deserialized) ? null : Number(deserialized); + } + ``` + + @method serialize + @param deserialized The deserialized value + @return The serialized value + */ + serialize: Ember.required(), + + /** + When given a serialize value from a JSON object this method must + return the deserialized value for the record attribute. + + Example + + ```javascript + deserialize: function(serialized) { + return empty(serialized) ? null : Number(serialized); + } + ``` + + @method deserialize + @param serialized The serialized value + @return The deserialized value + */ + deserialize: Ember.required() + +}); + +})(); + + + +(function() { + +/** + The `DS.BooleanTransform` class is used to serialize and deserialize + boolean attributes on Ember Data record objects. This transform is + used when `boolean` is passed as the type parameter to the + [DS.attr](../../data#method_attr) function. + + Usage + + ```javascript + var attr = DS.attr; + App.User = DS.Model.extend({ + isAdmin: attr('boolean'), + name: attr('string'), + email: attr('string') + }); + ``` + + @class BooleanTransform + @extends DS.Transform + @namespace DS + */ +DS.BooleanTransform = DS.Transform.extend({ + deserialize: function(serialized) { + var type = typeof serialized; + + if (type === "boolean") { + return serialized; + } else if (type === "string") { + return serialized.match(/^true$|^t$|^1$/i) !== null; + } else if (type === "number") { + return serialized === 1; + } else { + return false; + } + }, + + serialize: function(deserialized) { + return Boolean(deserialized); + } +}); + +})(); + + + +(function() { +/** + The `DS.DateTransform` class is used to serialize and deserialize + date attributes on Ember Data record objects. This transform is used + when `date` is passed as the type parameter to the + [DS.attr](../../data#method_attr) function. + + ```javascript + var attr = DS.attr; + App.Score = DS.Model.extend({ + value: attr('number'), + player: DS.belongsTo('player'), + date: attr('date') + }); + ``` + + @class DateTransform + @extends DS.Transform + @namespace DS + */ +DS.DateTransform = DS.Transform.extend({ + + deserialize: function(serialized) { + var type = typeof serialized; + + if (type === "string") { + return new Date(Ember.Date.parse(serialized)); + } else if (type === "number") { + return new Date(serialized); + } else if (serialized === null || serialized === undefined) { + // if the value is not present in the data, + // return undefined, not null. + return serialized; + } else { + return null; + } + }, + + serialize: function(date) { + if (date instanceof Date) { + var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + var pad = function(num) { + return num < 10 ? "0"+num : ""+num; + }; + + var utcYear = date.getUTCFullYear(), + utcMonth = date.getUTCMonth(), + utcDayOfMonth = date.getUTCDate(), + utcDay = date.getUTCDay(), + utcHours = date.getUTCHours(), + utcMinutes = date.getUTCMinutes(), + utcSeconds = date.getUTCSeconds(); + + + var dayOfWeek = days[utcDay]; + var dayOfMonth = pad(utcDayOfMonth); + var month = months[utcMonth]; + + return dayOfWeek + ", " + dayOfMonth + " " + month + " " + utcYear + " " + + pad(utcHours) + ":" + pad(utcMinutes) + ":" + pad(utcSeconds) + " GMT"; + } else { + return null; + } + } + +}); + +})(); + + + +(function() { +var empty = Ember.isEmpty; +/** + The `DS.NumberTransform` class is used to serialize and deserialize + numeric attributes on Ember Data record objects. This transform is + used when `number` is passed as the type parameter to the + [DS.attr](../../data#method_attr) function. + + Usage + + ```javascript + var attr = DS.attr; + App.Score = DS.Model.extend({ + value: attr('number'), + player: DS.belongsTo('player'), + date: attr('date') + }); + ``` + + @class NumberTransform + @extends DS.Transform + @namespace DS + */ +DS.NumberTransform = DS.Transform.extend({ + + deserialize: function(serialized) { + return empty(serialized) ? null : Number(serialized); + }, + + serialize: function(deserialized) { + return empty(deserialized) ? null : Number(deserialized); + } +}); + +})(); + + + +(function() { +var none = Ember.isNone; + +/** + The `DS.StringTransform` class is used to serialize and deserialize + string attributes on Ember Data record objects. This transform is + used when `string` is passed as the type parameter to the + [DS.attr](../../data#method_attr) function. + + Usage + + ```javascript + var attr = DS.attr; + App.User = DS.Model.extend({ + isAdmin: attr('boolean'), + name: attr('string'), + email: attr('string') + }); + ``` + + @class StringTransform + @extends DS.Transform + @namespace DS + */ +DS.StringTransform = DS.Transform.extend({ + + deserialize: function(serialized) { + return none(serialized) ? null : String(serialized); + }, + + serialize: function(deserialized) { + return none(deserialized) ? null : String(deserialized); + } + +}); + +})(); + + + +(function() { + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var set = Ember.set; + +/* + This code registers an injection for Ember.Application. + + If an Ember.js developer defines a subclass of DS.Store on their application, + this code will automatically instantiate it and make it available on the + router. + + Additionally, after an application's controllers have been injected, they will + each have the store made available to them. + + For example, imagine an Ember.js application with the following classes: + + App.Store = DS.Store.extend({ + adapter: 'custom' + }); + + App.PostsController = Ember.ArrayController.extend({ + // ... + }); + + When the application is initialized, `App.Store` will automatically be + instantiated, and the instance of `App.PostsController` will have its `store` + property set to that instance. + + Note that this code will only be run if the `ember-application` package is + loaded. If Ember Data is being used in an environment other than a + typical application (e.g., node.js where only `ember-runtime` is available), + this code will be ignored. +*/ + +Ember.onLoad('Ember.Application', function(Application) { + Application.initializer({ + name: "store", + + initialize: function(container, application) { + application.register('store:main', application.Store || DS.Store); + application.register('serializer:_default', DS.JSONSerializer); + application.register('serializer:_rest', DS.RESTSerializer); + application.register('adapter:_rest', DS.RESTAdapter); + + // Eagerly generate the store so defaultStore is populated. + // TODO: Do this in a finisher hook + container.lookup('store:main'); + } + }); + + Application.initializer({ + name: "transforms", + before: "store", + + initialize: function(container, application) { + application.register('transform:boolean', DS.BooleanTransform); + application.register('transform:date', DS.DateTransform); + application.register('transform:number', DS.NumberTransform); + application.register('transform:string', DS.StringTransform); + } + }); + + Application.initializer({ + name: "dataAdapter", + before: "store", + + initialize: function(container, application) { + application.register('dataAdapter:main', DS.DebugAdapter); + } + }); + + Application.initializer({ + name: "injectStore", + before: "store", + + initialize: function(container, application) { + application.inject('controller', 'store', 'store:main'); + application.inject('route', 'store', 'store:main'); + application.inject('serializer', 'store', 'store:main'); + application.inject('dataAdapter', 'store', 'store:main'); + } + }); + +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +/** + Date.parse with progressive enhancement for ISO 8601 + + © 2011 Colin Snover + + Released under MIT license. + + @class Date + @namespace Ember + @static +*/ +Ember.Date = Ember.Date || {}; + +var origParse = Date.parse, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ]; + +/** + @method parse + @param date +*/ +Ember.Date.parse = function (date) { + var timestamp, struct, minutesOffset = 0; + + // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string + // before falling back to any implementation-specific date parsing, so that’s what we do, even if native + // implementations could be faster + // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm + if ((struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(date))) { + // avoid NaN timestamps caused by “undefined†values being passed to Date.UTC + for (var i = 0, k; (k = numericKeys[i]); ++i) { + struct[k] = +struct[k] || 0; + } + + // allow undefined days and months + struct[2] = (+struct[2] || 1) - 1; + struct[3] = +struct[3] || 1; + + if (struct[8] !== 'Z' && struct[9] !== undefined) { + minutesOffset = struct[10] * 60 + struct[11]; + + if (struct[9] === '+') { + minutesOffset = 0 - minutesOffset; + } + } + + timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]); + } + else { + timestamp = origParse ? origParse(date) : NaN; + } + + return timestamp; +}; + +if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Date) { + Date.parse = Ember.Date.parse; +} + +})(); + + + +(function() { + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set; + +/** + A record array is an array that contains records of a certain type. The record + array materializes records as needed when they are retrieved for the first + time. You should not create record arrays yourself. Instead, an instance of + `DS.RecordArray` or its subclasses will be returned by your application's store + in response to queries. + + @class RecordArray + @namespace DS + @extends Ember.ArrayProxy + @uses Ember.Evented +*/ + +DS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, { + /** + The model type contained by this record array. + + @property type + @type DS.Model + */ + type: null, + + /** + The array of client ids backing the record array. When a + record is requested from the record array, the record + for the client id at the same index is materialized, if + necessary, by the store. + + @property content + @private + @type Ember.Array + */ + content: null, + + /** + The flag to signal a `RecordArray` is currently loading data. + + Example + + ```javascript + var people = store.all(App.Person); + people.get('isLoaded'); // true + ``` + + @property isLoaded + @type Boolean + */ + isLoaded: false, + /** + The flag to signal a `RecordArray` is currently loading data. + + Example + + ```javascript + var people = store.all(App.Person); + people.get('isUpdating'); // false + people.update(); + people.get('isUpdating'); // true + ``` + + @property isUpdating + @type Boolean + */ + isUpdating: false, + + /** + The store that created this record array. + + @property store + @private + @type DS.Store + */ + store: null, + + /** + Retrieves an object from the content by index. + + @method objectAtContent + @private + @param {Number} index + @return {DS.Model} record + */ + objectAtContent: function(index) { + var content = get(this, 'content'); + + return content.objectAt(index); + }, + + /** + Used to get the latest version of all of the records in this array + from the adapter. + + Example + + ```javascript + var people = store.all(App.Person); + people.get('isUpdating'); // false + people.update(); + people.get('isUpdating'); // true + ``` + + @method update + */ + update: function() { + if (get(this, 'isUpdating')) { return; } + + var store = get(this, 'store'), + type = get(this, 'type'); + + store.fetchAll(type, this); + }, + + /** + Adds a record to the `RecordArray`. + + @method addRecord + @private + @param {DS.Model} record + */ + addRecord: function(record) { + get(this, 'content').addObject(record); + }, + + /** + Removes a record to the `RecordArray`. + + @method removeRecord + @private + @param {DS.Model} record + */ + removeRecord: function(record) { + get(this, 'content').removeObject(record); + }, + + /** + Saves all of the records in the `RecordArray`. + + Example + + ```javascript + var messages = store.all(App.Message); + messages.forEach(function(message) { + message.set('hasBeenSeen', true); + }); + messages.save(); + ``` + + @method save + @return {DS.PromiseArray} promise + */ + save: function() { + var promiseLabel = "DS: RecordArray#save " + get(this, 'type'); + var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function(array) { + return Ember.A(array); + }, null, "DS: RecordArray#save apply Ember.NativeArray"); + + return DS.PromiseArray.create({ promise: promise }); + } +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get; + +/** + Represents a list of records whose membership is determined by the + store. As records are created, loaded, or modified, the store + evaluates them to determine if they should be part of the record + array. + + @class FilteredRecordArray + @namespace DS + @extends DS.RecordArray +*/ +DS.FilteredRecordArray = DS.RecordArray.extend({ + /** + The filterFunction is a function used to test records from the store to + determine if they should be part of the record array. + + Example + + ```javascript + var allPeople = store.all('person'); + allPeople.mapBy('name'); // ["Tom Dale", "Yehuda Katz", "Trek Glowacki"] + + var people = store.filter('person', function(person) { + if (person.get('name').match(/Katz$/)) { return true; } + }); + people.mapBy('name'); // ["Yehuda Katz"] + + var notKatzFilter = function(person) { + return !person.get('name').match(/Katz$/); + }; + people.set('filterFunction', notKatzFilter); + people.mapBy('name'); // ["Tom Dale", "Trek Glowacki"] + ``` + + @method filterFunction + @param {DS.Model} record + @return {Boolean} `true` if the record should be in the array + */ + filterFunction: null, + isLoaded: true, + + replace: function() { + var type = get(this, 'type').toString(); + throw new Error("The result of a client-side filter (on " + type + ") is immutable."); + }, + + /** + @method updateFilter + @private + */ + updateFilter: Ember.observer(function() { + var manager = get(this, 'manager'); + manager.updateFilter(this, get(this, 'type'), get(this, 'filterFunction')); + }, 'filterFunction') +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set; + +/** + Represents an ordered list of records whose order and membership is + determined by the adapter. For example, a query sent to the adapter + may trigger a search on the server, whose results would be loaded + into an instance of the `AdapterPopulatedRecordArray`. + + @class AdapterPopulatedRecordArray + @namespace DS + @extends DS.RecordArray +*/ +DS.AdapterPopulatedRecordArray = DS.RecordArray.extend({ + query: null, + + replace: function() { + var type = get(this, 'type').toString(); + throw new Error("The result of a server query (on " + type + ") is immutable."); + }, + + /** + @method load + @private + @param {Array} data + */ + load: function(data) { + var store = get(this, 'store'), + type = get(this, 'type'), + records = store.pushMany(type, data), + meta = store.metadataFor(type); + + this.setProperties({ + content: Ember.A(records), + isLoaded: true, + meta: meta + }); + + // TODO: does triggering didLoad event should be the last action of the runLoop? + Ember.run.once(this, 'trigger', 'didLoad'); + } +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set; +var map = Ember.EnumerableUtils.map; + +/** + A `ManyArray` is a `RecordArray` that represents the contents of a has-many + relationship. + + The `ManyArray` is instantiated lazily the first time the relationship is + requested. + + ### Inverses + + Often, the relationships in Ember Data applications will have + an inverse. For example, imagine the following models are + defined: + + ```javascript + App.Post = DS.Model.extend({ + comments: DS.hasMany('comment') + }); + + App.Comment = DS.Model.extend({ + post: DS.belongsTo('post') + }); + ``` + + If you created a new instance of `App.Post` and added + a `App.Comment` record to its `comments` has-many + relationship, you would expect the comment's `post` + property to be set to the post that contained + the has-many. + + We call the record to which a relationship belongs the + relationship's _owner_. + + @class ManyArray + @namespace DS + @extends DS.RecordArray +*/ +DS.ManyArray = DS.RecordArray.extend({ + init: function() { + this._super.apply(this, arguments); + this._changesToSync = Ember.OrderedSet.create(); + }, + + /** + The property name of the relationship + + @property {String} name + @private + */ + name: null, + + /** + The record to which this relationship belongs. + + @property {DS.Model} owner + @private + */ + owner: null, + + /** + `true` if the relationship is polymorphic, `false` otherwise. + + @property {Boolean} isPolymorphic + @private + */ + isPolymorphic: false, + + // LOADING STATE + + isLoaded: false, + + /** + Used for async `hasMany` arrays + to keep track of when they will resolve. + + @property {Ember.RSVP.Promise} promise + @private + */ + promise: null, + + /** + @method loadingRecordsCount + @param {Number} count + @private + */ + loadingRecordsCount: function(count) { + this.loadingRecordsCount = count; + }, + + /** + @method loadedRecord + @private + */ + loadedRecord: function() { + this.loadingRecordsCount--; + if (this.loadingRecordsCount === 0) { + set(this, 'isLoaded', true); + this.trigger('didLoad'); + } + }, + + /** + @method fetch + @private + */ + fetch: function() { + var records = get(this, 'content'), + store = get(this, 'store'), + owner = get(this, 'owner'), + resolver = Ember.RSVP.defer("DS: ManyArray#fetch " + get(this, 'type')); + + var unloadedRecords = records.filterProperty('isEmpty', true); + store.fetchMany(unloadedRecords, owner, resolver); + }, + + // Overrides Ember.Array's replace method to implement + replaceContent: function(index, removed, added) { + // Map the array of record objects into an array of client ids. + added = map(added, function(record) { + Ember.assert("You cannot add '" + record.constructor.typeKey + "' records to this relationship (only '" + this.type.typeKey + "' allowed)", !this.type || record instanceof this.type); + return record; + }, this); + + this._super(index, removed, added); + }, + + arrangedContentDidChange: function() { + Ember.run.once(this, 'fetch'); + }, + + arrayContentWillChange: function(index, removed, added) { + var owner = get(this, 'owner'), + name = get(this, 'name'); + + if (!owner._suspendedRelationships) { + // This code is the first half of code that continues inside + // of arrayContentDidChange. It gets or creates a change from + // the child object, adds the current owner as the old + // parent if this is the first time the object was removed + // from a ManyArray, and sets `newParent` to null. + // + // Later, if the object is added to another ManyArray, + // the `arrayContentDidChange` will set `newParent` on + // the change. + for (var i=index; i "root.created.uncommitted" + ``` + + The hierarchy of valid states that ship with ember data looks like + this: + + ```text + * root + * deleted + * saved + * uncommitted + * inFlight + * empty + * loaded + * created + * uncommitted + * inFlight + * saved + * updated + * uncommitted + * inFlight + * loading + ``` + + The `DS.Model` states are themselves stateless. What we mean is + that, the hierarchical states that each of *those* points to is a + shared data structure. For performance reasons, instead of each + record getting its own copy of the hierarchy of states, each record + points to this global, immutable shared instance. How does a state + know which record it should be acting on? We pass the record + instance into the state's event handlers as the first argument. + + The record passed as the first parameter is where you should stash + state about the record if needed; you should never store data on the state + object itself. + + ### Events and Flags + + A state may implement zero or more events and flags. + + #### Events + + Events are named functions that are invoked when sent to a record. The + record will first look for a method with the given name on the + current state. If no method is found, it will search the current + state's parent, and then its grandparent, and so on until reaching + the top of the hierarchy. If the root is reached without an event + handler being found, an exception will be raised. This can be very + helpful when debugging new features. + + Here's an example implementation of a state with a `myEvent` event handler: + + ```javascript + aState: DS.State.create({ + myEvent: function(manager, param) { + console.log("Received myEvent with", param); + } + }) + ``` + + To trigger this event: + + ```javascript + record.send('myEvent', 'foo'); + //=> "Received myEvent with foo" + ``` + + Note that an optional parameter can be sent to a record's `send()` method, + which will be passed as the second parameter to the event handler. + + Events should transition to a different state if appropriate. This can be + done by calling the record's `transitionTo()` method with a path to the + desired state. The state manager will attempt to resolve the state path + relative to the current state. If no state is found at that path, it will + attempt to resolve it relative to the current state's parent, and then its + parent, and so on until the root is reached. For example, imagine a hierarchy + like this: + + * created + * uncommitted <-- currentState + * inFlight + * updated + * inFlight + + If we are currently in the `uncommitted` state, calling + `transitionTo('inFlight')` would transition to the `created.inFlight` state, + while calling `transitionTo('updated.inFlight')` would transition to + the `updated.inFlight` state. + + Remember that *only events* should ever cause a state transition. You should + never call `transitionTo()` from outside a state's event handler. If you are + tempted to do so, create a new event and send that to the state manager. + + #### Flags + + Flags are Boolean values that can be used to introspect a record's current + state in a more user-friendly way than examining its state path. For example, + instead of doing this: + + ```javascript + var statePath = record.get('stateManager.currentPath'); + if (statePath === 'created.inFlight') { + doSomething(); + } + ``` + + You can say: + + ```javascript + if (record.get('isNew') && record.get('isSaving')) { + doSomething(); + } + ``` + + If your state does not set a value for a given flag, the value will + be inherited from its parent (or the first place in the state hierarchy + where it is defined). + + The current set of flags are defined below. If you want to add a new flag, + in addition to the area below, you will also need to declare it in the + `DS.Model` class. + + + * [isEmpty](DS.Model.html#property_isEmpty) + * [isLoading](DS.Model.html#property_isLoading) + * [isLoaded](DS.Model.html#property_isLoaded) + * [isDirty](DS.Model.html#property_isDirty) + * [isSaving](DS.Model.html#property_isSaving) + * [isDeleted](DS.Model.html#property_isDeleted) + * [isNew](DS.Model.html#property_isNew) + * [isValid](DS.Model.html#property_isValid) + + @namespace DS + @class RootState +*/ + +var hasDefinedProperties = function(object) { + // Ignore internal property defined by simulated `Ember.create`. + var names = Ember.keys(object); + var i, l, name; + for (i = 0, l = names.length; i < l; i++ ) { + name = names[i]; + if (object.hasOwnProperty(name) && object[name]) { return true; } + } + + return false; +}; + +var didSetProperty = function(record, context) { + if (context.value === context.originalValue) { + delete record._attributes[context.name]; + record.send('propertyWasReset', context.name); + } else if (context.value !== context.oldValue) { + record.send('becomeDirty'); + } + + record.updateRecordArraysLater(); +}; + +// Implementation notes: +// +// Each state has a boolean value for all of the following flags: +// +// * isLoaded: The record has a populated `data` property. When a +// record is loaded via `store.find`, `isLoaded` is false +// until the adapter sets it. When a record is created locally, +// its `isLoaded` property is always true. +// * isDirty: The record has local changes that have not yet been +// saved by the adapter. This includes records that have been +// created (but not yet saved) or deleted. +// * isSaving: The record has been committed, but +// the adapter has not yet acknowledged that the changes have +// been persisted to the backend. +// * isDeleted: The record was marked for deletion. When `isDeleted` +// is true and `isDirty` is true, the record is deleted locally +// but the deletion was not yet persisted. When `isSaving` is +// true, the change is in-flight. When both `isDirty` and +// `isSaving` are false, the change has persisted. +// * isError: The adapter reported that it was unable to save +// local changes to the backend. This may also result in the +// record having its `isValid` property become false if the +// adapter reported that server-side validations failed. +// * isNew: The record was created on the client and the adapter +// did not yet report that it was successfully saved. +// * isValid: No client-side validations have failed and the +// adapter did not report any server-side validation failures. + +// The dirty state is a abstract state whose functionality is +// shared between the `created` and `updated` states. +// +// The deleted state shares the `isDirty` flag with the +// subclasses of `DirtyState`, but with a very different +// implementation. +// +// Dirty states have three child states: +// +// `uncommitted`: the store has not yet handed off the record +// to be saved. +// `inFlight`: the store has handed off the record to be saved, +// but the adapter has not yet acknowledged success. +// `invalid`: the record has invalid information and cannot be +// send to the adapter yet. +var DirtyState = { + initialState: 'uncommitted', + + // FLAGS + isDirty: true, + + // SUBSTATES + + // When a record first becomes dirty, it is `uncommitted`. + // This means that there are local pending changes, but they + // have not yet begun to be saved, and are not invalid. + uncommitted: { + // EVENTS + didSetProperty: didSetProperty, + + propertyWasReset: function(record, name) { + var stillDirty = false; + + for (var prop in record._attributes) { + stillDirty = true; + break; + } + + if (!stillDirty) { record.send('rolledBack'); } + }, + + pushedData: Ember.K, + + becomeDirty: Ember.K, + + willCommit: function(record) { + record.transitionTo('inFlight'); + }, + + reloadRecord: function(record, resolve) { + resolve(get(record, 'store').reloadRecord(record)); + }, + + rolledBack: function(record) { + record.transitionTo('loaded.saved'); + }, + + becameInvalid: function(record) { + record.transitionTo('invalid'); + }, + + rollback: function(record) { + record.rollback(); + } + }, + + // Once a record has been handed off to the adapter to be + // saved, it is in the 'in flight' state. Changes to the + // record cannot be made during this window. + inFlight: { + // FLAGS + isSaving: true, + + // EVENTS + didSetProperty: didSetProperty, + becomeDirty: Ember.K, + pushedData: Ember.K, + + // TODO: More robust semantics around save-while-in-flight + willCommit: Ember.K, + + didCommit: function(record) { + var dirtyType = get(this, 'dirtyType'); + + record.transitionTo('saved'); + record.send('invokeLifecycleCallbacks', dirtyType); + }, + + becameInvalid: function(record) { + record.transitionTo('invalid'); + record.send('invokeLifecycleCallbacks'); + }, + + becameError: function(record) { + record.transitionTo('uncommitted'); + record.triggerLater('becameError', record); + } + }, + + // A record is in the `invalid` state when its client-side + // invalidations have failed, or if the adapter has indicated + // the the record failed server-side invalidations. + invalid: { + // FLAGS + isValid: false, + + // EVENTS + deleteRecord: function(record) { + record.transitionTo('deleted.uncommitted'); + record.clearRelationships(); + }, + + didSetProperty: function(record, context) { + get(record, 'errors').remove(context.name); + + didSetProperty(record, context); + }, + + becomeDirty: Ember.K, + + rolledBack: function(record) { + get(record, 'errors').clear(); + }, + + becameValid: function(record) { + record.transitionTo('uncommitted'); + }, + + invokeLifecycleCallbacks: function(record) { + record.triggerLater('becameInvalid', record); + } + } +}; + +// The created and updated states are created outside the state +// chart so we can reopen their substates and add mixins as +// necessary. + +function deepClone(object) { + var clone = {}, value; + + for (var prop in object) { + value = object[prop]; + if (value && typeof value === 'object') { + clone[prop] = deepClone(value); + } else { + clone[prop] = value; + } + } + + return clone; +} + +function mixin(original, hash) { + for (var prop in hash) { + original[prop] = hash[prop]; + } + + return original; +} + +function dirtyState(options) { + var newState = deepClone(DirtyState); + return mixin(newState, options); +} + +var createdState = dirtyState({ + dirtyType: 'created', + + // FLAGS + isNew: true +}); + +createdState.uncommitted.rolledBack = function(record) { + record.transitionTo('deleted.saved'); +}; + +var updatedState = dirtyState({ + dirtyType: 'updated' +}); + +createdState.uncommitted.deleteRecord = function(record) { + record.clearRelationships(); + record.transitionTo('deleted.saved'); +}; + +createdState.uncommitted.rollback = function(record) { + DirtyState.uncommitted.rollback.apply(this, arguments); + record.transitionTo('deleted.saved'); +}; + +updatedState.uncommitted.deleteRecord = function(record) { + record.transitionTo('deleted.uncommitted'); + record.clearRelationships(); +}; + +var RootState = { + // FLAGS + isEmpty: false, + isLoading: false, + isLoaded: false, + isDirty: false, + isSaving: false, + isDeleted: false, + isNew: false, + isValid: true, + + // DEFAULT EVENTS + + // Trying to roll back if you're not in the dirty state + // doesn't change your state. For example, if you're in the + // in-flight state, rolling back the record doesn't move + // you out of the in-flight state. + rolledBack: Ember.K, + + propertyWasReset: Ember.K, + + // SUBSTATES + + // A record begins its lifecycle in the `empty` state. + // If its data will come from the adapter, it will + // transition into the `loading` state. Otherwise, if + // the record is being created on the client, it will + // transition into the `created` state. + empty: { + isEmpty: true, + + // EVENTS + loadingData: function(record, promise) { + record._loadingPromise = promise; + record.transitionTo('loading'); + }, + + loadedData: function(record) { + record.transitionTo('loaded.created.uncommitted'); + + record.suspendRelationshipObservers(function() { + record.notifyPropertyChange('data'); + }); + }, + + pushedData: function(record) { + record.transitionTo('loaded.saved'); + record.triggerLater('didLoad'); + } + }, + + // A record enters this state when the store askes + // the adapter for its data. It remains in this state + // until the adapter provides the requested data. + // + // Usually, this process is asynchronous, using an + // XHR to retrieve the data. + loading: { + // FLAGS + isLoading: true, + + exit: function(record) { + record._loadingPromise = null; + }, + + // EVENTS + pushedData: function(record) { + record.transitionTo('loaded.saved'); + record.triggerLater('didLoad'); + set(record, 'isError', false); + }, + + becameError: function(record) { + record.triggerLater('becameError', record); + }, + + notFound: function(record) { + record.transitionTo('empty'); + } + }, + + // A record enters this state when its data is populated. + // Most of a record's lifecycle is spent inside substates + // of the `loaded` state. + loaded: { + initialState: 'saved', + + // FLAGS + isLoaded: true, + + // SUBSTATES + + // If there are no local changes to a record, it remains + // in the `saved` state. + saved: { + setup: function(record) { + var attrs = record._attributes, + isDirty = false; + + for (var prop in attrs) { + if (attrs.hasOwnProperty(prop)) { + isDirty = true; + break; + } + } + + if (isDirty) { + record.adapterDidDirty(); + } + }, + + // EVENTS + didSetProperty: didSetProperty, + + pushedData: Ember.K, + + becomeDirty: function(record) { + record.transitionTo('updated.uncommitted'); + }, + + willCommit: function(record) { + record.transitionTo('updated.inFlight'); + }, + + reloadRecord: function(record, resolve) { + resolve(get(record, 'store').reloadRecord(record)); + }, + + deleteRecord: function(record) { + record.transitionTo('deleted.uncommitted'); + record.clearRelationships(); + }, + + unloadRecord: function(record) { + // clear relationships before moving to deleted state + // otherwise it fails + record.clearRelationships(); + record.transitionTo('deleted.saved'); + }, + + didCommit: function(record) { + record.send('invokeLifecycleCallbacks', get(record, 'lastDirtyType')); + }, + + // loaded.saved.notFound would be triggered by a failed + // `reload()` on an unchanged record + notFound: Ember.K + + }, + + // A record is in this state after it has been locally + // created but before the adapter has indicated that + // it has been saved. + created: createdState, + + // A record is in this state if it has already been + // saved to the server, but there are new local changes + // that have not yet been saved. + updated: updatedState + }, + + // A record is in this state if it was deleted from the store. + deleted: { + initialState: 'uncommitted', + dirtyType: 'deleted', + + // FLAGS + isDeleted: true, + isLoaded: true, + isDirty: true, + + // TRANSITIONS + setup: function(record) { + record.updateRecordArrays(); + }, + + // SUBSTATES + + // When a record is deleted, it enters the `start` + // state. It will exit this state when the record + // starts to commit. + uncommitted: { + + // EVENTS + + willCommit: function(record) { + record.transitionTo('inFlight'); + }, + + rollback: function(record) { + record.rollback(); + }, + + becomeDirty: Ember.K, + deleteRecord: Ember.K, + + rolledBack: function(record) { + record.transitionTo('loaded.saved'); + } + }, + + // After a record starts committing, but + // before the adapter indicates that the deletion + // has saved to the server, a record is in the + // `inFlight` substate of `deleted`. + inFlight: { + // FLAGS + isSaving: true, + + // EVENTS + + // TODO: More robust semantics around save-while-in-flight + willCommit: Ember.K, + didCommit: function(record) { + record.transitionTo('saved'); + + record.send('invokeLifecycleCallbacks'); + }, + + becameError: function(record) { + record.transitionTo('uncommitted'); + record.triggerLater('becameError', record); + } + }, + + // Once the adapter indicates that the deletion has + // been saved, the record enters the `saved` substate + // of `deleted`. + saved: { + // FLAGS + isDirty: false, + + setup: function(record) { + var store = get(record, 'store'); + store.dematerializeRecord(record); + }, + + invokeLifecycleCallbacks: function(record) { + record.triggerLater('didDelete', record); + record.triggerLater('didCommit', record); + } + } + }, + + invokeLifecycleCallbacks: function(record, dirtyType) { + if (dirtyType === 'created') { + record.triggerLater('didCreate', record); + } else { + record.triggerLater('didUpdate', record); + } + + record.triggerLater('didCommit', record); + } +}; + +function wireState(object, parent, name) { + /*jshint proto:true*/ + // TODO: Use Object.create and copy instead + object = mixin(parent ? Ember.create(parent) : {}, object); + object.parentState = parent; + object.stateName = name; + + for (var prop in object) { + if (!object.hasOwnProperty(prop) || prop === 'parentState' || prop === 'stateName') { continue; } + if (typeof object[prop] === 'object') { + object[prop] = wireState(object[prop], object, name + "." + prop); + } + } + + return object; +} + +RootState = wireState(RootState, null, "root"); + +DS.RootState = RootState; + +})(); + + + +(function() { +var get = Ember.get, isEmpty = Ember.isEmpty; + +/** +@module ember-data +*/ + +/** + Holds validation errors for a given record organized by attribute names. + + @class Errors + @namespace DS + @extends Ember.Object + @uses Ember.Enumerable + @uses Ember.Evented + */ +DS.Errors = Ember.Object.extend(Ember.Enumerable, Ember.Evented, { + /** + Register with target handler + + @method registerHandlers + @param {Object} target + @param {Function} becameInvalid + @param {Function} becameValid + */ + registerHandlers: function(target, becameInvalid, becameValid) { + this.on('becameInvalid', target, becameInvalid); + this.on('becameValid', target, becameValid); + }, + + /** + @property errorsByAttributeName + @type {Ember.MapWithDefault} + @private + */ + errorsByAttributeName: Ember.reduceComputed("content", { + initialValue: function() { + return Ember.MapWithDefault.create({ + defaultValue: function() { + return Ember.A(); + } + }); + }, + + addedItem: function(errors, error) { + errors.get(error.attribute).pushObject(error); + + return errors; + }, + + removedItem: function(errors, error) { + errors.get(error.attribute).removeObject(error); + + return errors; + } + }), + + /** + Returns errors for a given attribute + + @method errorsFor + @param {String} attribute + @returns {Array} + */ + errorsFor: function(attribute) { + return get(this, 'errorsByAttributeName').get(attribute); + }, + + /** + */ + messages: Ember.computed.mapBy('content', 'message'), + + /** + @property content + @type {Array} + @private + */ + content: Ember.computed(function() { + return Ember.A(); + }), + + /** + @method unknownProperty + @private + */ + unknownProperty: function(attribute) { + var errors = this.errorsFor(attribute); + if (isEmpty(errors)) { return null; } + return errors; + }, + + /** + @method nextObject + @private + */ + nextObject: function(index, previousObject, context) { + return get(this, 'content').objectAt(index); + }, + + /** + Total number of errors. + + @property length + @type {Number} + @readOnly + */ + length: Ember.computed.oneWay('content.length').readOnly(), + + /** + @property isEmpty + @type {Boolean} + @readOnly + */ + isEmpty: Ember.computed.not('length').readOnly(), + + /** + Adds error messages to a given attribute and sends + `becameInvalid` event to the record. + + @method add + @param {String} attribute + @param {Array|String} messages + */ + add: function(attribute, messages) { + var wasEmpty = get(this, 'isEmpty'); + + messages = this._findOrCreateMessages(attribute, messages); + get(this, 'content').addObjects(messages); + + this.notifyPropertyChange(attribute); + this.enumerableContentDidChange(); + + if (wasEmpty && !get(this, 'isEmpty')) { + this.trigger('becameInvalid'); + } + }, + + /** + @method _findOrCreateMessages + @private + */ + _findOrCreateMessages: function(attribute, messages) { + var errors = this.errorsFor(attribute); + + return Ember.makeArray(messages).map(function(message) { + return errors.findBy('message', message) || { + attribute: attribute, + message: message + }; + }); + }, + + /** + Removes all error messages from the given attribute and sends + `becameValid` event to the record if there no more errors left. + + @method remove + @param {String} attribute + */ + remove: function(attribute) { + if (get(this, 'isEmpty')) { return; } + + var content = get(this, 'content').rejectBy('attribute', attribute); + get(this, 'content').setObjects(content); + + this.notifyPropertyChange(attribute); + this.enumerableContentDidChange(); + + if (get(this, 'isEmpty')) { + this.trigger('becameValid'); + } + }, + + /** + Removes all error messages and sends `becameValid` event + to the record. + + @method clear + */ + clear: function() { + if (get(this, 'isEmpty')) { return; } + + get(this, 'content').clear(); + this.enumerableContentDidChange(); + + this.trigger('becameValid'); + }, + + /** + Checks if there is error messages for the given attribute. + + @method has + @param {String} attribute + @returns {Boolean} true if there some errors on given attribute + */ + has: function(attribute) { + return !isEmpty(this.errorsFor(attribute)); + } +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set, + merge = Ember.merge, once = Ember.run.once; + +var retrieveFromCurrentState = Ember.computed('currentState', function(key, value) { + return get(get(this, 'currentState'), key); +}).readOnly(); + +/** + + The model class that all Ember Data records descend from. + + @class Model + @namespace DS + @extends Ember.Object + @uses Ember.Evented +*/ +DS.Model = Ember.Object.extend(Ember.Evented, { + /** + If this property is `true` the record is in the `empty` + state. Empty is the first state all records enter after they have + been created. Most records created by the store will quickly + transition to the `loading` state if data needs to be fetched from + the server or the `created` state if the record is created on the + client. A record can also enter the empty state if the adapter is + unable to locate the record. + + @property isEmpty + @type {Boolean} + @readOnly + */ + isEmpty: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `loading` state. A + record enters this state when the store askes the adapter for its + data. It remains in this state until the adapter provides the + requested data. + + @property isLoading + @type {Boolean} + @readOnly + */ + isLoading: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `loaded` state. A + record enters this state when its data is populated. Most of a + record's lifecycle is spent inside substates of the `loaded` + state. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('isLoaded'); // true + + store.find('model', 1).then(function(model) { + model.get('isLoaded'); // true + }); + ``` + + @property isLoaded + @type {Boolean} + @readOnly + */ + isLoaded: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `dirty` state. The + record has local changes that have not yet been saved by the + adapter. This includes records that have been created (but not yet + saved) or deleted. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('isDirty'); // true + + store.find('model', 1).then(function(model) { + model.get('isDirty'); // false + model.set('foo', 'some value'); + model.set('isDirty'); // true + }); + ``` + + @property isDirty + @type {Boolean} + @readOnly + */ + isDirty: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `saving` state. A + record enters the saving state when `save` is called, but the + adapter has not yet acknowledged that the changes have been + persisted to the backend. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('isSaving'); // false + var promise = record.save(); + record.get('isSaving'); // true + promise.then(function() { + record.get('isSaving'); // false + }); + ``` + + @property isSaving + @type {Boolean} + @readOnly + */ + isSaving: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `deleted` state + and has been marked for deletion. When `isDeleted` is true and + `isDirty` is true, the record is deleted locally but the deletion + was not yet persisted. When `isSaving` is true, the change is + in-flight. When both `isDirty` and `isSaving` are false, the + change has persisted. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('isDeleted'); // false + record.deleteRecord(); + record.get('isDeleted'); // true + ``` + + @property isDeleted + @type {Boolean} + @readOnly + */ + isDeleted: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `new` state. A + record will be in the `new` state when it has been created on the + client and the adapter has not yet report that it was successfully + saved. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('isNew'); // true + + store.find('model', 1).then(function(model) { + model.get('isNew'); // false + }); + ``` + + @property isNew + @type {Boolean} + @readOnly + */ + isNew: retrieveFromCurrentState, + /** + If this property is `true` the record is in the `valid` state. A + record will be in the `valid` state when no client-side + validations have failed and the adapter did not report any + server-side validation failures. + + @property isValid + @type {Boolean} + @readOnly + */ + isValid: retrieveFromCurrentState, + /** + If the record is in the dirty state this property will report what + kind of change has caused it to move into the dirty + state. Possible values are: + + - `created` The record has been created by the client and not yet saved to the adapter. + - `updated` The record has been updated by the client and not yet saved to the adapter. + - `deleted` The record has been deleted by the client and not yet saved to the adapter. + + Example + + ```javascript + var record = store.createRecord(App.Model); + record.get('dirtyType'); // 'created' + ``` + + @property dirtyType + @type {String} + @readOnly + */ + dirtyType: retrieveFromCurrentState, + + /** + If `true` the adapter reported that it was unable to save local + changes to the backend. This may also result in the record having + its `isValid` property become false if the adapter reported that + server-side validations failed. + + Example + + ```javascript + record.get('isError'); // false + record.set('foo', 'invalid value'); + record.save().then(null, function() { + record.get('isError'); // true + }); + ``` + + @property isError + @type {Boolean} + @readOnly + */ + isError: false, + /** + If `true` the store is attempting to reload the record form the adapter. + + Example + + ```javascript + record.get('isReloading'); // false + record.reload(); + record.get('isReloading'); // true + ``` + + @property isReloading + @type {Boolean} + @readOnly + */ + isReloading: false, + + /** + The `clientId` property is a transient numerical identifier + generated at runtime by the data store. It is important + primarily because newly created objects may not yet have an + externally generated id. + + @property clientId + @private + @type {Number|String} + */ + clientId: null, + /** + All ember models have an id property. This is an identifier + managed by an external source. These are always coerced to be + strings before being used internally. Note when declaring the + attributes for a model it is an error to declare an id + attribute. + + ```javascript + var record = store.createRecord(App.Model); + record.get('id'); // null + + store.find('model', 1).then(function(model) { + model.get('id'); // '1' + }); + ``` + + @property id + @type {String} + */ + id: null, + transaction: null, + /** + @property currentState + @private + @type {Object} + */ + currentState: null, + /** + When the record is in the `invalid` state this object will contain + any errors returned by the adapter. When present the errors hash + typically contains keys coresponding to the invalid property names + and values which are an array of error messages. + + ```javascript + record.get('errors.length'); // 0 + record.set('foo', 'invalid value'); + record.save().then(null, function() { + record.get('errors').get('foo'); // ['foo should be a number.'] + }); + ``` + + @property errors + @type {Object} + */ + errors: null, + + /** + Create a JSON representation of the record, using the serialization + strategy of the store's adapter. + + `serialize` takes an optional hash as a parameter, currently + supported options are: + + - `includeId`: `true` if the record's ID should be included in the + JSON representation. + + @method serialize + @param {Object} options + @returns {Object} an object whose values are primitive JSON values only + */ + serialize: function(options) { + var store = get(this, 'store'); + return store.serialize(this, options); + }, + + /** + Use [DS.JSONSerializer](DS.JSONSerializer.html) to + get the JSON representation of a record. + + `toJSON` takes an optional hash as a parameter, currently + supported options are: + + - `includeId`: `true` if the record's ID should be included in the + JSON representation. + + @method toJSON + @param {Object} options + @returns {Object} A JSON representation of the object. + */ + toJSON: function(options) { + // container is for lazy transform lookups + var serializer = DS.JSONSerializer.create({ container: this.container }); + return serializer.serialize(this, options); + }, + + /** + Fired when the record is loaded from the server. + + @event didLoad + */ + didLoad: Ember.K, + + /** + Fired when the record is updated. + + @event didUpdate + */ + didUpdate: Ember.K, + + /** + Fired when the record is created. + + @event didCreate + */ + didCreate: Ember.K, + + /** + Fired when the record is deleted. + + @event didDelete + */ + didDelete: Ember.K, + + /** + Fired when the record becomes invalid. + + @event becameInvalid + */ + becameInvalid: Ember.K, + + /** + Fired when the record enters the error state. + + @event becameError + */ + becameError: Ember.K, + + /** + @property data + @private + @type {Object} + */ + data: Ember.computed(function() { + this._data = this._data || {}; + return this._data; + }).property(), + + _data: null, + + init: function() { + set(this, 'currentState', DS.RootState.empty); + var errors = DS.Errors.create(); + errors.registerHandlers(this, function() { + this.send('becameInvalid'); + }, function() { + this.send('becameValid'); + }); + set(this, 'errors', errors); + this._super(); + this._setup(); + }, + + _setup: function() { + this._changesToSync = {}; + this._deferredTriggers = []; + this._data = {}; + this._attributes = {}; + this._inFlightAttributes = {}; + this._relationships = {}; + }, + + /** + @method send + @private + @param {String} name + @param {Object} context + */ + send: function(name, context) { + var currentState = get(this, 'currentState'); + + if (!currentState[name]) { + this._unhandledEvent(currentState, name, context); + } + + return currentState[name](this, context); + }, + + /** + @method transitionTo + @private + @param {String} name + */ + transitionTo: function(name) { + // POSSIBLE TODO: Remove this code and replace with + // always having direct references to state objects + + var pivotName = name.split(".", 1), + currentState = get(this, 'currentState'), + state = currentState; + + do { + if (state.exit) { state.exit(this); } + state = state.parentState; + } while (!state.hasOwnProperty(pivotName)); + + var path = name.split("."); + + var setups = [], enters = [], i, l; + + for (i=0, l=path.length; i')` from " + this.toString(), name !== 'id'); + + meta.name = name; + map.set(name, meta); + } + }); + + return map; + }), + + /** + A map whose keys are the attributes of the model (properties + described by DS.attr) and whose values are type of transformation + applied to each attribute. This map does not include any + attributes that do not have an transformation type. + + Example + + ```javascript + App.Person = DS.Model.extend({ + firstName: attr(), + lastName: attr('string'), + birthday: attr('date') + }); + + var transformedAttributes = Ember.get(App.Person, 'transformedAttributes') + + transformedAttributes.forEach(function(field, type) { + console.log(field, type); + }); + + // prints: + // lastName string + // birthday date + ``` + + @property transformedAttributes + @static + @type {Ember.Map} + @readOnly + */ + transformedAttributes: Ember.computed(function() { + var map = Ember.Map.create(); + + this.eachAttribute(function(key, meta) { + if (meta.type) { + map.set(key, meta.type); + } + }); + + return map; + }), + + /** + Iterates through the attributes of the model, calling the passed function on each + attribute. + + The callback method you provide should have the following signature (all + parameters are optional): + + ```javascript + function(name, meta); + ``` + + - `name` the name of the current property in the iteration + - `meta` the meta object for the attribute property in the iteration + + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. + + Example + + ```javascript + App.Person = DS.Model.extend({ + firstName: attr('string'), + lastName: attr('string'), + birthday: attr('date') + }); + + App.Person.eachAttribute(function(name, meta) { + console.log(name, meta); + }); + + // prints: + // firstName {type: "string", isAttribute: true, options: Object, parentType: function, name: "firstName"} + // lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"} + // birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"} + ``` + + @method eachAttribute + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @static + */ + eachAttribute: function(callback, binding) { + get(this, 'attributes').forEach(function(name, meta) { + callback.call(binding, name, meta); + }, binding); + }, + + /** + Iterates through the transformedAttributes of the model, calling + the passed function on each attribute. Note the callback will not be + called for any attributes that do not have an transformation type. + + The callback method you provide should have the following signature (all + parameters are optional): + + ```javascript + function(name, type); + ``` + + - `name` the name of the current property in the iteration + - `type` a tring contrining the name of the type of transformed + applied to the attribute + + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. + + Example + + ```javascript + App.Person = DS.Model.extend({ + firstName: attr(), + lastName: attr('string'), + birthday: attr('date') + }); + + App.Person.eachTransformedAttribute(function(name, type) { + console.log(name, type); + }); + + // prints: + // lastName string + // birthday date + ``` + + @method eachTransformedAttribute + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @static + */ + eachTransformedAttribute: function(callback, binding) { + get(this, 'transformedAttributes').forEach(function(name, type) { + callback.call(binding, name, type); + }); + } +}); + + +DS.Model.reopen({ + eachAttribute: function(callback, binding) { + this.constructor.eachAttribute(callback, binding); + } +}); + +function getDefaultValue(record, options, key) { + if (typeof options.defaultValue === "function") { + return options.defaultValue(); + } else { + return options.defaultValue; + } +} + +function hasValue(record, key) { + return record._attributes.hasOwnProperty(key) || + record._inFlightAttributes.hasOwnProperty(key) || + record._data.hasOwnProperty(key); +} + +function getValue(record, key) { + if (record._attributes.hasOwnProperty(key)) { + return record._attributes[key]; + } else if (record._inFlightAttributes.hasOwnProperty(key)) { + return record._inFlightAttributes[key]; + } else { + return record._data[key]; + } +} + +/** + `DS.attr` defines an attribute on a [DS.Model](DS.Model.html). + By default, attributes are passed through as-is, however you can specify an + optional type to have the value automatically transformed. + Ember Data ships with four basic transform types: `string`, `number`, + `boolean` and `date`. You can define your own transforms by subclassing + [DS.Transform](DS.Transform.html). + + `DS.attr` takes an optional hash as a second parameter, currently + supported options are: + + - `defaultValue`: Pass a string or a function to be called to set the attribute + to a default value if none is supplied. + + Example + + ```javascript + var attr = DS.attr; + + App.User = DS.Model.extend({ + username: attr('string'), + email: attr('string'), + verified: attr('boolean', {defaultValue: false}) + }); + ``` + + @namespace + @method attr + @for DS + @param {String} type the attribute type + @param {Object} options a hash of options + @return {Attribute} +*/ + +DS.attr = function(type, options) { + options = options || {}; + + var meta = { + type: type, + isAttribute: true, + options: options + }; + + return Ember.computed(function(key, value) { + if (arguments.length > 1) { + Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('')` from " + this.constructor.toString(), key !== 'id'); + var oldValue = this._attributes[key] || this._inFlightAttributes[key] || this._data[key]; + + this.send('didSetProperty', { + name: key, + oldValue: oldValue, + originalValue: this._data[key], + value: value + }); + + this._attributes[key] = value; + return value; + } else if (hasValue(this, key)) { + return getValue(this, key); + } else { + return getDefaultValue(this, options, key); + } + + // `data` is never set directly. However, it may be + // invalidated from the state manager's setData + // event. + }).property('data').meta(meta); +}; + + +})(); + + + +(function() { +/** + @module ember-data +*/ + +})(); + + + +(function() { +/** + @module ember-data +*/ + +/** + An AttributeChange object is created whenever a record's + attribute changes value. It is used to track changes to a + record between transaction commits. + + @class AttributeChange + @namespace DS + @private + @constructor +*/ +var AttributeChange = DS.AttributeChange = function(options) { + this.record = options.record; + this.store = options.store; + this.name = options.name; + this.value = options.value; + this.oldValue = options.oldValue; +}; + +AttributeChange.createChange = function(options) { + return new AttributeChange(options); +}; + +AttributeChange.prototype = { + sync: function() { + if (this.value !== this.oldValue) { + this.record.send('becomeDirty'); + this.record.updateRecordArraysLater(); + } + + // TODO: Use this object in the commit process + this.destroy(); + }, + + /** + If the AttributeChange is destroyed (either by being rolled back + or being committed), remove it from the list of pending changes + on the record. + + @method destroy + */ + destroy: function() { + delete this.record._changesToSync[this.name]; + } +}; + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set; +var forEach = Ember.EnumerableUtils.forEach; + +/** + @class RelationshipChange + @namespace DS + @private + @construtor +*/ +DS.RelationshipChange = function(options) { + this.parentRecord = options.parentRecord; + this.childRecord = options.childRecord; + this.firstRecord = options.firstRecord; + this.firstRecordKind = options.firstRecordKind; + this.firstRecordName = options.firstRecordName; + this.secondRecord = options.secondRecord; + this.secondRecordKind = options.secondRecordKind; + this.secondRecordName = options.secondRecordName; + this.changeType = options.changeType; + this.store = options.store; + + this.committed = {}; +}; + +/** + @class RelationshipChangeAdd + @namespace DS + @private + @construtor +*/ +DS.RelationshipChangeAdd = function(options){ + DS.RelationshipChange.call(this, options); +}; + +/** + @class RelationshipChangeRemove + @namespace DS + @private + @construtor +*/ +DS.RelationshipChangeRemove = function(options){ + DS.RelationshipChange.call(this, options); +}; + +DS.RelationshipChange.create = function(options) { + return new DS.RelationshipChange(options); +}; + +DS.RelationshipChangeAdd.create = function(options) { + return new DS.RelationshipChangeAdd(options); +}; + +DS.RelationshipChangeRemove.create = function(options) { + return new DS.RelationshipChangeRemove(options); +}; + +DS.OneToManyChange = {}; +DS.OneToNoneChange = {}; +DS.ManyToNoneChange = {}; +DS.OneToOneChange = {}; +DS.ManyToManyChange = {}; + +DS.RelationshipChange._createChange = function(options){ + if(options.changeType === "add"){ + return DS.RelationshipChangeAdd.create(options); + } + if(options.changeType === "remove"){ + return DS.RelationshipChangeRemove.create(options); + } +}; + + +DS.RelationshipChange.determineRelationshipType = function(recordType, knownSide){ + var knownKey = knownSide.key, key, otherKind; + var knownKind = knownSide.kind; + + var inverse = recordType.inverseFor(knownKey); + + if (inverse){ + key = inverse.name; + otherKind = inverse.kind; + } + + if (!inverse){ + return knownKind === "belongsTo" ? "oneToNone" : "manyToNone"; + } + else{ + if(otherKind === "belongsTo"){ + return knownKind === "belongsTo" ? "oneToOne" : "manyToOne"; + } + else{ + return knownKind === "belongsTo" ? "oneToMany" : "manyToMany"; + } + } + +}; + +DS.RelationshipChange.createChange = function(firstRecord, secondRecord, store, options){ + // Get the type of the child based on the child's client ID + var firstRecordType = firstRecord.constructor, changeType; + changeType = DS.RelationshipChange.determineRelationshipType(firstRecordType, options); + if (changeType === "oneToMany"){ + return DS.OneToManyChange.createChange(firstRecord, secondRecord, store, options); + } + else if (changeType === "manyToOne"){ + return DS.OneToManyChange.createChange(secondRecord, firstRecord, store, options); + } + else if (changeType === "oneToNone"){ + return DS.OneToNoneChange.createChange(firstRecord, secondRecord, store, options); + } + else if (changeType === "manyToNone"){ + return DS.ManyToNoneChange.createChange(firstRecord, secondRecord, store, options); + } + else if (changeType === "oneToOne"){ + return DS.OneToOneChange.createChange(firstRecord, secondRecord, store, options); + } + else if (changeType === "manyToMany"){ + return DS.ManyToManyChange.createChange(firstRecord, secondRecord, store, options); + } +}; + +DS.OneToNoneChange.createChange = function(childRecord, parentRecord, store, options) { + var key = options.key; + var change = DS.RelationshipChange._createChange({ + parentRecord: parentRecord, + childRecord: childRecord, + firstRecord: childRecord, + store: store, + changeType: options.changeType, + firstRecordName: key, + firstRecordKind: "belongsTo" + }); + + store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change); + + return change; +}; + +DS.ManyToNoneChange.createChange = function(childRecord, parentRecord, store, options) { + var key = options.key; + var change = DS.RelationshipChange._createChange({ + parentRecord: childRecord, + childRecord: parentRecord, + secondRecord: childRecord, + store: store, + changeType: options.changeType, + secondRecordName: options.key, + secondRecordKind: "hasMany" + }); + + store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change); + return change; +}; + + +DS.ManyToManyChange.createChange = function(childRecord, parentRecord, store, options) { + // If the name of the belongsTo side of the relationship is specified, + // use that + // If the type of the parent is specified, look it up on the child's type + // definition. + var key = options.key; + + var change = DS.RelationshipChange._createChange({ + parentRecord: parentRecord, + childRecord: childRecord, + firstRecord: childRecord, + secondRecord: parentRecord, + firstRecordKind: "hasMany", + secondRecordKind: "hasMany", + store: store, + changeType: options.changeType, + firstRecordName: key + }); + + store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change); + + + return change; +}; + +DS.OneToOneChange.createChange = function(childRecord, parentRecord, store, options) { + var key; + + // If the name of the belongsTo side of the relationship is specified, + // use that + // If the type of the parent is specified, look it up on the child's type + // definition. + if (options.parentType) { + key = options.parentType.inverseFor(options.key).name; + } else if (options.key) { + key = options.key; + } else { + Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent", false); + } + + var change = DS.RelationshipChange._createChange({ + parentRecord: parentRecord, + childRecord: childRecord, + firstRecord: childRecord, + secondRecord: parentRecord, + firstRecordKind: "belongsTo", + secondRecordKind: "belongsTo", + store: store, + changeType: options.changeType, + firstRecordName: key + }); + + store.addRelationshipChangeFor(childRecord, key, parentRecord, null, change); + + + return change; +}; + +DS.OneToOneChange.maintainInvariant = function(options, store, childRecord, key){ + if (options.changeType === "add" && store.recordIsMaterialized(childRecord)) { + var oldParent = get(childRecord, key); + if (oldParent){ + var correspondingChange = DS.OneToOneChange.createChange(childRecord, oldParent, store, { + parentType: options.parentType, + hasManyName: options.hasManyName, + changeType: "remove", + key: options.key + }); + store.addRelationshipChangeFor(childRecord, key, options.parentRecord , null, correspondingChange); + correspondingChange.sync(); + } + } +}; + +DS.OneToManyChange.createChange = function(childRecord, parentRecord, store, options) { + var key; + + // If the name of the belongsTo side of the relationship is specified, + // use that + // If the type of the parent is specified, look it up on the child's type + // definition. + if (options.parentType) { + key = options.parentType.inverseFor(options.key).name; + DS.OneToManyChange.maintainInvariant( options, store, childRecord, key ); + } else if (options.key) { + key = options.key; + } else { + Ember.assert("You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent", false); + } + + var change = DS.RelationshipChange._createChange({ + parentRecord: parentRecord, + childRecord: childRecord, + firstRecord: childRecord, + secondRecord: parentRecord, + firstRecordKind: "belongsTo", + secondRecordKind: "hasMany", + store: store, + changeType: options.changeType, + firstRecordName: key + }); + + store.addRelationshipChangeFor(childRecord, key, parentRecord, change.getSecondRecordName(), change); + + + return change; +}; + + +DS.OneToManyChange.maintainInvariant = function(options, store, childRecord, key){ + if (options.changeType === "add" && childRecord) { + var oldParent = get(childRecord, key); + if (oldParent){ + var correspondingChange = DS.OneToManyChange.createChange(childRecord, oldParent, store, { + parentType: options.parentType, + hasManyName: options.hasManyName, + changeType: "remove", + key: options.key + }); + store.addRelationshipChangeFor(childRecord, key, options.parentRecord, correspondingChange.getSecondRecordName(), correspondingChange); + correspondingChange.sync(); + } + } +}; + +/** + @class RelationshipChange + @namespace DS +*/ +DS.RelationshipChange.prototype = { + + getSecondRecordName: function() { + var name = this.secondRecordName, parent; + + if (!name) { + parent = this.secondRecord; + if (!parent) { return; } + + var childType = this.firstRecord.constructor; + var inverse = childType.inverseFor(this.firstRecordName); + this.secondRecordName = inverse.name; + } + + return this.secondRecordName; + }, + + /** + Get the name of the relationship on the belongsTo side. + + @method getFirstRecordName + @return {String} + */ + getFirstRecordName: function() { + var name = this.firstRecordName; + return name; + }, + + /** + @method destroy + @private + */ + destroy: function() { + var childRecord = this.childRecord, + belongsToName = this.getFirstRecordName(), + hasManyName = this.getSecondRecordName(), + store = this.store; + + store.removeRelationshipChangeFor(childRecord, belongsToName, this.parentRecord, hasManyName, this.changeType); + }, + + getSecondRecord: function(){ + return this.secondRecord; + }, + + /** + @method getFirstRecord + @private + */ + getFirstRecord: function() { + return this.firstRecord; + }, + + coalesce: function(){ + var relationshipPairs = this.store.relationshipChangePairsFor(this.firstRecord); + forEach(relationshipPairs, function(pair){ + var addedChange = pair["add"]; + var removedChange = pair["remove"]; + if(addedChange && removedChange) { + addedChange.destroy(); + removedChange.destroy(); + } + }); + } +}; + +DS.RelationshipChangeAdd.prototype = Ember.create(DS.RelationshipChange.create({})); +DS.RelationshipChangeRemove.prototype = Ember.create(DS.RelationshipChange.create({})); + +// the object is a value, and not a promise +function isValue(object) { + return typeof object === 'object' && (!object.then || typeof object.then !== 'function'); +} + +DS.RelationshipChangeAdd.prototype.changeType = "add"; +DS.RelationshipChangeAdd.prototype.sync = function() { + var secondRecordName = this.getSecondRecordName(), + firstRecordName = this.getFirstRecordName(), + firstRecord = this.getFirstRecord(), + secondRecord = this.getSecondRecord(); + + //Ember.assert("You specified a hasMany (" + hasManyName + ") on " + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + " but did not specify an inverse belongsTo on " + child.constructor, belongsToName); + //Ember.assert("You specified a belongsTo (" + belongsToName + ") on " + child.constructor + " but did not specify an inverse hasMany on " + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName); + + if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) { + if(this.secondRecordKind === "belongsTo"){ + secondRecord.suspendRelationshipObservers(function(){ + set(secondRecord, secondRecordName, firstRecord); + }); + + } + else if(this.secondRecordKind === "hasMany"){ + secondRecord.suspendRelationshipObservers(function(){ + var relationship = get(secondRecord, secondRecordName); + if (isValue(relationship)) { relationship.addObject(firstRecord); } + }); + } + } + + if (firstRecord instanceof DS.Model && secondRecord instanceof DS.Model && get(firstRecord, firstRecordName) !== secondRecord) { + if(this.firstRecordKind === "belongsTo"){ + firstRecord.suspendRelationshipObservers(function(){ + set(firstRecord, firstRecordName, secondRecord); + }); + } + else if(this.firstRecordKind === "hasMany"){ + firstRecord.suspendRelationshipObservers(function(){ + var relationship = get(firstRecord, firstRecordName); + if (isValue(relationship)) { relationship.addObject(secondRecord); } + }); + } + } + + this.coalesce(); +}; + +DS.RelationshipChangeRemove.prototype.changeType = "remove"; +DS.RelationshipChangeRemove.prototype.sync = function() { + var secondRecordName = this.getSecondRecordName(), + firstRecordName = this.getFirstRecordName(), + firstRecord = this.getFirstRecord(), + secondRecord = this.getSecondRecord(); + + //Ember.assert("You specified a hasMany (" + hasManyName + ") on " + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + " but did not specify an inverse belongsTo on " + child.constructor, belongsToName); + //Ember.assert("You specified a belongsTo (" + belongsToName + ") on " + child.constructor + " but did not specify an inverse hasMany on " + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName); + + if (secondRecord instanceof DS.Model && firstRecord instanceof DS.Model) { + if(this.secondRecordKind === "belongsTo"){ + secondRecord.suspendRelationshipObservers(function(){ + set(secondRecord, secondRecordName, null); + }); + } + else if(this.secondRecordKind === "hasMany"){ + secondRecord.suspendRelationshipObservers(function(){ + var relationship = get(secondRecord, secondRecordName); + if (isValue(relationship)) { relationship.removeObject(firstRecord); } + }); + } + } + + if (firstRecord instanceof DS.Model && get(firstRecord, firstRecordName)) { + if(this.firstRecordKind === "belongsTo"){ + firstRecord.suspendRelationshipObservers(function(){ + set(firstRecord, firstRecordName, null); + }); + } + else if(this.firstRecordKind === "hasMany"){ + firstRecord.suspendRelationshipObservers(function(){ + var relationship = get(firstRecord, firstRecordName); + if (isValue(relationship)) { relationship.removeObject(secondRecord); } + }); + } + } + + this.coalesce(); +}; + +})(); + + + +(function() { +/** + @module ember-data +*/ + +})(); + + + +(function() { +var get = Ember.get, set = Ember.set, + isNone = Ember.isNone; + +/** + @module ember-data +*/ + +function asyncBelongsTo(type, options, meta) { + return Ember.computed(function(key, value) { + var data = get(this, 'data'), + store = get(this, 'store'), + promiseLabel = "DS: Async belongsTo " + this + " : " + key; + + if (arguments.length === 2) { + Ember.assert("You can only add a '" + type + "' record to this relationship", !value || value instanceof store.modelFor(type)); + return value === undefined ? null : DS.PromiseObject.create({ promise: Ember.RSVP.resolve(value, promiseLabel) }); + } + + var link = data.links && data.links[key], + belongsTo = data[key]; + + if(!isNone(belongsTo)) { + var promise = store.fetchRecord(belongsTo) || Ember.RSVP.resolve(belongsTo, promiseLabel); + return DS.PromiseObject.create({ promise: promise}); + } else if (link) { + var resolver = Ember.RSVP.defer("DS: Async belongsTo (link) " + this + " : " + key); + store.findBelongsTo(this, link, meta, resolver); + return DS.PromiseObject.create({ promise: resolver.promise }); + } else { + return null; + } + }).property('data').meta(meta); +} + +/** + `DS.belongsTo` is used to define One-To-One and One-To-Many + relationships on a [DS.Model](DS.Model.html). + + + `DS.belongsTo` takes an optional hash as a second parameter, currently + supported options are: + + - `async`: A boolean value used to explicitly declare this to be an async relationship. + - `inverse`: A string used to identify the inverse property on a + related model in a One-To-Many relationship. See [Explicit Inverses](#toc_explicit-inverses) + + #### One-To-One + To declare a one-to-one relationship between two models, use + `DS.belongsTo`: + + ```javascript + App.User = DS.Model.extend({ + profile: DS.belongsTo('profile') + }); + + App.Profile = DS.Model.extend({ + user: DS.belongsTo('user') + }); + ``` + + #### One-To-Many + To declare a one-to-many relationship between two models, use + `DS.belongsTo` in combination with `DS.hasMany`, like this: + + ```javascript + App.Post = DS.Model.extend({ + comments: DS.hasMany('comment') + }); + + App.Comment = DS.Model.extend({ + post: DS.belongsTo('post') + }); + ``` + + @namespace + @method belongsTo + @for DS + @param {String or DS.Model} type the model type of the relationship + @param {Object} options a hash of options + @return {Ember.computed} relationship +*/ +DS.belongsTo = function(type, options) { + if (typeof type === 'object') { + options = type; + type = undefined; + } else { + Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)", !!type && (typeof type === 'string' || DS.Model.detect(type))); + } + + options = options || {}; + + var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' }; + + if (options.async) { + return asyncBelongsTo(type, options, meta); + } + + return Ember.computed(function(key, value) { + var data = get(this, 'data'), + store = get(this, 'store'), belongsTo, typeClass; + + if (typeof type === 'string') { + typeClass = store.modelFor(type); + } else { + typeClass = type; + } + + if (arguments.length === 2) { + Ember.assert("You can only add a '" + type + "' record to this relationship", !value || value instanceof typeClass); + return value === undefined ? null : value; + } + + belongsTo = data[key]; + + if (isNone(belongsTo)) { return null; } + + store.fetchRecord(belongsTo); + + return belongsTo; + }).property('data').meta(meta); +}; + +/** + These observers observe all `belongsTo` relationships on the record. See + `relationships/ext` to see how these observers get their dependencies. + + @class Model + @namespace DS +*/ +DS.Model.reopen({ + + /** + @method belongsToWillChange + @private + @static + @param record + @param key + */ + belongsToWillChange: Ember.beforeObserver(function(record, key) { + if (get(record, 'isLoaded')) { + var oldParent = get(record, key); + + if (oldParent) { + var store = get(record, 'store'), + change = DS.RelationshipChange.createChange(record, oldParent, store, { key: key, kind: "belongsTo", changeType: "remove" }); + + change.sync(); + this._changesToSync[key] = change; + } + } + }), + + /** + @method belongsToDidChange + @private + @static + @param record + @param key + */ + belongsToDidChange: Ember.immediateObserver(function(record, key) { + if (get(record, 'isLoaded')) { + var newParent = get(record, key); + + if (newParent) { + var store = get(record, 'store'), + change = DS.RelationshipChange.createChange(record, newParent, store, { key: key, kind: "belongsTo", changeType: "add" }); + + change.sync(); + } + } + + delete this._changesToSync[key]; + }) +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set, setProperties = Ember.setProperties; + +function asyncHasMany(type, options, meta) { + return Ember.computed(function(key, value) { + var relationship = this._relationships[key], + promiseLabel = "DS: Async hasMany " + this + " : " + key; + + if (!relationship) { + var resolver = Ember.RSVP.defer(promiseLabel); + relationship = buildRelationship(this, key, options, function(store, data) { + var link = data.links && data.links[key]; + var rel; + if (link) { + rel = store.findHasMany(this, link, meta, resolver); + } else { + rel = store.findMany(this, data[key], meta.type, resolver); + } + // cache the promise so we can use it + // when we come back and don't need to rebuild + // the relationship. + set(rel, 'promise', resolver.promise); + return rel; + }); + } + + var promise = relationship.get('promise').then(function() { + return relationship; + }, null, "DS: Async hasMany records received"); + + return DS.PromiseArray.create({ promise: promise }); + }).property('data').meta(meta); +} + +function buildRelationship(record, key, options, callback) { + var rels = record._relationships; + + if (rels[key]) { return rels[key]; } + + var data = get(record, 'data'), + store = get(record, 'store'); + + var relationship = rels[key] = callback.call(record, store, data); + + return setProperties(relationship, { + owner: record, name: key, isPolymorphic: options.polymorphic + }); +} + +function hasRelationship(type, options) { + options = options || {}; + + var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' }; + + if (options.async) { + return asyncHasMany(type, options, meta); + } + + return Ember.computed(function(key, value) { + return buildRelationship(this, key, options, function(store, data) { + var records = data[key]; + Ember.assert("You looked up the '" + key + "' relationship on '" + this + "' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", Ember.A(records).everyProperty('isEmpty', false)); + return store.findMany(this, data[key], meta.type); + }); + }).property('data').meta(meta); +} + +/** + `DS.hasMany` is used to define One-To-Many and Many-To-Many + relationships on a [DS.Model](DS.Model.html). + + `DS.hasMany` takes an optional hash as a second parameter, currently + supported options are: + + - `async`: A boolean value used to explicitly declare this to be an async relationship. + - `inverse`: A string used to identify the inverse property on a related model. + + #### One-To-Many + To declare a one-to-many relationship between two models, use + `DS.belongsTo` in combination with `DS.hasMany`, like this: + + ```javascript + App.Post = DS.Model.extend({ + comments: DS.hasMany('comment') + }); + + App.Comment = DS.Model.extend({ + post: DS.belongsTo('post') + }); + ``` + + #### Many-To-Many + To declare a many-to-many relationship between two models, use + `DS.hasMany`: + + ```javascript + App.Post = DS.Model.extend({ + tags: DS.hasMany('tag') + }); + + App.Tag = DS.Model.extend({ + posts: DS.hasMany('post') + }); + ``` + + #### Explicit Inverses + + Ember Data will do its best to discover which relationships map to + one another. In the one-to-many code above, for example, Ember Data + can figure out that changing the `comments` relationship should update + the `post` relationship on the inverse because post is the only + relationship to that model. + + However, sometimes you may have multiple `belongsTo`/`hasManys` for the + same type. You can specify which property on the related model is + the inverse using `DS.hasMany`'s `inverse` option: + + ```javascript + var belongsTo = DS.belongsTo, + hasMany = DS.hasMany; + + App.Comment = DS.Model.extend({ + onePost: belongsTo('post'), + twoPost: belongsTo('post'), + redPost: belongsTo('post'), + bluePost: belongsTo('post') + }); + + App.Post = DS.Model.extend({ + comments: hasMany('comment', { + inverse: 'redPost' + }) + }); + ``` + + You can also specify an inverse on a `belongsTo`, which works how + you'd expect. + + @namespace + @method hasMany + @for DS + @param {String or DS.Model} type the model type of the relationship + @param {Object} options a hash of options + @return {Ember.computed} relationship +*/ +DS.hasMany = function(type, options) { + if (typeof type === 'object') { + options = type; + type = undefined; + } + return hasRelationship(type, options); +}; + +})(); + + + +(function() { +var get = Ember.get, set = Ember.set; + +/** + @module ember-data +*/ + +/* + This file defines several extensions to the base `DS.Model` class that + add support for one-to-many relationships. +*/ + +/** + @class Model + @namespace DS +*/ +DS.Model.reopen({ + + /** + This Ember.js hook allows an object to be notified when a property + is defined. + + In this case, we use it to be notified when an Ember Data user defines a + belongs-to relationship. In that case, we need to set up observers for + each one, allowing us to track relationship changes and automatically + reflect changes in the inverse has-many array. + + This hook passes the class being set up, as well as the key and value + being defined. So, for example, when the user does this: + + ```javascript + DS.Model.extend({ + parent: DS.belongsTo('user') + }); + ``` + + This hook would be called with "parent" as the key and the computed + property returned by `DS.belongsTo` as the value. + + @method didDefineProperty + @param proto + @param key + @param value + */ + didDefineProperty: function(proto, key, value) { + // Check if the value being set is a computed property. + if (value instanceof Ember.Descriptor) { + + // If it is, get the metadata for the relationship. This is + // populated by the `DS.belongsTo` helper when it is creating + // the computed property. + var meta = value.meta(); + + if (meta.isRelationship && meta.kind === 'belongsTo') { + Ember.addObserver(proto, key, null, 'belongsToDidChange'); + Ember.addBeforeObserver(proto, key, null, 'belongsToWillChange'); + } + + meta.parentType = proto.constructor; + } + } +}); + +/* + These DS.Model extensions add class methods that provide relationship + introspection abilities about relationships. + + A note about the computed properties contained here: + + **These properties are effectively sealed once called for the first time.** + To avoid repeatedly doing expensive iteration over a model's fields, these + values are computed once and then cached for the remainder of the runtime of + your application. + + If your application needs to modify a class after its initial definition + (for example, using `reopen()` to add additional attributes), make sure you + do it before using your model with the store, which uses these properties + extensively. +*/ + +DS.Model.reopenClass({ + /** + For a given relationship name, returns the model type of the relationship. + + For example, if you define a model like this: + + ```javascript + App.Post = DS.Model.extend({ + comments: DS.hasMany('comment') + }); + ``` + + Calling `App.Post.typeForRelationship('comments')` will return `App.Comment`. + + @method typeForRelationship + @static + @param {String} name the name of the relationship + @return {subclass of DS.Model} the type of the relationship, or undefined + */ + typeForRelationship: function(name) { + var relationship = get(this, 'relationshipsByName').get(name); + return relationship && relationship.type; + }, + + inverseFor: function(name) { + var inverseType = this.typeForRelationship(name); + + if (!inverseType) { return null; } + + var options = this.metaForProperty(name).options; + + if (options.inverse === null) { return null; } + + var inverseName, inverseKind; + + if (options.inverse) { + inverseName = options.inverse; + inverseKind = Ember.get(inverseType, 'relationshipsByName').get(inverseName).kind; + } else { + var possibleRelationships = findPossibleInverses(this, inverseType); + + if (possibleRelationships.length === 0) { return null; } + + Ember.assert("You defined the '" + name + "' relationship on " + this + ", but multiple possible inverse relationships of type " + this + " were found on " + inverseType + ". Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses", possibleRelationships.length === 1); + + inverseName = possibleRelationships[0].name; + inverseKind = possibleRelationships[0].kind; + } + + function findPossibleInverses(type, inverseType, possibleRelationships) { + possibleRelationships = possibleRelationships || []; + + var relationshipMap = get(inverseType, 'relationships'); + if (!relationshipMap) { return; } + + var relationships = relationshipMap.get(type); + if (relationships) { + possibleRelationships.push.apply(possibleRelationships, relationshipMap.get(type)); + } + + if (type.superclass) { + findPossibleInverses(type.superclass, inverseType, possibleRelationships); + } + + return possibleRelationships; + } + + return { + type: inverseType, + name: inverseName, + kind: inverseKind + }; + }, + + /** + The model's relationships as a map, keyed on the type of the + relationship. The value of each entry is an array containing a descriptor + for each relationship with that type, describing the name of the relationship + as well as the type. + + For example, given the following model definition: + + ```javascript + App.Blog = DS.Model.extend({ + users: DS.hasMany('user'), + owner: DS.belongsTo('user'), + posts: DS.hasMany('post') + }); + ``` + + This computed property would return a map describing these + relationships, like this: + + ```javascript + var relationships = Ember.get(App.Blog, 'relationships'); + relationships.get(App.User); + //=> [ { name: 'users', kind: 'hasMany' }, + // { name: 'owner', kind: 'belongsTo' } ] + relationships.get(App.Post); + //=> [ { name: 'posts', kind: 'hasMany' } ] + ``` + + @property relationships + @static + @type Ember.Map + @readOnly + */ + relationships: Ember.computed(function() { + var map = new Ember.MapWithDefault({ + defaultValue: function() { return []; } + }); + + // Loop through each computed property on the class + this.eachComputedProperty(function(name, meta) { + + // If the computed property is a relationship, add + // it to the map. + if (meta.isRelationship) { + if (typeof meta.type === 'string') { + meta.type = this.store.modelFor(meta.type); + } + + var relationshipsForType = map.get(meta.type); + + relationshipsForType.push({ name: name, kind: meta.kind }); + } + }); + + return map; + }), + + /** + A hash containing lists of the model's relationships, grouped + by the relationship kind. For example, given a model with this + definition: + + ```javascript + App.Blog = DS.Model.extend({ + users: DS.hasMany('user'), + owner: DS.belongsTo('user'), + + posts: DS.hasMany('post') + }); + ``` + + This property would contain the following: + + ```javascript + var relationshipNames = Ember.get(App.Blog, 'relationshipNames'); + relationshipNames.hasMany; + //=> ['users', 'posts'] + relationshipNames.belongsTo; + //=> ['owner'] + ``` + + @property relationshipNames + @static + @type Object + @readOnly + */ + relationshipNames: Ember.computed(function() { + var names = { hasMany: [], belongsTo: [] }; + + this.eachComputedProperty(function(name, meta) { + if (meta.isRelationship) { + names[meta.kind].push(name); + } + }); + + return names; + }), + + /** + An array of types directly related to a model. Each type will be + included once, regardless of the number of relationships it has with + the model. + + For example, given a model with this definition: + + ```javascript + App.Blog = DS.Model.extend({ + users: DS.hasMany('user'), + owner: DS.belongsTo('user'), + + posts: DS.hasMany('post') + }); + ``` + + This property would contain the following: + + ```javascript + var relatedTypes = Ember.get(App.Blog, 'relatedTypes'); + //=> [ App.User, App.Post ] + ``` + + @property relatedTypes + @static + @type Ember.Array + @readOnly + */ + relatedTypes: Ember.computed(function() { + var type, + types = Ember.A(); + + // Loop through each computed property on the class, + // and create an array of the unique types involved + // in relationships + this.eachComputedProperty(function(name, meta) { + if (meta.isRelationship) { + type = meta.type; + + if (typeof type === 'string') { + type = get(this, type, false) || this.store.modelFor(type); + } + + Ember.assert("You specified a hasMany (" + meta.type + ") on " + meta.parentType + " but " + meta.type + " was not found.", type); + + if (!types.contains(type)) { + Ember.assert("Trying to sideload " + name + " on " + this.toString() + " but the type doesn't exist.", !!type); + types.push(type); + } + } + }); + + return types; + }), + + /** + A map whose keys are the relationships of a model and whose values are + relationship descriptors. + + For example, given a model with this + definition: + + ```javascript + App.Blog = DS.Model.extend({ + users: DS.hasMany('user'), + owner: DS.belongsTo('user'), + + posts: DS.hasMany('post') + }); + ``` + + This property would contain the following: + + ```javascript + var relationshipsByName = Ember.get(App.Blog, 'relationshipsByName'); + relationshipsByName.get('users'); + //=> { key: 'users', kind: 'hasMany', type: App.User } + relationshipsByName.get('owner'); + //=> { key: 'owner', kind: 'belongsTo', type: App.User } + ``` + + @property relationshipsByName + @static + @type Ember.Map + @readOnly + */ + relationshipsByName: Ember.computed(function() { + var map = Ember.Map.create(), type; + + this.eachComputedProperty(function(name, meta) { + if (meta.isRelationship) { + meta.key = name; + type = meta.type; + + if (!type && meta.kind === 'hasMany') { + type = Ember.String.singularize(name); + } else if (!type) { + type = name; + } + + if (typeof type === 'string') { + meta.type = this.store.modelFor(type); + } + + map.set(name, meta); + } + }); + + return map; + }), + + /** + A map whose keys are the fields of the model and whose values are strings + describing the kind of the field. A model's fields are the union of all of its + attributes and relationships. + + For example: + + ```javascript + + App.Blog = DS.Model.extend({ + users: DS.hasMany('user'), + owner: DS.belongsTo('user'), + + posts: DS.hasMany('post'), + + title: DS.attr('string') + }); + + var fields = Ember.get(App.Blog, 'fields'); + fields.forEach(function(field, kind) { + console.log(field, kind); + }); + + // prints: + // users, hasMany + // owner, belongsTo + // posts, hasMany + // title, attribute + ``` + + @property fields + @static + @type Ember.Map + @readOnly + */ + fields: Ember.computed(function() { + var map = Ember.Map.create(); + + this.eachComputedProperty(function(name, meta) { + if (meta.isRelationship) { + map.set(name, meta.kind); + } else if (meta.isAttribute) { + map.set(name, 'attribute'); + } + }); + + return map; + }), + + /** + Given a callback, iterates over each of the relationships in the model, + invoking the callback with the name of each relationship and its relationship + descriptor. + + @method eachRelationship + @static + @param {Function} callback the callback to invoke + @param {any} binding the value to which the callback's `this` should be bound + */ + eachRelationship: function(callback, binding) { + get(this, 'relationshipsByName').forEach(function(name, relationship) { + callback.call(binding, name, relationship); + }); + }, + + /** + Given a callback, iterates over each of the types related to a model, + invoking the callback with the related type's class. Each type will be + returned just once, regardless of how many different relationships it has + with a model. + + @method eachRelatedType + @static + @param {Function} callback the callback to invoke + @param {any} binding the value to which the callback's `this` should be bound + */ + eachRelatedType: function(callback, binding) { + get(this, 'relatedTypes').forEach(function(type) { + callback.call(binding, type); + }); + } +}); + +DS.Model.reopen({ + /** + Given a callback, iterates over each of the relationships in the model, + invoking the callback with the name of each relationship and its relationship + descriptor. + + @method eachRelationship + @param {Function} callback the callback to invoke + @param {any} binding the value to which the callback's `this` should be bound + */ + eachRelationship: function(callback, binding) { + this.constructor.eachRelationship(callback, binding); + } +}); + +})(); + + + +(function() { +/** + @module ember-data +*/ + +})(); + + + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get, set = Ember.set; +var once = Ember.run.once; +var forEach = Ember.EnumerableUtils.forEach; + +/** + @class RecordArrayManager + @namespace DS + @private + @extends Ember.Object +*/ +DS.RecordArrayManager = Ember.Object.extend({ + init: function() { + this.filteredRecordArrays = Ember.MapWithDefault.create({ + defaultValue: function() { return []; } + }); + + this.changedRecords = []; + }, + + recordDidChange: function(record) { + this.changedRecords.push(record); + once(this, this.updateRecordArrays); + }, + + recordArraysForRecord: function(record) { + record._recordArrays = record._recordArrays || Ember.OrderedSet.create(); + return record._recordArrays; + }, + + /** + This method is invoked whenever data is loaded into the store by the + adapter or updated by the adapter, or when a record has changed. + + It updates all record arrays that a record belongs to. + + To avoid thrashing, it only runs at most once per run loop. + + @method updateRecordArrays + @param {Class} type + @param {Number|String} clientId + */ + updateRecordArrays: function() { + forEach(this.changedRecords, function(record) { + if (get(record, 'isDeleted')) { + this._recordWasDeleted(record); + } else { + this._recordWasChanged(record); + } + }, this); + + this.changedRecords = []; + }, + + _recordWasDeleted: function (record) { + var recordArrays = record._recordArrays; + + if (!recordArrays) { return; } + + forEach(recordArrays, function(array) { + array.removeRecord(record); + }); + }, + + _recordWasChanged: function (record) { + var type = record.constructor, + recordArrays = this.filteredRecordArrays.get(type), + filter; + + forEach(recordArrays, function(array) { + filter = get(array, 'filterFunction'); + this.updateRecordArray(array, filter, type, record); + }, this); + + // loop through all manyArrays containing an unloaded copy of this + // clientId and notify them that the record was loaded. + var manyArrays = record._loadingRecordArrays; + + if (manyArrays) { + for (var i=0, l=manyArrays.length; i 'kine' + inflector.singularize('kine') //=> 'cow' + ``` + + Creating an inflector and adding rules later. + + ```javascript + var inflector = Ember.Inflector.inflector; + + inflector.pluralize('advice') // => 'advices' + inflector.uncountable('advice'); + inflector.pluralize('advice') // => 'advice' + + inflector.pluralize('formula') // => 'formulas' + inflector.irregular('formula', 'formulae'); + inflector.pluralize('formula') // => 'formulae' + + // you would not need to add these as they are the default rules + inflector.plural(/$/, 's'); + inflector.singular(/s$/i, ''); + ``` + + Creating an inflector with a nondefault ruleset. + + ```javascript + var rules = { + plurals: [ /$/, 's' ], + singular: [ /\s$/, '' ], + irregularPairs: [ + [ 'cow', 'kine' ] + ], + uncountable: [ 'fish' ] + }; + + var inflector = new Ember.Inflector(rules); + ``` + + @class Inflector + @namespace Ember +*/ +function Inflector(ruleSet) { + ruleSet = ruleSet || {}; + ruleSet.uncountable = ruleSet.uncountable || {}; + ruleSet.irregularPairs = ruleSet.irregularPairs || {}; + + var rules = this.rules = { + plurals: ruleSet.plurals || [], + singular: ruleSet.singular || [], + irregular: {}, + irregularInverse: {}, + uncountable: {} + }; + + loadUncountable(rules, ruleSet.uncountable); + loadIrregular(rules, ruleSet.irregularPairs); +} + +Inflector.prototype = { + /** + @method plural + @param {RegExp} regex + @param {String} string + */ + plural: function(regex, string) { + this.rules.plurals.push([regex, string.toLowerCase()]); + }, + + /** + @method singular + @param {RegExp} regex + @param {String} string + */ + singular: function(regex, string) { + this.rules.singular.push([regex, string.toLowerCase()]); + }, + + /** + @method uncountable + @param {String} regex + */ + uncountable: function(string) { + loadUncountable(this.rules, [string.toLowerCase()]); + }, + + /** + @method irregular + @param {String} singular + @param {String} plural + */ + irregular: function (singular, plural) { + loadIrregular(this.rules, [[singular, plural]]); + }, + + /** + @method pluralize + @param {String} word + */ + pluralize: function(word) { + return this.inflect(word, this.rules.plurals, this.rules.irregular); + }, + + /** + @method singularize + @param {String} word + */ + singularize: function(word) { + return this.inflect(word, this.rules.singular, this.rules.irregularInverse); + }, + + /** + @protected + + @method inflect + @param {String} word + @param {Object} typeRules + @param {Object} irregular + */ + inflect: function(word, typeRules, irregular) { + var inflection, substitution, result, lowercase, isBlank, + isUncountable, isIrregular, isIrregularInverse, rule; + + isBlank = BLANK_REGEX.test(word); + + if (isBlank) { + return word; + } + + lowercase = word.toLowerCase(); + + isUncountable = this.rules.uncountable[lowercase]; + + if (isUncountable) { + return word; + } + + isIrregular = irregular && irregular[lowercase]; + + if (isIrregular) { + return isIrregular; + } + + for (var i = typeRules.length, min = 0; i > min; i--) { + inflection = typeRules[i-1]; + rule = inflection[0]; + + if (rule.test(word)) { + break; + } + } + + inflection = inflection || []; + + rule = inflection[0]; + substitution = inflection[1]; + + result = word.replace(rule, substitution); + + return result; + } +}; + +Ember.Inflector = Inflector; + +})(); + + + +(function() { +Ember.Inflector.defaultRules = { + plurals: [ + [/$/, 's'], + [/s$/i, 's'], + [/^(ax|test)is$/i, '$1es'], + [/(octop|vir)us$/i, '$1i'], + [/(octop|vir)i$/i, '$1i'], + [/(alias|status)$/i, '$1es'], + [/(bu)s$/i, '$1ses'], + [/(buffal|tomat)o$/i, '$1oes'], + [/([ti])um$/i, '$1a'], + [/([ti])a$/i, '$1a'], + [/sis$/i, 'ses'], + [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], + [/(hive)$/i, '$1s'], + [/([^aeiouy]|qu)y$/i, '$1ies'], + [/(x|ch|ss|sh)$/i, '$1es'], + [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], + [/^(m|l)ouse$/i, '$1ice'], + [/^(m|l)ice$/i, '$1ice'], + [/^(ox)$/i, '$1en'], + [/^(oxen)$/i, '$1'], + [/(quiz)$/i, '$1zes'] + ], + + singular: [ + [/s$/i, ''], + [/(ss)$/i, '$1'], + [/(n)ews$/i, '$1ews'], + [/([ti])a$/i, '$1um'], + [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], + [/(^analy)(sis|ses)$/i, '$1sis'], + [/([^f])ves$/i, '$1fe'], + [/(hive)s$/i, '$1'], + [/(tive)s$/i, '$1'], + [/([lr])ves$/i, '$1f'], + [/([^aeiouy]|qu)ies$/i, '$1y'], + [/(s)eries$/i, '$1eries'], + [/(m)ovies$/i, '$1ovie'], + [/(x|ch|ss|sh)es$/i, '$1'], + [/^(m|l)ice$/i, '$1ouse'], + [/(bus)(es)?$/i, '$1'], + [/(o)es$/i, '$1'], + [/(shoe)s$/i, '$1'], + [/(cris|test)(is|es)$/i, '$1is'], + [/^(a)x[ie]s$/i, '$1xis'], + [/(octop|vir)(us|i)$/i, '$1us'], + [/(alias|status)(es)?$/i, '$1'], + [/^(ox)en/i, '$1'], + [/(vert|ind)ices$/i, '$1ex'], + [/(matr)ices$/i, '$1ix'], + [/(quiz)zes$/i, '$1'], + [/(database)s$/i, '$1'] + ], + + irregularPairs: [ + ['person', 'people'], + ['man', 'men'], + ['child', 'children'], + ['sex', 'sexes'], + ['move', 'moves'], + ['cow', 'kine'], + ['zombie', 'zombies'] + ], + + uncountable: [ + 'equipment', + 'information', + 'rice', + 'money', + 'species', + 'series', + 'fish', + 'sheep', + 'jeans', + 'police' + ] +}; + +})(); + + + +(function() { +if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { + /** + See {{#crossLink "Ember.String/pluralize"}}{{/crossLink}} + + @method pluralize + @for String + */ + String.prototype.pluralize = function() { + return Ember.String.pluralize(this); + }; + + /** + See {{#crossLink "Ember.String/singularize"}}{{/crossLink}} + + @method singularize + @for String + */ + String.prototype.singularize = function() { + return Ember.String.singularize(this); + }; +} + +})(); + + + +(function() { +Ember.Inflector.inflector = new Ember.Inflector(Ember.Inflector.defaultRules); + +})(); + + + +(function() { + +})(); + +(function() { +/** + @module ember-data +*/ + +var get = Ember.get; +var forEach = Ember.EnumerableUtils.forEach; + +DS.ActiveModelSerializer = DS.RESTSerializer.extend({ + // SERIALIZE + + /** + Converts camelcased attributes to underscored when serializing. + + @method keyForAttribute + @param {String} attribute + @returns String + */ + keyForAttribute: function(attr) { + return Ember.String.decamelize(attr); + }, + + /** + Underscores relationship names and appends "_id" or "_ids" when serializing + relationship keys. + + @method keyForRelationship + @param {String} key + @param {String} kind + @returns String + */ + keyForRelationship: function(key, kind) { + key = Ember.String.decamelize(key); + if (kind === "belongsTo") { + return key + "_id"; + } else if (kind === "hasMany") { + return Ember.String.singularize(key) + "_ids"; + } else { + return key; + } + }, + + /** + Does not serialize hasMany relationships by default. + */ + serializeHasMany: Ember.K, + + /** + Underscores the JSON root keys when serializing. + + @method serializeIntoHash + @param {Object} hash + @param {subclass of DS.Model} type + @param {DS.Model} record + @param {Object} options + */ + serializeIntoHash: function(data, type, record, options) { + var root = Ember.String.decamelize(type.typeKey); + data[root] = this.serialize(record, options); + }, + + /** + Serializes a polymorphic type as a fully capitalized model name. + + @method serializePolymorphicType + @param {DS.Model} record + @param {Object} json + @param relationship + */ + serializePolymorphicType: function(record, json, relationship) { + var key = relationship.key, + belongsTo = get(record, key); + key = this.keyForAttribute(key); + json[key + "_type"] = Ember.String.capitalize(belongsTo.constructor.typeKey); + }, + + // EXTRACT + + /** + Extracts the model typeKey from underscored root objects. + + @method typeForRoot + @param {String} root + @returns String the model's typeKey + */ + typeForRoot: function(root) { + var camelized = Ember.String.camelize(root); + return Ember.String.singularize(camelized); + }, + + /** + Add extra step to `DS.RESTSerializer.normalize` so links are + normalized. + + If your payload looks like this + + ```js + { + "post": { + "id": 1, + "title": "Rails is omakase", + "links": { "flagged_comments": "api/comments/flagged" } + } + } + ``` + The normalized version would look like this + + ```js + { + "post": { + "id": 1, + "title": "Rails is omakase", + "links": { "flaggedComments": "api/comments/flagged" } + } + } + ``` + + @method normalize + @param {subclass of DS.Model} type + @param {Object} hash + @param {String} prop + @returns Object + */ + + normalize: function(type, hash, prop) { + this.normalizeLinks(hash); + + return this._super(type, hash, prop); + }, + + /** + Convert `snake_cased` links to `camelCase` + + @method normalizeLinks + @param {Object} hash + */ + + normalizeLinks: function(data){ + if (data.links) { + var links = data.links; + + for (var link in links) { + var camelizedLink = Ember.String.camelize(link); + + if (camelizedLink !== link) { + links[camelizedLink] = links[link]; + delete links[link]; + } + } + } + }, + + /** + Normalize the polymorphic type from the JSON. + + Normalize: + ```js + { + id: "1" + minion: { type: "evil_minion", id: "12"} + } + ``` + + To: + ```js + { + id: "1" + minion: { type: "evilMinion", id: "12"} + } + ``` + + @method normalizeRelationships + @private + */ + normalizeRelationships: function(type, hash) { + var payloadKey, payload; + + if (this.keyForRelationship) { + type.eachRelationship(function(key, relationship) { + if (relationship.options.polymorphic) { + payloadKey = this.keyForAttribute(key); + payload = hash[payloadKey]; + if (payload && payload.type) { + payload.type = this.typeForRoot(payload.type); + } else if (payload && relationship.kind === "hasMany") { + var self = this; + forEach(payload, function(single) { + single.type = self.typeForRoot(single.type); + }); + } + } else { + payloadKey = this.keyForRelationship(key, relationship.kind); + payload = hash[payloadKey]; + } + + hash[key] = payload; + + if (key !== payloadKey) { + delete hash[payloadKey]; + } + }, this); + } + } +}); + +})(); + + + +(function() { +var get = Ember.get; +var forEach = Ember.EnumerableUtils.forEach; + +/** + The EmbeddedRecordsMixin allows you to add embedded record support to your + serializers. + To set up embedded records, you include the mixin into the serializer and then + define your embedded relations. + + ```js + App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, { + attrs: { + comments: {embedded: 'always'} + } + }) + ``` + + Currently only `{embedded: 'always'}` records are supported. + + @class EmbeddedRecordsMixin + @namespace DS +*/ +DS.EmbeddedRecordsMixin = Ember.Mixin.create({ + + /** + Serialize has-may relationship when it is configured as embedded objects. + + @method serializeHasMany + */ + serializeHasMany: function(record, json, relationship) { + var key = relationship.key, + attrs = get(this, 'attrs'), + embed = attrs && attrs[key] && attrs[key].embedded === 'always'; + + if (embed) { + json[this.keyForAttribute(key)] = get(record, key).map(function(relation) { + var data = relation.serialize(), + primaryKey = get(this, 'primaryKey'); + + data[primaryKey] = get(relation, primaryKey); + + return data; + }, this); + } + }, + + /** + Extract embedded objects out of the payload for a single object + and add them as sideloaded objects instead. + + @method extractSingle + */ + extractSingle: function(store, primaryType, payload, recordId, requestType) { + var root = this.keyForAttribute(primaryType.typeKey), + partial = payload[root]; + + updatePayloadWithEmbedded(store, this, primaryType, partial, payload); + + return this._super(store, primaryType, payload, recordId, requestType); + }, + + /** + Extract embedded objects out of a standard payload + and add them as sideloaded objects instead. + + @method extractArray + */ + extractArray: function(store, type, payload) { + var root = this.keyForAttribute(type.typeKey), + partials = payload[Ember.String.pluralize(root)]; + + forEach(partials, function(partial) { + updatePayloadWithEmbedded(store, this, type, partial, payload); + }, this); + + return this._super(store, type, payload); + } +}); + +function updatePayloadWithEmbedded(store, serializer, type, partial, payload) { + var attrs = get(serializer, 'attrs'); + + if (!attrs) { + return; + } + + type.eachRelationship(function(key, relationship) { + var expandedKey, embeddedTypeKey, attribute, ids, + config = attrs[key], + serializer = store.serializerFor(relationship.type.typeKey), + primaryKey = get(serializer, "primaryKey"); + + if (relationship.kind !== "hasMany") { + return; + } + + if (config && (config.embedded === 'always' || config.embedded === 'load')) { + // underscore forces the embedded records to be side loaded. + // it is needed when main type === relationship.type + embeddedTypeKey = '_' + Ember.String.pluralize(relationship.type.typeKey); + expandedKey = this.keyForRelationship(key, relationship.kind); + attribute = this.keyForAttribute(key); + ids = []; + + if (!partial[attribute]) { + return; + } + + payload[embeddedTypeKey] = payload[embeddedTypeKey] || []; + + forEach(partial[attribute], function(data) { + var embeddedType = store.modelFor(relationship.type.typeKey); + updatePayloadWithEmbedded(store, serializer, embeddedType, data, payload); + ids.push(data[primaryKey]); + payload[embeddedTypeKey].push(data); + }); + + partial[expandedKey] = ids; + delete partial[attribute]; + } + }, serializer); +} +})(); + + + +(function() { +/** + @module ember-data +*/ + +var forEach = Ember.EnumerableUtils.forEach; + +/** + The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate + with a JSON API that uses an underscored naming convention instead of camelcasing. + It has been designed to work out of the box with the + [active_model_serializers](http://github.com/rails-api/active_model_serializers) + Ruby gem. + + This adapter extends the DS.RESTAdapter by making consistent use of the camelization, + decamelization and pluralization methods to normalize the serialized JSON into a + format that is compatible with a conventional Rails backend and Ember Data. + + ## JSON Structure + + The ActiveModelAdapter expects the JSON returned from your server to follow + the REST adapter conventions substituting underscored keys for camelcased ones. + + ### Conventional Names + + Attribute names in your JSON payload should be the underscored versions of + the attributes in your Ember.js models. + + For example, if you have a `Person` model: + + ```js + App.FamousPerson = DS.Model.extend({ + firstName: DS.attr('string'), + lastName: DS.attr('string'), + occupation: DS.attr('string') + }); + ``` + + The JSON returned should look like this: + + ```js + { + "famous_person": { + "first_name": "Barack", + "last_name": "Obama", + "occupation": "President" + } + } + ``` + + @class ActiveModelAdapter + @constructor + @namespace DS + @extends DS.Adapter +**/ + +DS.ActiveModelAdapter = DS.RESTAdapter.extend({ + defaultSerializer: '_ams', + /** + The ActiveModelAdapter overrides the `pathForType` method to build + underscored URLs by decamelizing and pluralizing the object type name. + + ```js + this.pathForType("famousPerson"); + //=> "famous_people" + ``` + + @method pathForType + @param {String} type + @returns String + */ + pathForType: function(type) { + var decamelized = Ember.String.decamelize(type); + return Ember.String.pluralize(decamelized); + }, + + /** + The ActiveModelAdapter overrides the `ajaxError` method + to return a DS.InvalidError for all 422 Unprocessable Entity + responses. + + A 422 HTTP response from the server generally implies that the request + was well formed but the API was unable to process it because the + content was not semantically correct or meaningful per the API. + + For more information on 422 HTTP Error code see 11.2 WebDAV RFC 4918 + https://tools.ietf.org/html/rfc4918#section-11.2 + + @method ajaxError + @param jqXHR + @returns error + */ + ajaxError: function(jqXHR) { + var error = this._super(jqXHR); + + if (jqXHR && jqXHR.status === 422) { + var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"], + errors = {}; + + forEach(Ember.keys(jsonErrors), function(key) { + errors[Ember.String.camelize(key)] = jsonErrors[key]; + }); + + return new DS.InvalidError(errors); + } else { + return error; + } + } +}); + +})(); + + + +(function() { + +})(); + + + +(function() { +Ember.onLoad('Ember.Application', function(Application) { + Application.initializer({ + name: "activeModelAdapter", + + initialize: function(container, application) { + application.register('serializer:_ams', DS.ActiveModelSerializer); + application.register('adapter:_ams', DS.ActiveModelAdapter); + } + }); +}); + +})(); + + + +(function() { + +})(); + + +})(); diff --git a/handling-spring-static-resources/src/main/webapp/js/ember.js b/handling-spring-static-resources/src/main/webapp/js/ember.js new file mode 100644 index 000000000000..44c4687e4a96 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/ember.js @@ -0,0 +1,47755 @@ +/*! + * @overview Ember - JavaScript Application Framework + * @copyright Copyright 2011-2014 Tilde Inc. and contributors + * Portions Copyright 2006-2011 Strobe Inc. + * Portions Copyright 2008-2011 Apple Inc. All rights reserved. + * @license Licensed under MIT license + * See https://raw.github.com/emberjs/ember.js/master/LICENSE + * @version 1.7.0 + */ + +(function() { +var define, requireModule, require, requirejs, Ember; + +(function() { + Ember = this.Ember = this.Ember || {}; + if (typeof Ember === 'undefined') { Ember = {} }; + + if (typeof Ember.__loader === 'undefined') { + var registry = {}, seen = {}; + + define = function(name, deps, callback) { + registry[name] = { deps: deps, callback: callback }; + }; + + requirejs = require = requireModule = function(name) { + if (seen.hasOwnProperty(name)) { return seen[name]; } + seen[name] = {}; + + if (!registry[name]) { + throw new Error("Could not find module " + name); + } + + var mod = registry[name], + deps = mod.deps, + callback = mod.callback, + reified = [], + exports; + + for (var i=0, l=deps.length; i 3 ? slice.call(arguments, 3) : undefined; + if (!this.currentInstance) { createAutorun(this); } + return this.currentInstance.schedule(queueName, target, method, args, false, stack); + }, + + deferOnce: function(queueName, target, method /* , args */) { + if (!method) { + method = target; + target = null; + } + + if (isString(method)) { + method = target[method]; + } + + var stack = this.DEBUG ? new Error() : undefined, + args = arguments.length > 3 ? slice.call(arguments, 3) : undefined; + if (!this.currentInstance) { createAutorun(this); } + return this.currentInstance.schedule(queueName, target, method, args, true, stack); + }, + + setTimeout: function() { + var args = slice.call(arguments), + length = args.length, + method, wait, target, + methodOrTarget, methodOrWait, methodOrArgs; + + if (length === 0) { + return; + } else if (length === 1) { + method = args.shift(); + wait = 0; + } else if (length === 2) { + methodOrTarget = args[0]; + methodOrWait = args[1]; + + if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { + target = args.shift(); + method = args.shift(); + wait = 0; + } else if (isCoercableNumber(methodOrWait)) { + method = args.shift(); + wait = args.shift(); + } else { + method = args.shift(); + wait = 0; + } + } else { + var last = args[args.length - 1]; + + if (isCoercableNumber(last)) { + wait = args.pop(); + } else { + wait = 0; + } + + methodOrTarget = args[0]; + methodOrArgs = args[1]; + + if (isFunction(methodOrArgs) || (isString(methodOrArgs) && + methodOrTarget !== null && + methodOrArgs in methodOrTarget)) { + target = args.shift(); + method = args.shift(); + } else { + method = args.shift(); + } + } + + var executeAt = (+new Date()) + parseInt(wait, 10); + + if (isString(method)) { + method = target[method]; + } + + var onError = getOnError(this.options); + + function fn() { + if (onError) { + try { + method.apply(target, args); + } catch (e) { + onError(e); + } + } else { + method.apply(target, args); + } + } + + // find position to insert + var i = searchTimer(executeAt, timers); + + timers.splice(i, 0, executeAt, fn); + + updateLaterTimer(this, executeAt, wait); + + return fn; + }, + + throttle: function(target, method /* , args, wait, [immediate] */) { + var self = this, + args = arguments, + immediate = pop.call(args), + wait, + throttler, + index, + timer; + + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = true; + } else { + wait = pop.call(args); + } + + wait = parseInt(wait, 10); + + index = findThrottler(target, method, this._throttlers); + if (index > -1) { return this._throttlers[index]; } // throttled + + timer = global.setTimeout(function() { + if (!immediate) { + self.run.apply(self, args); + } + var index = findThrottler(target, method, self._throttlers); + if (index > -1) { + self._throttlers.splice(index, 1); + } + }, wait); + + if (immediate) { + self.run.apply(self, args); + } + + throttler = [target, method, timer]; + + this._throttlers.push(throttler); + + return throttler; + }, + + debounce: function(target, method /* , args, wait, [immediate] */) { + var self = this, + args = arguments, + immediate = pop.call(args), + wait, + index, + debouncee, + timer; + + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = false; + } else { + wait = pop.call(args); + } + + wait = parseInt(wait, 10); + // Remove debouncee + index = findDebouncee(target, method, this._debouncees); + + if (index > -1) { + debouncee = this._debouncees[index]; + this._debouncees.splice(index, 1); + clearTimeout(debouncee[2]); + } + + timer = global.setTimeout(function() { + if (!immediate) { + self.run.apply(self, args); + } + var index = findDebouncee(target, method, self._debouncees); + if (index > -1) { + self._debouncees.splice(index, 1); + } + }, wait); + + if (immediate && index === -1) { + self.run.apply(self, args); + } + + debouncee = [target, method, timer]; + + self._debouncees.push(debouncee); + + return debouncee; + }, + + cancelTimers: function() { + var clearItems = function(item) { + clearTimeout(item[2]); + }; + + each(this._throttlers, clearItems); + this._throttlers = []; + + each(this._debouncees, clearItems); + this._debouncees = []; + + if (this._laterTimer) { + clearTimeout(this._laterTimer); + this._laterTimer = null; + } + timers = []; + + if (this._autorun) { + clearTimeout(this._autorun); + this._autorun = null; + } + }, + + hasTimers: function() { + return !!timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; + }, + + cancel: function(timer) { + var timerType = typeof timer; + + if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce + return timer.queue.cancel(timer); + } else if (timerType === 'function') { // we're cancelling a setTimeout + for (var i = 0, l = timers.length; i < l; i += 2) { + if (timers[i + 1] === timer) { + timers.splice(i, 2); // remove the two elements + return true; + } + } + } else if (Object.prototype.toString.call(timer) === "[object Array]"){ // we're cancelling a throttle or debounce + return this._cancelItem(findThrottler, this._throttlers, timer) || + this._cancelItem(findDebouncee, this._debouncees, timer); + } else { + return; // timer was null or not a timer + } + }, + + _cancelItem: function(findMethod, array, timer){ + var item, + index; + + if (timer.length < 3) { return false; } + + index = findMethod(timer[0], timer[1], array); + + if(index > -1) { + + item = array[index]; + + if(item[2] === timer[2]){ + array.splice(index, 1); + clearTimeout(timer[2]); + return true; + } + } + + return false; + } + }; + + Backburner.prototype.schedule = Backburner.prototype.defer; + Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; + Backburner.prototype.later = Backburner.prototype.setTimeout; + + if (needsIETryCatchFix) { + var originalRun = Backburner.prototype.run; + Backburner.prototype.run = wrapInTryCatch(originalRun); + + var originalEnd = Backburner.prototype.end; + Backburner.prototype.end = wrapInTryCatch(originalEnd); + } + + function wrapInTryCatch(func) { + return function () { + try { + return func.apply(this, arguments); + } catch (e) { + throw e; + } + }; + } + + function getOnError(options) { + return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); + } + + + function createAutorun(backburner) { + backburner.begin(); + backburner._autorun = global.setTimeout(function() { + backburner._autorun = null; + backburner.end(); + }); + } + + function updateLaterTimer(self, executeAt, wait) { + if (!self._laterTimer || executeAt < self._laterTimerExpiresAt) { + self._laterTimer = global.setTimeout(function() { + self._laterTimer = null; + self._laterTimerExpiresAt = null; + executeTimers(self); + }, wait); + self._laterTimerExpiresAt = executeAt; + } + } + + function executeTimers(self) { + var now = +new Date(), + time, fns, i, l; + + self.run(function() { + i = searchTimer(now, timers); + + fns = timers.splice(0, i); + + for (i = 1, l = fns.length; i < l; i += 2) { + self.schedule(self.options.defaultQueue, null, fns[i]); + } + }); + + if (timers.length) { + updateLaterTimer(self, timers[0], timers[0] - now); + } + } + + function findDebouncee(target, method, debouncees) { + return findItem(target, method, debouncees); + } + + function findThrottler(target, method, throttlers) { + return findItem(target, method, throttlers); + } + + function findItem(target, method, collection) { + var item, + index = -1; + + for (var i = 0, l = collection.length; i < l; i++) { + item = collection[i]; + if (item[0] === target && item[1] === method) { + index = i; + break; + } + } + + return index; + } + + function searchTimer(time, timers) { + var start = 0, + end = timers.length - 2, + middle, l; + + while (start < end) { + // since timers is an array of pairs 'l' will always + // be an integer + l = (end - start) / 2; + + // compensate for the index in case even number + // of pairs inside timers + middle = start + l - (l % 2); + + if (time >= timers[middle]) { + start = middle + 2; + } else { + end = middle; + } + } + + return (time >= timers[start]) ? start + 2 : start; + } + + __exports__.Backburner = Backburner; + }); +define("backburner/deferred_action_queues", + ["backburner/utils","backburner/queue","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var Utils = __dependency1__["default"]; + var Queue = __dependency2__.Queue; + + var each = Utils.each, + isString = Utils.isString; + + function DeferredActionQueues(queueNames, options) { + var queues = this.queues = {}; + this.queueNames = queueNames = queueNames || []; + + this.options = options; + + each(queueNames, function(queueName) { + queues[queueName] = new Queue(this, queueName, options); + }); + } + + DeferredActionQueues.prototype = { + queueNames: null, + queues: null, + options: null, + + schedule: function(queueName, target, method, args, onceFlag, stack) { + var queues = this.queues, + queue = queues[queueName]; + + if (!queue) { throw new Error("You attempted to schedule an action in a queue (" + queueName + ") that doesn't exist"); } + + if (onceFlag) { + return queue.pushUnique(target, method, args, stack); + } else { + return queue.push(target, method, args, stack); + } + }, + + invoke: function(target, method, args, _) { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + }, + + invokeWithOnError: function(target, method, args, onError) { + try { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + } catch(error) { + onError(error); + } + }, + + flush: function() { + var queues = this.queues, + queueNames = this.queueNames, + queueName, queue, queueItems, priorQueueNameIndex, + queueNameIndex = 0, numberOfQueues = queueNames.length, + options = this.options, + onError = options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]), + invoke = onError ? this.invokeWithOnError : this.invoke; + + outerloop: + while (queueNameIndex < numberOfQueues) { + queueName = queueNames[queueNameIndex]; + queue = queues[queueName]; + queueItems = queue._queueBeingFlushed = queue._queue.slice(); + queue._queue = []; + + var queueOptions = queue.options, // TODO: write a test for this + before = queueOptions && queueOptions.before, + after = queueOptions && queueOptions.after, + target, method, args, stack, + queueIndex = 0, numberOfQueueItems = queueItems.length; + + if (numberOfQueueItems && before) { before(); } + + while (queueIndex < numberOfQueueItems) { + target = queueItems[queueIndex]; + method = queueItems[queueIndex+1]; + args = queueItems[queueIndex+2]; + stack = queueItems[queueIndex+3]; // Debugging assistance + + if (isString(method)) { method = target[method]; } + + // method could have been nullified / canceled during flush + if (method) { + invoke(target, method, args, onError); + } + + queueIndex += 4; + } + + queue._queueBeingFlushed = null; + if (numberOfQueueItems && after) { after(); } + + if ((priorQueueNameIndex = indexOfPriorQueueWithActions(this, queueNameIndex)) !== -1) { + queueNameIndex = priorQueueNameIndex; + continue outerloop; + } + + queueNameIndex++; + } + } + }; + + function indexOfPriorQueueWithActions(daq, currentQueueIndex) { + var queueName, queue; + + for (var i = 0, l = currentQueueIndex; i <= l; i++) { + queueName = daq.queueNames[i]; + queue = daq.queues[queueName]; + if (queue._queue.length) { return i; } + } + + return -1; + } + + __exports__.DeferredActionQueues = DeferredActionQueues; + }); +define("backburner/queue", + ["exports"], + function(__exports__) { + "use strict"; + function Queue(daq, name, options) { + this.daq = daq; + this.name = name; + this.globalOptions = options; + this.options = options[name]; + this._queue = []; + } + + Queue.prototype = { + daq: null, + name: null, + options: null, + onError: null, + _queue: null, + + push: function(target, method, args, stack) { + var queue = this._queue; + queue.push(target, method, args, stack); + return {queue: this, target: target, method: method}; + }, + + pushUnique: function(target, method, args, stack) { + var queue = this._queue, currentTarget, currentMethod, i, l; + + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; + + if (currentTarget === target && currentMethod === method) { + queue[i+2] = args; // replace args + queue[i+3] = stack; // replace stack + return {queue: this, target: target, method: method}; + } + } + + queue.push(target, method, args, stack); + return {queue: this, target: target, method: method}; + }, + + // TODO: remove me, only being used for Ember.run.sync + flush: function() { + var queue = this._queue, + globalOptions = this.globalOptions, + options = this.options, + before = options && options.before, + after = options && options.after, + onError = globalOptions.onError || (globalOptions.onErrorTarget && globalOptions.onErrorTarget[globalOptions.onErrorMethod]), + target, method, args, stack, i, l = queue.length; + + if (l && before) { before(); } + for (i = 0; i < l; i += 4) { + target = queue[i]; + method = queue[i+1]; + args = queue[i+2]; + stack = queue[i+3]; // Debugging assistance + + // TODO: error handling + if (args && args.length > 0) { + if (onError) { + try { + method.apply(target, args); + } catch (e) { + onError(e); + } + } else { + method.apply(target, args); + } + } else { + if (onError) { + try { + method.call(target); + } catch(e) { + onError(e); + } + } else { + method.call(target); + } + } + } + if (l && after) { after(); } + + // check if new items have been added + if (queue.length > l) { + this._queue = queue.slice(l); + this.flush(); + } else { + this._queue.length = 0; + } + }, + + cancel: function(actionToCancel) { + var queue = this._queue, currentTarget, currentMethod, i, l; + + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; + + if (currentTarget === actionToCancel.target && currentMethod === actionToCancel.method) { + queue.splice(i, 4); + return true; + } + } + + // if not found in current queue + // could be in the queue that is being flushed + queue = this._queueBeingFlushed; + if (!queue) { + return; + } + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; + + if (currentTarget === actionToCancel.target && currentMethod === actionToCancel.method) { + // don't mess with array during flush + // just nullify the method + queue[i+1] = null; + return true; + } + } + } + }; + + __exports__.Queue = Queue; + }); +define("backburner/utils", + ["exports"], + function(__exports__) { + "use strict"; + __exports__["default"] = { + each: function(collection, callback) { + for (var i = 0; i < collection.length; i++) { + callback(collection[i]); + } + }, + + isString: function(suspect) { + return typeof suspect === 'string'; + }, + + isFunction: function(suspect) { + return typeof suspect === 'function'; + }, + + isNumber: function(suspect) { + return typeof suspect === 'number'; + } + }; + }); + +define("calculateVersion", + [], + function() { + "use strict"; + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + + module.exports = function () { + var packageVersion = require('../package.json').version; + var output = [packageVersion]; + var gitPath = path.join(__dirname,'..','.git'); + var headFilePath = path.join(gitPath, 'HEAD'); + + if (packageVersion.indexOf('+') > -1) { + try { + if (fs.existsSync(headFilePath)) { + var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'}); + var branchName = headFile.split('/').slice(-1)[0].trim(); + var refPath = headFile.split(' ')[1]; + var branchSHA; + + if (refPath) { + var branchPath = path.join(gitPath, refPath.trim()); + branchSHA = fs.readFileSync(branchPath); + } else { + branchSHA = branchName; + } + + output.push(branchSHA.slice(0,10)); + } + } catch (err) { + console.error(err.stack); + } + return output.join('.'); + } else { + return packageVersion; + } + }; + }); +define("container", + ["container/container","exports"], + function(__dependency1__, __exports__) { + "use strict"; + /* + Public api for the container is still in flux. + The public api, specified on the application namespace should be considered the stable api. + // @module container + @private + */ + + /* + Flag to enable/disable model factory injections (disabled by default) + If model factory injections are enabled, models should not be + accessed globally (only through `container.lookupFactory('model:modelName'))`); + */ + Ember.MODEL_FACTORY_INJECTIONS = false; + + if (Ember.ENV && typeof Ember.ENV.MODEL_FACTORY_INJECTIONS !== 'undefined') { + Ember.MODEL_FACTORY_INJECTIONS = !!Ember.ENV.MODEL_FACTORY_INJECTIONS; + } + + + var Container = __dependency1__["default"]; + + __exports__["default"] = Container; + }); +define("container/container", + ["container/inheriting_dict","ember-metal/core","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var InheritingDict = __dependency1__["default"]; + var Ember = __dependency2__["default"]; + // Ember.assert + + // A lightweight container that helps to assemble and decouple components. + // Public api for the container is still in flux. + // The public api, specified on the application namespace should be considered the stable api. + function Container(parent) { + this.parent = parent; + this.children = []; + + this.resolver = parent && parent.resolver || function() {}; + + this.registry = new InheritingDict(parent && parent.registry); + this.cache = new InheritingDict(parent && parent.cache); + this.factoryCache = new InheritingDict(parent && parent.factoryCache); + this.resolveCache = new InheritingDict(parent && parent.resolveCache); + this.typeInjections = new InheritingDict(parent && parent.typeInjections); + this.injections = {}; + + this.factoryTypeInjections = new InheritingDict(parent && parent.factoryTypeInjections); + this.factoryInjections = {}; + + this._options = new InheritingDict(parent && parent._options); + this._typeOptions = new InheritingDict(parent && parent._typeOptions); + } + + Container.prototype = { + + /** + @property parent + @type Container + @default null + */ + parent: null, + + /** + @property children + @type Array + @default [] + */ + children: null, + + /** + @property resolver + @type function + */ + resolver: null, + + /** + @property registry + @type InheritingDict + */ + registry: null, + + /** + @property cache + @type InheritingDict + */ + cache: null, + + /** + @property typeInjections + @type InheritingDict + */ + typeInjections: null, + + /** + @property injections + @type Object + @default {} + */ + injections: null, + + /** + @private + + @property _options + @type InheritingDict + @default null + */ + _options: null, + + /** + @private + + @property _typeOptions + @type InheritingDict + */ + _typeOptions: null, + + /** + Returns a new child of the current container. These children are configured + to correctly inherit from the current container. + + @method child + @return {Container} + */ + child: function() { + var container = new Container(this); + this.children.push(container); + return container; + }, + + /** + Sets a key-value pair on the current container. If a parent container, + has the same key, once set on a child, the parent and child will diverge + as expected. + + @method set + @param {Object} object + @param {String} key + @param {any} value + */ + set: function(object, key, value) { + object[key] = value; + }, + + /** + Registers a factory for later injection. + + Example: + + ```javascript + var container = new Container(); + + container.register('model:user', Person, {singleton: false }); + container.register('fruit:favorite', Orange); + container.register('communication:main', Email, {singleton: false}); + ``` + + @method register + @param {String} fullName + @param {Function} factory + @param {Object} options + */ + register: function(fullName, factory, options) { + + if (factory === undefined) { + throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`'); + } + + var normalizedName = this.normalize(fullName); + + if (this.cache.has(normalizedName)) { + throw new Error('Cannot re-register: `' + fullName +'`, as it has already been looked up.'); + } + + this.registry.set(normalizedName, factory); + this._options.set(normalizedName, options || {}); + }, + + /** + Unregister a fullName + + ```javascript + var container = new Container(); + container.register('model:user', User); + + container.lookup('model:user') instanceof User //=> true + + container.unregister('model:user') + container.lookup('model:user') === undefined //=> true + ``` + + @method unregister + @param {String} fullName + */ + unregister: function(fullName) { + + var normalizedName = this.normalize(fullName); + + this.registry.remove(normalizedName); + this.cache.remove(normalizedName); + this.factoryCache.remove(normalizedName); + this.resolveCache.remove(normalizedName); + this._options.remove(normalizedName); + }, + + /** + Given a fullName return the corresponding factory. + + By default `resolve` will retrieve the factory from + its container's registry. + + ```javascript + var container = new Container(); + container.register('api:twitter', Twitter); + + container.resolve('api:twitter') // => Twitter + ``` + + Optionally the container can be provided with a custom resolver. + If provided, `resolve` will first provide the custom resolver + the opportunity to resolve the fullName, otherwise it will fallback + to the registry. + + ```javascript + var container = new Container(); + container.resolver = function(fullName) { + // lookup via the module system of choice + }; + + // the twitter factory is added to the module system + container.resolve('api:twitter') // => Twitter + ``` + + @method resolve + @param {String} fullName + @return {Function} fullName's factory + */ + resolve: function(fullName) { + return resolve(this, this.normalize(fullName)); + }, + + /** + A hook that can be used to describe how the resolver will + attempt to find the factory. + + For example, the default Ember `.describe` returns the full + class name (including namespace) where Ember's resolver expects + to find the `fullName`. + + @method describe + @param {String} fullName + @return {string} described fullName + */ + describe: function(fullName) { + return fullName; + }, + + /** + A hook to enable custom fullName normalization behaviour + + @method normalize + @param {String} fullName + @return {string} normalized fullName + */ + normalize: function(fullName) { + return fullName; + }, + + /** + @method makeToString + + @param {any} factory + @param {string} fullName + @return {function} toString function + */ + makeToString: function(factory, fullName) { + return factory.toString(); + }, + + /** + Given a fullName return a corresponding instance. + + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + + ```javascript + var container = new Container(); + container.register('api:twitter', Twitter); + + var twitter = container.lookup('api:twitter'); + + twitter instanceof Twitter; // => true + + // by default the container will return singletons + var twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + + twitter === twitter2; //=> true + ``` + + If singletons are not wanted an optional flag can be provided at lookup. + + ```javascript + var container = new Container(); + container.register('api:twitter', Twitter); + + var twitter = container.lookup('api:twitter', { singleton: false }); + var twitter2 = container.lookup('api:twitter', { singleton: false }); + + twitter === twitter2; //=> false + ``` + + @method lookup + @param {String} fullName + @param {Object} options + @return {any} + */ + lookup: function(fullName, options) { + return lookup(this, this.normalize(fullName), options); + }, + + /** + Given a fullName return the corresponding factory. + + @method lookupFactory + @param {String} fullName + @return {any} + */ + lookupFactory: function(fullName) { + return factoryFor(this, this.normalize(fullName)); + }, + + /** + Given a fullName check if the container is aware of its factory + or singleton instance. + + @method has + @param {String} fullName + @return {Boolean} + */ + has: function(fullName) { + return has(this, this.normalize(fullName)); + }, + + /** + Allow registering options for all factories of a type. + + ```javascript + var container = new Container(); + + // if all of type `connection` must not be singletons + container.optionsForType('connection', { singleton: false }); + + container.register('connection:twitter', TwitterConnection); + container.register('connection:facebook', FacebookConnection); + + var twitter = container.lookup('connection:twitter'); + var twitter2 = container.lookup('connection:twitter'); + + twitter === twitter2; // => false + + var facebook = container.lookup('connection:facebook'); + var facebook2 = container.lookup('connection:facebook'); + + facebook === facebook2; // => false + ``` + + @method optionsForType + @param {String} type + @param {Object} options + */ + optionsForType: function(type, options) { + if (this.parent) { illegalChildOperation('optionsForType'); } + + this._typeOptions.set(type, options); + }, + + /** + @method options + @param {String} type + @param {Object} options + */ + options: function(type, options) { + this.optionsForType(type, options); + }, + + /** + Used only via `injection`. + + Provides a specialized form of injection, specifically enabling + all objects of one type to be injected with a reference to another + object. + + For example, provided each object of type `controller` needed a `router`. + one would do the following: + + ```javascript + var container = new Container(); + + container.register('router:main', Router); + container.register('controller:user', UserController); + container.register('controller:post', PostController); + + container.typeInjection('controller', 'router', 'router:main'); + + var user = container.lookup('controller:user'); + var post = container.lookup('controller:post'); + + user.router instanceof Router; //=> true + post.router instanceof Router; //=> true + + // both controllers share the same router + user.router === post.router; //=> true + ``` + + @private + @method typeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + typeInjection: function(type, property, fullName) { + if (this.parent) { illegalChildOperation('typeInjection'); } + + var fullNameType = fullName.split(':')[0]; + if(fullNameType === type) { + throw new Error('Cannot inject a `' + fullName + '` on other ' + type + '(s). Register the `' + fullName + '` as a different type and perform the typeInjection.'); + } + addTypeInjection(this.typeInjections, type, property, fullName); + }, + + /** + Defines injection rules. + + These rules are used to inject dependencies onto objects when they + are instantiated. + + Two forms of injections are possible: + + * Injecting one fullName on another fullName + * Injecting one fullName on a type + + Example: + + ```javascript + var container = new Container(); + + container.register('source:main', Source); + container.register('model:user', User); + container.register('model:post', Post); + + // injecting one fullName on another fullName + // eg. each user model gets a post model + container.injection('model:user', 'post', 'model:post'); + + // injecting one fullName on another type + container.injection('model', 'source', 'source:main'); + + var user = container.lookup('model:user'); + var post = container.lookup('model:post'); + + user.source instanceof Source; //=> true + post.source instanceof Source; //=> true + + user.post instanceof Post; //=> true + + // and both models share the same source + user.source === post.source; //=> true + ``` + + @method injection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + injection: function(fullName, property, injectionName) { + if (this.parent) { illegalChildOperation('injection'); } + + validateFullName(injectionName); + var normalizedInjectionName = this.normalize(injectionName); + + if (fullName.indexOf(':') === -1) { + return this.typeInjection(fullName, property, normalizedInjectionName); + } + + var normalizedName = this.normalize(fullName); + + if (this.cache.has(normalizedName)) { + throw new Error("Attempted to register an injection for a type that has already been looked up. ('" + normalizedName + "', '" + property + "', '" + injectionName + "')"); + } + addInjection(this.injections, normalizedName, property, normalizedInjectionName); + }, + + + /** + Used only via `factoryInjection`. + + Provides a specialized form of injection, specifically enabling + all factory of one type to be injected with a reference to another + object. + + For example, provided each factory of type `model` needed a `store`. + one would do the following: + + ```javascript + var container = new Container(); + + container.register('store:main', SomeStore); + + container.factoryTypeInjection('model', 'store', 'store:main'); + + var store = container.lookup('store:main'); + var UserFactory = container.lookupFactory('model:user'); + + UserFactory.store instanceof SomeStore; //=> true + ``` + + @private + @method factoryTypeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + factoryTypeInjection: function(type, property, fullName) { + if (this.parent) { illegalChildOperation('factoryTypeInjection'); } + + addTypeInjection(this.factoryTypeInjections, type, property, this.normalize(fullName)); + }, + + /** + Defines factory injection rules. + + Similar to regular injection rules, but are run against factories, via + `Container#lookupFactory`. + + These rules are used to inject objects onto factories when they + are looked up. + + Two forms of injections are possible: + + * Injecting one fullName on another fullName + * Injecting one fullName on a type + + Example: + + ```javascript + var container = new Container(); + + container.register('store:main', Store); + container.register('store:secondary', OtherStore); + container.register('model:user', User); + container.register('model:post', Post); + + // injecting one fullName on another type + container.factoryInjection('model', 'store', 'store:main'); + + // injecting one fullName on another fullName + container.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); + + var UserFactory = container.lookupFactory('model:user'); + var PostFactory = container.lookupFactory('model:post'); + var store = container.lookup('store:main'); + + UserFactory.store instanceof Store; //=> true + UserFactory.secondaryStore instanceof OtherStore; //=> false + + PostFactory.store instanceof Store; //=> true + PostFactory.secondaryStore instanceof OtherStore; //=> true + + // and both models share the same source instance + UserFactory.store === PostFactory.store; //=> true + ``` + + @method factoryInjection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + factoryInjection: function(fullName, property, injectionName) { + if (this.parent) { illegalChildOperation('injection'); } + + var normalizedName = this.normalize(fullName); + var normalizedInjectionName = this.normalize(injectionName); + + validateFullName(injectionName); + + if (fullName.indexOf(':') === -1) { + return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); + } + + + if (this.factoryCache.has(normalizedName)) { + throw new Error('Attempted to register a factoryInjection for a type that has already ' + + 'been looked up. (\'' + normalizedName + '\', \'' + property + '\', \'' + injectionName + '\')'); + } + + addInjection(this.factoryInjections, normalizedName, property, normalizedInjectionName); + }, + + /** + A depth first traversal, destroying the container, its descendant containers and all + their managed objects. + + @method destroy + */ + destroy: function() { + for (var i = 0, length = this.children.length; i < length; i++) { + this.children[i].destroy(); + } + + this.children = []; + + eachDestroyable(this, function(item) { + item.destroy(); + }); + + this.parent = undefined; + this.isDestroyed = true; + }, + + /** + @method reset + */ + reset: function() { + for (var i = 0, length = this.children.length; i < length; i++) { + resetCache(this.children[i]); + } + + resetCache(this); + } + }; + + function resolve(container, normalizedName) { + var cached = container.resolveCache.get(normalizedName); + if (cached) { return cached; } + + var resolved = container.resolver(normalizedName) || container.registry.get(normalizedName); + container.resolveCache.set(normalizedName, resolved); + + return resolved; + } + + function has(container, fullName){ + if (container.cache.has(fullName)) { + return true; + } + + return !!container.resolve(fullName); + } + + function lookup(container, fullName, options) { + options = options || {}; + + if (container.cache.has(fullName) && options.singleton !== false) { + return container.cache.get(fullName); + } + + var value = instantiate(container, fullName); + + if (value === undefined) { return; } + + if (isSingleton(container, fullName) && options.singleton !== false) { + container.cache.set(fullName, value); + } + + return value; + } + + function illegalChildOperation(operation) { + throw new Error(operation + ' is not currently supported on child containers'); + } + + function isSingleton(container, fullName) { + var singleton = option(container, fullName, 'singleton'); + + return singleton !== false; + } + + function buildInjections(container, injections) { + var hash = {}; + + if (!injections) { return hash; } + + var injection, injectable; + + for (var i = 0, length = injections.length; i < length; i++) { + injection = injections[i]; + injectable = lookup(container, injection.fullName); + + if (injectable !== undefined) { + hash[injection.property] = injectable; + } else { + throw new Error('Attempting to inject an unknown injection: `' + injection.fullName + '`'); + } + } + + return hash; + } + + function option(container, fullName, optionName) { + var options = container._options.get(fullName); + + if (options && options[optionName] !== undefined) { + return options[optionName]; + } + + var type = fullName.split(':')[0]; + options = container._typeOptions.get(type); + + if (options) { + return options[optionName]; + } + } + + function factoryFor(container, fullName) { + var cache = container.factoryCache; + if (cache.has(fullName)) { + return cache.get(fullName); + } + var factory = container.resolve(fullName); + if (factory === undefined) { return; } + + var type = fullName.split(':')[0]; + if (!factory || typeof factory.extend !== 'function' || (!Ember.MODEL_FACTORY_INJECTIONS && type === 'model')) { + // TODO: think about a 'safe' merge style extension + // for now just fallback to create time injection + return factory; + } else { + var injections = injectionsFor(container, fullName); + var factoryInjections = factoryInjectionsFor(container, fullName); + + factoryInjections._toString = container.makeToString(factory, fullName); + + var injectedFactory = factory.extend(injections); + injectedFactory.reopenClass(factoryInjections); + + cache.set(fullName, injectedFactory); + + return injectedFactory; + } + } + + function injectionsFor(container, fullName) { + var splitName = fullName.split(':'), + type = splitName[0], + injections = []; + + injections = injections.concat(container.typeInjections.get(type) || []); + injections = injections.concat(container.injections[fullName] || []); + + injections = buildInjections(container, injections); + injections._debugContainerKey = fullName; + injections.container = container; + + return injections; + } + + function factoryInjectionsFor(container, fullName) { + var splitName = fullName.split(':'), + type = splitName[0], + factoryInjections = []; + + factoryInjections = factoryInjections.concat(container.factoryTypeInjections.get(type) || []); + factoryInjections = factoryInjections.concat(container.factoryInjections[fullName] || []); + + factoryInjections = buildInjections(container, factoryInjections); + factoryInjections._debugContainerKey = fullName; + + return factoryInjections; + } + + function instantiate(container, fullName) { + var factory = factoryFor(container, fullName); + + if (option(container, fullName, 'instantiate') === false) { + return factory; + } + + if (factory) { + if (typeof factory.create !== 'function') { + throw new Error('Failed to create an instance of \'' + fullName + '\'. ' + + 'Most likely an improperly defined class or an invalid module export.'); + } + + if (typeof factory.extend === 'function') { + // assume the factory was extendable and is already injected + return factory.create(); + } else { + // assume the factory was extendable + // to create time injections + // TODO: support new'ing for instantiation and merge injections for pure JS Functions + return factory.create(injectionsFor(container, fullName)); + } + } + } + + function eachDestroyable(container, callback) { + container.cache.eachLocal(function(key, value) { + if (option(container, key, 'instantiate') === false) { return; } + callback(value); + }); + } + + function resetCache(container) { + container.cache.eachLocal(function(key, value) { + if (option(container, key, 'instantiate') === false) { return; } + value.destroy(); + }); + container.cache.dict = {}; + } + + function addTypeInjection(rules, type, property, fullName) { + var injections = rules.get(type); + + if (!injections) { + injections = []; + rules.set(type, injections); + } + + injections.push({ + property: property, + fullName: fullName + }); + } + + var VALID_FULL_NAME_REGEXP = /^[^:]+.+:[^:]+$/; + function validateFullName(fullName) { + if (!VALID_FULL_NAME_REGEXP.test(fullName)) { + throw new TypeError('Invalid Fullname, expected: `type:name` got: ' + fullName); + } + return true; + } + + function addInjection(rules, factoryName, property, injectionName) { + var injections = rules[factoryName] = rules[factoryName] || []; + injections.push({ property: property, fullName: injectionName }); + } + + __exports__["default"] = Container; + }); +define("container/inheriting_dict", + ["exports"], + function(__exports__) { + "use strict"; + // A safe and simple inheriting object. + function InheritingDict(parent) { + this.parent = parent; + this.dict = {}; + } + + InheritingDict.prototype = { + + /** + @property parent + @type InheritingDict + @default null + */ + + parent: null, + + /** + Object used to store the current nodes data. + + @property dict + @type Object + @default Object + */ + dict: null, + + /** + Retrieve the value given a key, if the value is present at the current + level use it, otherwise walk up the parent hierarchy and try again. If + no matching key is found, return undefined. + + @method get + @param {String} key + @return {any} + */ + get: function(key) { + var dict = this.dict; + + if (dict.hasOwnProperty(key)) { + return dict[key]; + } + + if (this.parent) { + return this.parent.get(key); + } + }, + + /** + Set the given value for the given key, at the current level. + + @method set + @param {String} key + @param {Any} value + */ + set: function(key, value) { + this.dict[key] = value; + }, + + /** + Delete the given key + + @method remove + @param {String} key + */ + remove: function(key) { + delete this.dict[key]; + }, + + /** + Check for the existence of given a key, if the key is present at the current + level return true, otherwise walk up the parent hierarchy and try again. If + no matching key is found, return false. + + @method has + @param {String} key + @return {Boolean} + */ + has: function(key) { + var dict = this.dict; + + if (dict.hasOwnProperty(key)) { + return true; + } + + if (this.parent) { + return this.parent.has(key); + } + + return false; + }, + + /** + Iterate and invoke a callback for each local key-value pair. + + @method eachLocal + @param {Function} callback + @param {Object} binding + */ + eachLocal: function(callback, binding) { + var dict = this.dict; + + for (var prop in dict) { + if (dict.hasOwnProperty(prop)) { + callback.call(binding, prop, dict[prop]); + } + } + } + }; + + __exports__["default"] = InheritingDict; + }); +define("ember-application", + ["ember-metal/core","ember-runtime/system/lazy_load","ember-application/system/dag","ember-application/system/resolver","ember-application/system/application","ember-application/ext/controller"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) { + "use strict"; + var Ember = __dependency1__["default"]; + var runLoadHooks = __dependency2__.runLoadHooks; + + /** + Ember Application + + @module ember + @submodule ember-application + @requires ember-views, ember-routing + */ + + var DAG = __dependency3__["default"]; + var Resolver = __dependency4__.Resolver; + var DefaultResolver = __dependency4__["default"]; + var Application = __dependency5__["default"]; + // side effect of extending ControllerMixin + + Ember.Application = Application; + Ember.DAG = DAG; + Ember.Resolver = Resolver; + Ember.DefaultResolver = DefaultResolver; + + runLoadHooks('Ember.Application', Application); + }); +define("ember-application/ext/controller", + ["ember-metal/core","ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/utils","ember-metal/computed","ember-runtime/mixins/controller","ember-routing/system/controller_for","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-application + */ + + var Ember = __dependency1__["default"]; + // Ember.assert + var get = __dependency2__.get; + var set = __dependency3__.set; + var EmberError = __dependency4__["default"]; + var inspect = __dependency5__.inspect; + var computed = __dependency6__.computed; + var ControllerMixin = __dependency7__["default"]; + var meta = __dependency5__.meta; + var controllerFor = __dependency8__["default"]; + + function verifyNeedsDependencies(controller, container, needs) { + var dependency, i, l, missing = []; + + for (i=0, l=needs.length; i 1 ? 'they' : 'it') + " could not be found"); + } + } + + var defaultControllersComputedProperty = computed(function() { + var controller = this; + + return { + needs: get(controller, 'needs'), + container: get(controller, 'container'), + unknownProperty: function(controllerName) { + var needs = this.needs, + dependency, i, l; + for (i=0, l=needs.length; i 0) { + + if (this.container) { + verifyNeedsDependencies(this, this.container, needs); + } + + // if needs then initialize controllers proxy + get(this, 'controllers'); + } + + this._super.apply(this, arguments); + }, + + /** + @method controllerFor + @see {Ember.Route#controllerFor} + @deprecated Use `needs` instead + */ + controllerFor: function(controllerName) { + return controllerFor(get(this, 'container'), controllerName); + }, + + /** + Stores the instances of other controllers available from within + this controller. Any controller listed by name in the `needs` + property will be accessible by name through this property. + + ```javascript + App.CommentsController = Ember.ArrayController.extend({ + needs: ['post'], + postTitle: function(){ + var currentPost = this.get('controllers.post'); // instance of App.PostController + return currentPost.get('title'); + }.property('controllers.post.title') + }); + ``` + + @see {Ember.ControllerMixin#needs} + @property {Object} controllers + @default null + */ + controllers: defaultControllersComputedProperty + }); + + __exports__["default"] = ControllerMixin; + }); +define("ember-application/system/application", + ["ember-metal","ember-metal/property_get","ember-metal/property_set","ember-runtime/system/lazy_load","ember-application/system/dag","ember-runtime/system/namespace","ember-runtime/mixins/deferred","ember-application/system/resolver","ember-metal/platform","ember-metal/run_loop","ember-metal/utils","container/container","ember-runtime/controllers/controller","ember-metal/enumerable_utils","ember-runtime/controllers/object_controller","ember-runtime/controllers/array_controller","ember-views/system/event_dispatcher","ember-views/system/jquery","ember-routing/system/route","ember-routing/system/router","ember-routing/location/hash_location","ember-routing/location/history_location","ember-routing/location/auto_location","ember-routing/location/none_location","ember-routing/system/cache","ember-metal/core","ember-handlebars-compiler","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __dependency23__, __dependency24__, __dependency25__, __dependency26__, __dependency27__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-application + */ + + var Ember = __dependency1__["default"]; + // Ember.FEATURES, Ember.deprecate, Ember.assert, Ember.libraries, LOG_VERSION, Namespace, BOOTED + var get = __dependency2__.get; + var set = __dependency3__.set; + var runLoadHooks = __dependency4__.runLoadHooks; + var DAG = __dependency5__["default"]; + var Namespace = __dependency6__["default"]; + var DeferredMixin = __dependency7__["default"]; + var DefaultResolver = __dependency8__["default"]; + var create = __dependency9__.create; + var run = __dependency10__["default"]; + var canInvoke = __dependency11__.canInvoke; + var Container = __dependency12__["default"]; + var Controller = __dependency13__["default"]; + var EnumerableUtils = __dependency14__["default"]; + var ObjectController = __dependency15__["default"]; + var ArrayController = __dependency16__["default"]; + var EventDispatcher = __dependency17__["default"]; + //import ContainerDebugAdapter from "ember-extension-support/container_debug_adapter"; + var jQuery = __dependency18__["default"]; + var Route = __dependency19__["default"]; + var Router = __dependency20__["default"]; + var HashLocation = __dependency21__["default"]; + var HistoryLocation = __dependency22__["default"]; + var AutoLocation = __dependency23__["default"]; + var NoneLocation = __dependency24__["default"]; + var BucketCache = __dependency25__["default"]; + + var K = __dependency26__.K; + var EmberHandlebars = __dependency27__["default"]; + + var ContainerDebugAdapter; + + /** + An instance of `Ember.Application` is the starting point for every Ember + application. It helps to instantiate, initialize and coordinate the many + objects that make up your app. + + Each Ember app has one and only one `Ember.Application` object. In fact, the + very first thing you should do in your application is create the instance: + + ```javascript + window.App = Ember.Application.create(); + ``` + + Typically, the application object is the only global variable. All other + classes in your app should be properties on the `Ember.Application` instance, + which highlights its first role: a global namespace. + + For example, if you define a view class, it might look like this: + + ```javascript + App.MyView = Ember.View.extend(); + ``` + + By default, calling `Ember.Application.create()` will automatically initialize + your application by calling the `Ember.Application.initialize()` method. If + you need to delay initialization, you can call your app's `deferReadiness()` + method. When you are ready for your app to be initialized, call its + `advanceReadiness()` method. + + You can define a `ready` method on the `Ember.Application` instance, which + will be run by Ember when the application is initialized. + + Because `Ember.Application` inherits from `Ember.Namespace`, any classes + you create will have useful string representations when calling `toString()`. + See the `Ember.Namespace` documentation for more information. + + While you can think of your `Ember.Application` as a container that holds the + other classes in your application, there are several other responsibilities + going on under-the-hood that you may want to understand. + + ### Event Delegation + + Ember uses a technique called _event delegation_. This allows the framework + to set up a global, shared event listener instead of requiring each view to + do it manually. For example, instead of each view registering its own + `mousedown` listener on its associated element, Ember sets up a `mousedown` + listener on the `body`. + + If a `mousedown` event occurs, Ember will look at the target of the event and + start walking up the DOM node tree, finding corresponding views and invoking + their `mouseDown` method as it goes. + + `Ember.Application` has a number of default events that it listens for, as + well as a mapping from lowercase events to camel-cased view method names. For + example, the `keypress` event causes the `keyPress` method on the view to be + called, the `dblclick` event causes `doubleClick` to be called, and so on. + + If there is a bubbling browser event that Ember does not listen for by + default, you can specify custom events and their corresponding view method + names by setting the application's `customEvents` property: + + ```javascript + App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: "paste" + } + }); + ``` + + By default, the application sets up these event listeners on the document + body. However, in cases where you are embedding an Ember application inside + an existing page, you may want it to set up the listeners on an element + inside the body. + + For example, if only events inside a DOM element with the ID of `ember-app` + should be delegated, set your application's `rootElement` property: + + ```javascript + window.App = Ember.Application.create({ + rootElement: '#ember-app' + }); + ``` + + The `rootElement` can be either a DOM element or a jQuery-compatible selector + string. Note that *views appended to the DOM outside the root element will + not receive events.* If you specify a custom root element, make sure you only + append views inside it! + + To learn more about the advantages of event delegation and the Ember view + layer, and a list of the event listeners that are setup by default, visit the + [Ember View Layer guide](http://emberjs.com/guides/understanding-ember/the-view-layer/#toc_event-delegation). + + ### Initializers + + Libraries on top of Ember can add initializers, like so: + + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + + initialize: function(container, application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + + Initializers provide an opportunity to access the container, which + organizes the different components of an Ember application. Additionally + they provide a chance to access the instantiated application. Beyond + being used for libraries, initializers are also a great way to organize + dependency injection or setup in your own application. + + ### Routing + + In addition to creating your application's router, `Ember.Application` is + also responsible for telling the router when to start routing. Transitions + between routes can be logged with the `LOG_TRANSITIONS` flag, and more + detailed intra-transition logging can be logged with + the `LOG_TRANSITIONS_INTERNAL` flag: + + ```javascript + window.App = Ember.Application.create({ + LOG_TRANSITIONS: true, // basic logging of successful transitions + LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps + }); + ``` + + By default, the router will begin trying to translate the current URL into + application state once the browser emits the `DOMContentReady` event. If you + need to defer routing, you can call the application's `deferReadiness()` + method. Once routing can begin, call the `advanceReadiness()` method. + + If there is any setup required before routing begins, you can implement a + `ready()` method on your app that will be invoked immediately before routing + begins. + ``` + + @class Application + @namespace Ember + @extends Ember.Namespace + */ + + var Application = Namespace.extend(DeferredMixin, { + _suppressDeferredDeprecation: true, + + /** + The root DOM element of the Application. This can be specified as an + element or a + [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). + + This is the element that will be passed to the Application's, + `eventDispatcher`, which sets up the listeners for event delegation. Every + view in your application should be a child of the element you specify here. + + @property rootElement + @type DOMElement + @default 'body' + */ + rootElement: 'body', + + /** + The `Ember.EventDispatcher` responsible for delegating events to this + application's views. + + The event dispatcher is created by the application at initialization time + and sets up event listeners on the DOM element described by the + application's `rootElement` property. + + See the documentation for `Ember.EventDispatcher` for more information. + + @property eventDispatcher + @type Ember.EventDispatcher + @default null + */ + eventDispatcher: null, + + /** + The DOM events for which the event dispatcher should listen. + + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + + If you would like additional bubbling events to be delegated to your + views, set your `Ember.Application`'s `customEvents` property + to a hash containing the DOM event name as the key and the + corresponding view method name as the value. For example: + + ```javascript + App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: "paste" + } + }); + ``` + + @property customEvents + @type Object + @default null + */ + customEvents: null, + + // Start off the number of deferrals at 1. This will be + // decremented by the Application's own `initialize` method. + _readinessDeferrals: 1, + + init: function() { + if (!this.$) { this.$ = jQuery; } + this.__container__ = this.buildContainer(); + + this.Router = this.defaultRouter(); + + this._super(); + + this.scheduleInitialize(); + + Ember.libraries.registerCoreLibrary('Handlebars', EmberHandlebars.VERSION); + Ember.libraries.registerCoreLibrary('jQuery', jQuery().jquery); + + if ( Ember.LOG_VERSION ) { + Ember.LOG_VERSION = false; // we only need to see this once per Application#init + + var nameLengths = EnumerableUtils.map(Ember.libraries, function(item) { + return get(item, "name.length"); + }); + + var maxNameLength = Math.max.apply(this, nameLengths); + + Ember.libraries.each(function(name, version) { + var spaces = new Array(maxNameLength - name.length + 1).join(" "); + }); + } + }, + + /** + Build the container for the current application. + + Also register a default application view in case the application + itself does not. + + @private + @method buildContainer + @return {Ember.Container} the configured container + */ + buildContainer: function() { + var container = this.__container__ = Application.buildContainer(this); + + return container; + }, + + /** + If the application has not opted out of routing and has not explicitly + defined a router, supply a default router for the application author + to configure. + + This allows application developers to do: + + ```javascript + var App = Ember.Application.create(); + + App.Router.map(function() { + this.resource('posts'); + }); + ``` + + @private + @method defaultRouter + @return {Ember.Router} the default router + */ + + defaultRouter: function() { + if (this.Router === false) { return; } + var container = this.__container__; + + if (this.Router) { + container.unregister('router:main'); + container.register('router:main', this.Router); + } + + return container.lookupFactory('router:main'); + }, + + /** + Automatically initialize the application once the DOM has + become ready. + + The initialization itself is scheduled on the actions queue + which ensures that application loading finishes before + booting. + + If you are asynchronously loading code, you should call + `deferReadiness()` to defer booting, and then call + `advanceReadiness()` once all of your code has finished + loading. + + @private + @method scheduleInitialize + */ + scheduleInitialize: function() { + var self = this; + + if (!this.$ || this.$.isReady) { + run.schedule('actions', self, '_initialize'); + } else { + this.$().ready(function runInitialize() { + run(self, '_initialize'); + }); + } + }, + + /** + Use this to defer readiness until some condition is true. + + Example: + + ```javascript + App = Ember.Application.create(); + App.deferReadiness(); + + jQuery.getJSON("/auth-token", function(token) { + App.token = token; + App.advanceReadiness(); + }); + ``` + + This allows you to perform asynchronous setup logic and defer + booting your application until the setup has finished. + + However, if the setup requires a loading UI, it might be better + to use the router for this purpose. + + @method deferReadiness + */ + deferReadiness: function() { + this._readinessDeferrals++; + }, + + /** + Call `advanceReadiness` after any asynchronous setup logic has completed. + Each call to `deferReadiness` must be matched by a call to `advanceReadiness` + or the application will never become ready and routing will not begin. + + @method advanceReadiness + @see {Ember.Application#deferReadiness} + */ + advanceReadiness: function() { + this._readinessDeferrals--; + + if (this._readinessDeferrals === 0) { + run.once(this, this.didBecomeReady); + } + }, + + /** + Registers a factory that can be used for dependency injection (with + `App.inject`) or for service lookup. Each factory is registered with + a full name including two parts: `type:name`. + + A simple example: + + ```javascript + var App = Ember.Application.create(); + App.Orange = Ember.Object.extend(); + App.register('fruit:favorite', App.Orange); + ``` + + Ember will resolve factories from the `App` namespace automatically. + For example `App.CarsController` will be discovered and returned if + an application requests `controller:cars`. + + An example of registering a controller with a non-standard name: + + ```javascript + var App = Ember.Application.create(), + Session = Ember.Controller.extend(); + + App.register('controller:session', Session); + + // The Session controller can now be treated like a normal controller, + // despite its non-standard name. + App.ApplicationController = Ember.Controller.extend({ + needs: ['session'] + }); + ``` + + Registered factories are **instantiated** by having `create` + called on them. Additionally they are **singletons**, each time + they are looked up they return the same instance. + + Some examples modifying that default behavior: + + ```javascript + var App = Ember.Application.create(); + + App.Person = Ember.Object.extend(); + App.Orange = Ember.Object.extend(); + App.Email = Ember.Object.extend(); + App.session = Ember.Object.create(); + + App.register('model:user', App.Person, {singleton: false }); + App.register('fruit:favorite', App.Orange); + App.register('communication:main', App.Email, {singleton: false}); + App.register('session', App.session, {instantiate: false}); + ``` + + @method register + @param fullName {String} type:name (e.g., 'model:user') + @param factory {Function} (e.g., App.Person) + @param options {Object} (optional) disable instantiation or singleton usage + **/ + register: function() { + var container = this.__container__; + container.register.apply(container, arguments); + }, + + /** + Define a dependency injection onto a specific factory or all factories + of a type. + + When Ember instantiates a controller, view, or other framework component + it can attach a dependency to that component. This is often used to + provide services to a set of framework components. + + An example of providing a session object to all controllers: + + ```javascript + var App = Ember.Application.create(), + Session = Ember.Object.extend({ isAuthenticated: false }); + + // A factory must be registered before it can be injected + App.register('session:main', Session); + + // Inject 'session:main' onto all factories of the type 'controller' + // with the name 'session' + App.inject('controller', 'session', 'session:main'); + + App.IndexController = Ember.Controller.extend({ + isLoggedIn: Ember.computed.alias('session.isAuthenticated') + }); + ``` + + Injections can also be performed on specific factories. + + ```javascript + App.inject(, , ) + App.inject('route', 'source', 'source:main') + App.inject('route:application', 'email', 'model:email') + ``` + + It is important to note that injections can only be performed on + classes that are instantiated by Ember itself. Instantiating a class + directly (via `create` or `new`) bypasses the dependency injection + system. + + Ember-Data instantiates its models in a unique manner, and consequently + injections onto models (or all models) will not work as expected. Injections + on models can be enabled by setting `Ember.MODEL_FACTORY_INJECTIONS` + to `true`. + + @method inject + @param factoryNameOrType {String} + @param property {String} + @param injectionName {String} + **/ + inject: function() { + var container = this.__container__; + container.injection.apply(container, arguments); + }, + + /** + Calling initialize manually is not supported. + + Please see Ember.Application#advanceReadiness and + Ember.Application#deferReadiness. + + @private + @deprecated + @method initialize + **/ + initialize: function() { + }, + + /** + Initialize the application. This happens automatically. + + Run any initializers and run the application load hook. These hooks may + choose to defer readiness. For example, an authentication hook might want + to defer readiness until the auth token has been retrieved. + + @private + @method _initialize + */ + _initialize: function() { + if (this.isDestroyed) { return; } + + // At this point, the App.Router must already be assigned + if (this.Router) { + var container = this.__container__; + container.unregister('router:main'); + container.register('router:main', this.Router); + } + + this.runInitializers(); + runLoadHooks('application', this); + + // At this point, any initializers or load hooks that would have wanted + // to defer readiness have fired. In general, advancing readiness here + // will proceed to didBecomeReady. + this.advanceReadiness(); + + return this; + }, + + /** + Reset the application. This is typically used only in tests. It cleans up + the application in the following order: + + 1. Deactivate existing routes + 2. Destroy all objects in the container + 3. Create a new application container + 4. Re-route to the existing url + + Typical Example: + + ```javascript + + var App; + + run(function() { + App = Ember.Application.create(); + }); + + module("acceptance test", { + setup: function() { + App.reset(); + } + }); + + test("first test", function() { + // App is freshly reset + }); + + test("first test", function() { + // App is again freshly reset + }); + ``` + + Advanced Example: + + Occasionally you may want to prevent the app from initializing during + setup. This could enable extra configuration, or enable asserting prior + to the app becoming ready. + + ```javascript + + var App; + + run(function() { + App = Ember.Application.create(); + }); + + module("acceptance test", { + setup: function() { + run(function() { + App.reset(); + App.deferReadiness(); + }); + } + }); + + test("first test", function() { + ok(true, 'something before app is initialized'); + + run(function() { + App.advanceReadiness(); + }); + ok(true, 'something after app is initialized'); + }); + ``` + + @method reset + **/ + reset: function() { + this._readinessDeferrals = 1; + + function handleReset() { + var router = this.__container__.lookup('router:main'); + router.reset(); + + run(this.__container__, 'destroy'); + + this.buildContainer(); + + run.schedule('actions', this, function() { + this._initialize(); + }); + } + + run.join(this, handleReset); + }, + + /** + @private + @method runInitializers + */ + runInitializers: function() { + var initializers = get(this.constructor, 'initializers'); + var container = this.__container__; + var graph = new DAG(); + var namespace = this; + var name, initializer; + + for (name in initializers) { + initializer = initializers[name]; + graph.addEdges(initializer.name, initializer.initialize, initializer.before, initializer.after); + } + + graph.topsort(function (vertex) { + var initializer = vertex.value; + initializer(container, namespace); + }); + }, + + /** + @private + @method didBecomeReady + */ + didBecomeReady: function() { + this.setupEventDispatcher(); + this.ready(); // user hook + this.startRouting(); + + if (!Ember.testing) { + // Eagerly name all classes that are already loaded + Ember.Namespace.processAll(); + Ember.BOOTED = true; + } + + this.resolve(this); + }, + + /** + Setup up the event dispatcher to receive events on the + application's `rootElement` with any registered + `customEvents`. + + @private + @method setupEventDispatcher + */ + setupEventDispatcher: function() { + var customEvents = get(this, 'customEvents'); + var rootElement = get(this, 'rootElement'); + var dispatcher = this.__container__.lookup('event_dispatcher:main'); + + set(this, 'eventDispatcher', dispatcher); + dispatcher.setup(customEvents, rootElement); + }, + + /** + If the application has a router, use it to route to the current URL, and + trigger a new call to `route` whenever the URL changes. + + @private + @method startRouting + @property router {Ember.Router} + */ + startRouting: function() { + var router = this.__container__.lookup('router:main'); + if (!router) { return; } + + router.startRouting(); + }, + + handleURL: function(url) { + var router = this.__container__.lookup('router:main'); + + router.handleURL(url); + }, + + /** + Called when the Application has become ready. + The call will be delayed until the DOM has become ready. + + @event ready + */ + ready: K, + + /** + @deprecated Use 'Resolver' instead + Set this to provide an alternate class to `Ember.DefaultResolver` + + + @property resolver + */ + resolver: null, + + /** + Set this to provide an alternate class to `Ember.DefaultResolver` + + @property resolver + */ + Resolver: null, + + willDestroy: function() { + Ember.BOOTED = false; + // Ensure deactivation of routes before objects are destroyed + this.__container__.lookup('router:main').reset(); + + this.__container__.destroy(); + }, + + initializer: function(options) { + this.constructor.initializer(options); + }, + + /** + @method then + @private + @deprecated + */ + then: function() { + + this._super.apply(this, arguments); + } + }); + + Application.reopenClass({ + initializers: {}, + + /** + Initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize, all others are optional. + + * `name` allows you to specify under which name the initializer is registered. + This must be a unique name, as trying to register two initializers with the + same name will result in an error. + + ```javascript + Ember.Application.initializer({ + name: 'namedInitializer', + initialize: function(container, application) { + Ember.debug("Running namedInitializer!"); + } + }); + ``` + + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + + An example of ordering initializers, we create an initializer named `first`: + + ```javascript + Ember.Application.initializer({ + name: 'first', + initialize: function(container, application) { + Ember.debug("First initializer!"); + } + }); + + // DEBUG: First initializer! + ``` + + We add another initializer named `second`, specifying that it should run + after the initializer named `first`: + + ```javascript + Ember.Application.initializer({ + name: 'second', + after: 'first', + + initialize: function(container, application) { + Ember.debug("Second initializer!"); + } + }); + + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + + Afterwards we add a further initializer named `pre`, this time specifying + that it should run before the initializer named `first`: + + ```javascript + Ember.Application.initializer({ + name: 'pre', + before: 'first', + + initialize: function(container, application) { + Ember.debug("Pre initializer!"); + } + }); + + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + + Finally we add an initializer named `post`, specifying it should run after + both the `first` and the `second` initializers: + + ```javascript + Ember.Application.initializer({ + name: 'post', + after: ['first', 'second'], + + initialize: function(container, application) { + Ember.debug("Post initializer!"); + } + }); + + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + // DEBUG: Post initializer! + ``` + + * `initialize` is a callback function that receives two arguments, `container` + and `application` on which you can operate. + + Example of using `container` to preload data into the store: + + ```javascript + Ember.Application.initializer({ + name: "preload-data", + + initialize: function(container, application) { + var store = container.lookup('store:main'); + store.pushPayload(preloadedData); + } + }); + ``` + + Example of using `application` to register an adapter: + + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + + initialize: function(container, application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + + @method initializer + @param initializer {Object} + */ + initializer: function(initializer) { + // If this is the first initializer being added to a subclass, we are going to reopen the class + // to make sure we have a new `initializers` object, which extends from the parent class' using + // prototypal inheritance. Without this, attempting to add initializers to the subclass would + // pollute the parent class as well as other subclasses. + if (this.superclass.initializers !== undefined && this.superclass.initializers === this.initializers) { + this.reopenClass({ + initializers: create(this.initializers) + }); + } + + + this.initializers[initializer.name] = initializer; + }, + + /** + This creates a container with the default Ember naming conventions. + + It also configures the container: + + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + + @private + @method buildContainer + @static + @param {Ember.Application} namespace the application to build the + container for. + @return {Ember.Container} the built container + */ + buildContainer: function(namespace) { + var container = new Container(); + + container.set = set; + container.resolver = resolverFor(namespace); + container.normalize = container.resolver.normalize; + container.describe = container.resolver.describe; + container.makeToString = container.resolver.makeToString; + + container.optionsForType('component', { singleton: false }); + container.optionsForType('view', { singleton: false }); + container.optionsForType('template', { instantiate: false }); + container.optionsForType('helper', { instantiate: false }); + + container.register('application:main', namespace, { instantiate: false }); + + container.register('controller:basic', Controller, { instantiate: false }); + container.register('controller:object', ObjectController, { instantiate: false }); + container.register('controller:array', ArrayController, { instantiate: false }); + container.register('route:basic', Route, { instantiate: false }); + container.register('event_dispatcher:main', EventDispatcher); + + container.register('router:main', Router); + container.injection('router:main', 'namespace', 'application:main'); + + container.register('location:auto', AutoLocation); + container.register('location:hash', HashLocation); + container.register('location:history', HistoryLocation); + container.register('location:none', NoneLocation); + + container.injection('controller', 'target', 'router:main'); + container.injection('controller', 'namespace', 'application:main'); + + container.register('-bucket-cache:main', BucketCache); + container.injection('router', '_bucketCache', '-bucket-cache:main'); + container.injection('route', '_bucketCache', '-bucket-cache:main'); + container.injection('controller', '_bucketCache', '-bucket-cache:main'); + + container.injection('route', 'router', 'router:main'); + container.injection('location', 'rootURL', '-location-setting:root-url'); + + // DEBUGGING + container.register('resolver-for-debugging:main', container.resolver.__resolver__, { instantiate: false }); + container.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + container.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + // Custom resolver authors may want to register their own ContainerDebugAdapter with this key + + // ES6TODO: resolve this via import once ember-application package is ES6'ed + if (!ContainerDebugAdapter) { ContainerDebugAdapter = requireModule('ember-extension-support/container_debug_adapter')['default']; } + container.register('container-debug-adapter:main', ContainerDebugAdapter); + + return container; + } + }); + + /** + This function defines the default lookup rules for container lookups: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after classifying the name. + For example, `controller:post` looks up `App.PostController` by default. + * if the default lookup fails, look for registered classes on the container + + This allows the application to register default injections in the container + that could be overridden by the normal naming convention. + + @private + @method resolverFor + @param {Ember.Namespace} namespace the namespace to look for classes + @return {*} the resolved value for a given lookup + */ + function resolverFor(namespace) { + if (namespace.get('resolver')) { + } + + var ResolverClass = namespace.get('resolver') || namespace.get('Resolver') || DefaultResolver; + var resolver = ResolverClass.create({ + namespace: namespace + }); + + function resolve(fullName) { + return resolver.resolve(fullName); + } + + resolve.describe = function(fullName) { + return resolver.lookupDescription(fullName); + }; + + resolve.makeToString = function(factory, fullName) { + return resolver.makeToString(factory, fullName); + }; + + resolve.normalize = function(fullName) { + if (resolver.normalize) { + return resolver.normalize(fullName); + } else { + return fullName; + } + }; + + resolve.__resolver__ = resolver; + + return resolve; + } + + __exports__["default"] = Application; + }); +define("ember-application/system/dag", + ["ember-metal/error","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var EmberError = __dependency1__["default"]; + + function visit(vertex, fn, visited, path) { + var name = vertex.name; + var vertices = vertex.incoming; + var names = vertex.incomingNames; + var len = names.length; + var i; + + if (!visited) { + visited = {}; + } + if (!path) { + path = []; + } + if (visited.hasOwnProperty(name)) { + return; + } + path.push(name); + visited[name] = true; + for (i = 0; i < len; i++) { + visit(vertices[names[i]], fn, visited, path); + } + fn(vertex, path); + path.pop(); + } + + + /** + * DAG stands for Directed acyclic graph. + * + * It is used to build a graph of dependencies checking that there isn't circular + * dependencies. p.e Registering initializers with a certain precedence order. + * + * @class DAG + * @constructor + */ + function DAG() { + this.names = []; + this.vertices = {}; + } + + /** + * Adds a vertex entry to the graph unless it is already added. + * + * @private + * @method add + * @param {String} name The name of the vertex to add + */ + DAG.prototype.add = function(name) { + if (!name) { return; } + if (this.vertices.hasOwnProperty(name)) { + return this.vertices[name]; + } + var vertex = { + name: name, incoming: {}, incomingNames: [], hasOutgoing: false, value: null + }; + this.vertices[name] = vertex; + this.names.push(name); + return vertex; + }; + + /** + * Adds a vertex to the graph and sets its value. + * + * @private + * @method map + * @param {String} name The name of the vertex. + * @param value The value to put in the vertex. + */ + DAG.prototype.map = function(name, value) { + this.add(name).value = value; + }; + + /** + * Connects the vertices with the given names, adding them to the graph if + * necesary, only if this does not produce is any circular dependency. + * + * @private + * @method addEdge + * @param {String} fromName The name the vertex where the edge starts. + * @param {String} toName The name the vertex where the edge ends. + */ + DAG.prototype.addEdge = function(fromName, toName) { + if (!fromName || !toName || fromName === toName) { + return; + } + var from = this.add(fromName), to = this.add(toName); + if (to.incoming.hasOwnProperty(fromName)) { + return; + } + function checkCycle(vertex, path) { + if (vertex.name === toName) { + throw new EmberError("cycle detected: " + toName + " <- " + path.join(" <- ")); + } + } + visit(from, checkCycle); + from.hasOutgoing = true; + to.incoming[fromName] = from; + to.incomingNames.push(fromName); + }; + + /** + * Visits all the vertex of the graph calling the given function with each one, + * ensuring that the vertices are visited respecting their precedence. + * + * @method topsort + * @param {Function} fn The function to be invoked on each vertex. + */ + DAG.prototype.topsort = function(fn) { + var visited = {}; + var vertices = this.vertices; + var names = this.names; + var len = names.length; + var i, vertex; + + for (i = 0; i < len; i++) { + vertex = vertices[names[i]]; + if (!vertex.hasOutgoing) { + visit(vertex, fn, visited); + } + } + }; + + /** + * Adds a vertex with the given name and value to the graph and joins it with the + * vertices referenced in _before_ and _after_. If there isn't vertices with those + * names, they are added too. + * + * If either _before_ or _after_ are falsy/empty, the added vertex will not have + * an incoming/outgoing edge. + * + * @method addEdges + * @param {String} name The name of the vertex to be added. + * @param value The value of that vertex. + * @param before An string or array of strings with the names of the vertices before + * which this vertex must be visited. + * @param after An string or array of strings with the names of the vertex after + * which this vertex must be visited. + * + */ + DAG.prototype.addEdges = function(name, value, before, after) { + var i; + this.map(name, value); + if (before) { + if (typeof before === 'string') { + this.addEdge(name, before); + } else { + for (i = 0; i < before.length; i++) { + this.addEdge(name, before[i]); + } + } + } + if (after) { + if (typeof after === 'string') { + this.addEdge(after, name); + } else { + for (i = 0; i < after.length; i++) { + this.addEdge(after[i], name); + } + } + } + }; + + __exports__["default"] = DAG; + }); +define("ember-application/system/resolver", + ["ember-metal/core","ember-metal/property_get","ember-metal/logger","ember-runtime/system/string","ember-runtime/system/object","ember-runtime/system/namespace","ember-handlebars","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-application + */ + + var Ember = __dependency1__["default"]; + // Ember.TEMPLATES, Ember.assert + var get = __dependency2__.get; + var Logger = __dependency3__["default"]; + var classify = __dependency4__.classify; + var capitalize = __dependency4__.capitalize; + var decamelize = __dependency4__.decamelize; + var EmberObject = __dependency5__["default"]; + var Namespace = __dependency6__["default"]; + var EmberHandlebars = __dependency7__["default"]; + + var Resolver = EmberObject.extend({ + /** + This will be set to the Application instance when it is + created. + + @property namespace + */ + namespace: null, + normalize: Ember.required(Function), + resolve: Ember.required(Function), + parseName: Ember.required(Function), + lookupDescription: Ember.required(Function), + makeToString: Ember.required(Function), + resolveOther: Ember.required(Function), + _logLookup: Ember.required(Function) + }); + __exports__.Resolver = Resolver; + /** + The DefaultResolver defines the default lookup rules to resolve + container lookups before consulting the container for registered + items: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after converting + the name. For example, `controller:post` looks up + `App.PostController` by default. + * there are some nuances (see examples below) + + ### How Resolving Works + + The container calls this object's `resolve` method with the + `fullName` argument. + + It first parses the fullName into an object using `parseName`. + + Then it checks for the presence of a type-specific instance + method of the form `resolve[Type]` and calls it if it exists. + For example if it was resolving 'template:post', it would call + the `resolveTemplate` method. + + Its last resort is to call the `resolveOther` method. + + The methods of this object are designed to be easy to override + in a subclass. For example, you could enhance how a template + is resolved like so: + + ```javascript + App = Ember.Application.create({ + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + var resolvedTemplate = this._super(parsedName); + if (resolvedTemplate) { return resolvedTemplate; } + return Ember.TEMPLATES['not_found']; + } + }) + }); + ``` + + Some examples of how names are resolved: + + ``` + 'template:post' //=> Ember.TEMPLATES['post'] + 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] + // OR + // Ember.TEMPLATES['blog_post'] + 'controller:post' //=> App.PostController + 'controller:posts.index' //=> App.PostsIndexController + 'controller:blog/post' //=> Blog.PostController + 'controller:basic' //=> Ember.Controller + 'route:post' //=> App.PostRoute + 'route:posts.index' //=> App.PostsIndexRoute + 'route:blog/post' //=> Blog.PostRoute + 'route:basic' //=> Ember.Route + 'view:post' //=> App.PostView + 'view:posts.index' //=> App.PostsIndexView + 'view:blog/post' //=> Blog.PostView + 'view:basic' //=> Ember.View + 'foo:post' //=> App.PostFoo + 'model:post' //=> App.Post + ``` + + @class DefaultResolver + @namespace Ember + @extends Ember.Object + */ + + __exports__["default"] = EmberObject.extend({ + /** + This will be set to the Application instance when it is + created. + + @property namespace + */ + namespace: null, + + normalize: function(fullName) { + var split = fullName.split(':', 2), + type = split[0], + name = split[1]; + + + if (type !== 'template') { + var result = name; + + if (result.indexOf('.') > -1) { + result = result.replace(/\.(.)/g, function(m) { return m.charAt(1).toUpperCase(); }); + } + + if (name.indexOf('_') > -1) { + result = result.replace(/_(.)/g, function(m) { return m.charAt(1).toUpperCase(); }); + } + + return type + ':' + result; + } else { + return fullName; + } + }, + + + /** + This method is called via the container's resolver method. + It parses the provided `fullName` and then looks up and + returns the appropriate template or class. + + @method resolve + @param {String} fullName the lookup string + @return {Object} the resolved factory + */ + resolve: function(fullName) { + var parsedName = this.parseName(fullName), + resolveMethodName = parsedName.resolveMethodName, + resolved; + + if (!(parsedName.name && parsedName.type)) { + throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); + } + + if (this[resolveMethodName]) { + resolved = this[resolveMethodName](parsedName); + } + + if (!resolved) { + resolved = this.resolveOther(parsedName); + } + + if (parsedName.root && parsedName.root.LOG_RESOLVER) { + this._logLookup(resolved, parsedName); + } + + return resolved; + }, + /** + Convert the string name of the form 'type:name' to + a Javascript object with the parsed aspects of the name + broken out. + + @protected + @param {String} fullName the lookup string + @method parseName + */ + parseName: function(fullName) { + var nameParts = fullName.split(':'), + type = nameParts[0], fullNameWithoutType = nameParts[1], + name = fullNameWithoutType, + namespace = get(this, 'namespace'), + root = namespace; + + if (type !== 'template' && name.indexOf('/') !== -1) { + var parts = name.split('/'); + name = parts[parts.length - 1]; + var namespaceName = capitalize(parts.slice(0, -1).join('.')); + root = Namespace.byName(namespaceName); + + } + + return { + fullName: fullName, + type: type, + fullNameWithoutType: fullNameWithoutType, + name: name, + root: root, + resolveMethodName: 'resolve' + classify(type) + }; + }, + + /** + Returns a human-readable description for a fullName. Used by the + Application namespace in assertions to describe the + precise name of the class that Ember is looking for, rather than + container keys. + + @protected + @param {String} fullName the lookup string + @method lookupDescription + */ + lookupDescription: function(fullName) { + var parsedName = this.parseName(fullName); + + if (parsedName.type === 'template') { + return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + } + + var description = parsedName.root + '.' + classify(parsedName.name); + if (parsedName.type !== 'model') { description += classify(parsedName.type); } + + return description; + }, + + makeToString: function(factory, fullName) { + return factory.toString(); + }, + /** + Given a parseName object (output from `parseName`), apply + the conventions expected by `Ember.Router` + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method useRouterNaming + */ + useRouterNaming: function(parsedName) { + parsedName.name = parsedName.name.replace(/\./g, '_'); + if (parsedName.name === 'basic') { + parsedName.name = ''; + } + }, + /** + Look up the template in Ember.TEMPLATES + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveTemplate + */ + resolveTemplate: function(parsedName) { + var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); + + if (Ember.TEMPLATES[templateName]) { + return Ember.TEMPLATES[templateName]; + } + + templateName = decamelize(templateName); + if (Ember.TEMPLATES[templateName]) { + return Ember.TEMPLATES[templateName]; + } + }, + /** + Lookup the view using `resolveOther` + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveView + */ + resolveView: function(parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + /** + Lookup the controller using `resolveOther` + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveController + */ + resolveController: function(parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + /** + Lookup the route using `resolveOther` + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveRoute + */ + resolveRoute: function(parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + + /** + Lookup the model on the Application namespace + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveModel + */ + resolveModel: function(parsedName) { + var className = classify(parsedName.name); + var factory = get(parsedName.root, className); + + if (factory) { return factory; } + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveHelper + */ + resolveHelper: function(parsedName) { + return this.resolveOther(parsedName) || EmberHandlebars.helpers[parsedName.fullNameWithoutType]; + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + + @protected + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveOther + */ + resolveOther: function(parsedName) { + var className = classify(parsedName.name) + classify(parsedName.type); + var factory = get(parsedName.root, className); + if (factory) { return factory; } + }, + + /** + @method _logLookup + @param {Boolean} found + @param {Object} parsedName + @private + */ + _logLookup: function(found, parsedName) { + var symbol, padding; + + if (found) { symbol = '[✓]'; } + else { symbol = '[ ]'; } + + if (parsedName.fullName.length > 60) { + padding = '.'; + } else { + padding = new Array(60 - parsedName.fullName.length).join('.'); + } + + Logger.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); + } + }); + }); +define("ember-extension-support", + ["ember-metal/core","ember-extension-support/data_adapter","ember-extension-support/container_debug_adapter"], + function(__dependency1__, __dependency2__, __dependency3__) { + "use strict"; + /** + Ember Extension Support + + @module ember + @submodule ember-extension-support + @requires ember-application + */ + + var Ember = __dependency1__["default"]; + var DataAdapter = __dependency2__["default"]; + var ContainerDebugAdapter = __dependency3__["default"]; + + Ember.DataAdapter = DataAdapter; + Ember.ContainerDebugAdapter = ContainerDebugAdapter; + }); +define("ember-extension-support/container_debug_adapter", + ["ember-metal/core","ember-runtime/system/native_array","ember-metal/utils","ember-runtime/system/string","ember-runtime/system/namespace","ember-runtime/system/object","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + var emberA = __dependency2__.A; + var typeOf = __dependency3__.typeOf; + var dasherize = __dependency4__.dasherize; + var classify = __dependency4__.classify; + var Namespace = __dependency5__["default"]; + var EmberObject = __dependency6__["default"]; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `ContainerDebugAdapter` helps the container and resolver interface + with tools that debug Ember such as the + [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class can be extended by a custom resolver implementer + to override some of the methods with library-specific code. + + The methods likely to be overridden are: + + * `canCatalogEntriesByType` + * `catalogEntriesByType` + + The adapter will need to be registered + in the application's container as `container-debug-adapter:main` + + Example: + + ```javascript + Application.initializer({ + name: "containerDebugAdapter", + + initialize: function(container, application) { + application.register('container-debug-adapter:main', require('app/container-debug-adapter')); + } + }); + ``` + + @class ContainerDebugAdapter + @namespace Ember + @extends EmberObject + @since 1.5.0 + */ + __exports__["default"] = EmberObject.extend({ + /** + The container of the application being debugged. + This property will be injected + on creation. + + @property container + @default null + */ + container: null, + + /** + The resolver instance of the application + being debugged. This property will be injected + on creation. + + @property resolver + @default null + */ + resolver: null, + + /** + Returns true if it is possible to catalog a list of available + classes in the resolver for a given type. + + @method canCatalogEntriesByType + @param {string} type The type. e.g. "model", "controller", "route" + @return {boolean} whether a list is available for this type. + */ + canCatalogEntriesByType: function(type) { + if (type === 'model' || type === 'template') return false; + return true; + }, + + /** + Returns the available classes a given type. + + @method catalogEntriesByType + @param {string} type The type. e.g. "model", "controller", "route" + @return {Array} An array of strings. + */ + catalogEntriesByType: function(type) { + var namespaces = emberA(Namespace.NAMESPACES), types = emberA(), self = this; + var typeSuffixRegex = new RegExp(classify(type) + "$"); + + namespaces.forEach(function(namespace) { + if (namespace !== Ember) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { continue; } + if (typeSuffixRegex.test(key)) { + var klass = namespace[key]; + if (typeOf(klass) === 'class') { + types.push(dasherize(key.replace(typeSuffixRegex, ''))); + } + } + } + } + }); + return types; + } + }); + }); +define("ember-extension-support/data_adapter", + ["ember-metal/core","ember-metal/property_get","ember-metal/run_loop","ember-runtime/system/string","ember-runtime/system/namespace","ember-runtime/system/object","ember-runtime/system/native_array","ember-application/system/application","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + var get = __dependency2__.get; + var run = __dependency3__["default"]; + var dasherize = __dependency4__.dasherize; + var Namespace = __dependency5__["default"]; + var EmberObject = __dependency6__["default"]; + var emberA = __dependency7__.A; + var Application = __dependency8__["default"]; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `DataAdapter` helps a data persistence library + interface with tools that debug Ember such + as the [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class will be extended by a persistence library + which will override some of the methods with + library-specific code. + + The methods likely to be overridden are: + + * `getFilters` + * `detect` + * `columnsForType` + * `getRecords` + * `getRecordColumnValues` + * `getRecordKeywords` + * `getRecordFilterValues` + * `getRecordColor` + * `observeRecord` + + The adapter will need to be registered + in the application's container as `dataAdapter:main` + + Example: + + ```javascript + Application.initializer({ + name: "data-adapter", + + initialize: function(container, application) { + application.register('data-adapter:main', DS.DataAdapter); + } + }); + ``` + + @class DataAdapter + @namespace Ember + @extends EmberObject + */ + __exports__["default"] = EmberObject.extend({ + init: function() { + this._super(); + this.releaseMethods = emberA(); + }, + + /** + The container of the application being debugged. + This property will be injected + on creation. + + @property container + @default null + @since 1.3.0 + */ + container: null, + + + /** + The container-debug-adapter which is used + to list all models. + + @property containerDebugAdapter + @default undefined + @since 1.5.0 + **/ + containerDebugAdapter: undefined, + + /** + Number of attributes to send + as columns. (Enough to make the record + identifiable). + + @private + @property attributeLimit + @default 3 + @since 1.3.0 + */ + attributeLimit: 3, + + /** + Stores all methods that clear observers. + These methods will be called on destruction. + + @private + @property releaseMethods + @since 1.3.0 + */ + releaseMethods: emberA(), + + /** + Specifies how records can be filtered. + Records returned will need to have a `filterValues` + property with a key for every name in the returned array. + + @public + @method getFilters + @return {Array} List of objects defining filters. + The object should have a `name` and `desc` property. + */ + getFilters: function() { + return emberA(); + }, + + /** + Fetch the model types and observe them for changes. + + @public + @method watchModelTypes + + @param {Function} typesAdded Callback to call to add types. + Takes an array of objects containing wrapped types (returned from `wrapModelType`). + + @param {Function} typesUpdated Callback to call when a type has changed. + Takes an array of objects containing wrapped types. + + @return {Function} Method to call to remove all observers + */ + watchModelTypes: function(typesAdded, typesUpdated) { + var modelTypes = this.getModelTypes(), + self = this, typesToSend, releaseMethods = emberA(); + + typesToSend = modelTypes.map(function(type) { + var klass = type.klass; + var wrapped = self.wrapModelType(klass, type.name); + releaseMethods.push(self.observeModelType(klass, typesUpdated)); + return wrapped; + }); + + typesAdded(typesToSend); + + var release = function() { + releaseMethods.forEach(function(fn) { fn(); }); + self.releaseMethods.removeObject(release); + }; + this.releaseMethods.pushObject(release); + return release; + }, + + _nameToClass: function(type) { + if (typeof type === 'string') { + type = this.container.lookupFactory('model:' + type); + } + return type; + }, + + /** + Fetch the records of a given type and observe them for changes. + + @public + @method watchRecords + + @param {Function} recordsAdded Callback to call to add records. + Takes an array of objects containing wrapped records. + The object should have the following properties: + columnValues: {Object} key and value of a table cell + object: {Object} the actual record object + + @param {Function} recordsUpdated Callback to call when a record has changed. + Takes an array of objects containing wrapped records. + + @param {Function} recordsRemoved Callback to call when a record has removed. + Takes the following parameters: + index: the array index where the records were removed + count: the number of records removed + + @return {Function} Method to call to remove all observers + */ + watchRecords: function(type, recordsAdded, recordsUpdated, recordsRemoved) { + var self = this, releaseMethods = emberA(), records = this.getRecords(type), release; + + var recordUpdated = function(updatedRecord) { + recordsUpdated([updatedRecord]); + }; + + var recordsToSend = records.map(function(record) { + releaseMethods.push(self.observeRecord(record, recordUpdated)); + return self.wrapRecord(record); + }); + + + var contentDidChange = function(array, idx, removedCount, addedCount) { + for (var i = idx; i < idx + addedCount; i++) { + var record = array.objectAt(i); + var wrapped = self.wrapRecord(record); + releaseMethods.push(self.observeRecord(record, recordUpdated)); + recordsAdded([wrapped]); + } + + if (removedCount) { + recordsRemoved(idx, removedCount); + } + }; + + var observer = { didChange: contentDidChange, willChange: Ember.K }; + records.addArrayObserver(self, observer); + + release = function() { + releaseMethods.forEach(function(fn) { fn(); }); + records.removeArrayObserver(self, observer); + self.releaseMethods.removeObject(release); + }; + + recordsAdded(recordsToSend); + + this.releaseMethods.pushObject(release); + return release; + }, + + /** + Clear all observers before destruction + @private + @method willDestroy + */ + willDestroy: function() { + this._super(); + this.releaseMethods.forEach(function(fn) { + fn(); + }); + }, + + /** + Detect whether a class is a model. + + Test that against the model class + of your persistence library + + @private + @method detect + @param {Class} klass The class to test + @return boolean Whether the class is a model class or not + */ + detect: function(klass) { + return false; + }, + + /** + Get the columns for a given model type. + + @private + @method columnsForType + @param {Class} type The model type + @return {Array} An array of columns of the following format: + name: {String} name of the column + desc: {String} Humanized description (what would show in a table column name) + */ + columnsForType: function(type) { + return emberA(); + }, + + /** + Adds observers to a model type class. + + @private + @method observeModelType + @param {Class} type The model type class + @param {Function} typesUpdated Called when a type is modified. + @return {Function} The function to call to remove observers + */ + + observeModelType: function(type, typesUpdated) { + var self = this, records = this.getRecords(type); + + var onChange = function() { + typesUpdated([self.wrapModelType(type)]); + }; + var observer = { + didChange: function() { + run.scheduleOnce('actions', this, onChange); + }, + willChange: Ember.K + }; + + records.addArrayObserver(this, observer); + + var release = function() { + records.removeArrayObserver(self, observer); + }; + + return release; + }, + + + /** + Wraps a given model type and observes changes to it. + + @private + @method wrapModelType + @param {Class} type A model class + @param {String} Optional name of the class + @return {Object} contains the wrapped type and the function to remove observers + Format: + type: {Object} the wrapped type + The wrapped type has the following format: + name: {String} name of the type + count: {Integer} number of records available + columns: {Columns} array of columns to describe the record + object: {Class} the actual Model type class + release: {Function} The function to remove observers + */ + wrapModelType: function(type, name) { + var release, records = this.getRecords(type), + typeToSend, self = this; + + typeToSend = { + name: name || type.toString(), + count: get(records, 'length'), + columns: this.columnsForType(type), + object: type + }; + + + return typeToSend; + }, + + + /** + Fetches all models defined in the application. + + @private + @method getModelTypes + @return {Array} Array of model types + */ + getModelTypes: function() { + var types, self = this, + containerDebugAdapter = this.get('containerDebugAdapter'); + + if (containerDebugAdapter.canCatalogEntriesByType('model')) { + types = containerDebugAdapter.catalogEntriesByType('model'); + } else { + types = this._getObjectsOnNamespaces(); + } + + // New adapters return strings instead of classes + types = emberA(types).map(function(name) { + return { + klass: self._nameToClass(name), + name: name + }; + }); + types = emberA(types).filter(function(type) { + return self.detect(type.klass); + }); + + return emberA(types); + }, + + /** + Loops over all namespaces and all objects + attached to them + + @private + @method _getObjectsOnNamespaces + @return {Array} Array of model type strings + */ + _getObjectsOnNamespaces: function() { + var namespaces = emberA(Namespace.NAMESPACES), + types = emberA(), + self = this; + + namespaces.forEach(function(namespace) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { continue; } + // Even though we will filter again in `getModelTypes`, + // we should not call `lookupContainer` on non-models + // (especially when `Ember.MODEL_FACTORY_INJECTIONS` is `true`) + if (!self.detect(namespace[key])) { continue; } + var name = dasherize(key); + if (!(namespace instanceof Application) && namespace.toString()) { + name = namespace + '/' + name; + } + types.push(name); + } + }); + return types; + }, + + /** + Fetches all loaded records for a given type. + + @private + @method getRecords + @return {Array} An array of records. + This array will be observed for changes, + so it should update when new records are added/removed. + */ + getRecords: function(type) { + return emberA(); + }, + + /** + Wraps a record and observers changes to it. + + @private + @method wrapRecord + @param {Object} record The record instance. + @return {Object} The wrapped record. Format: + columnValues: {Array} + searchKeywords: {Array} + */ + wrapRecord: function(record) { + var recordToSend = { object: record }, columnValues = {}, self = this; + + recordToSend.columnValues = this.getRecordColumnValues(record); + recordToSend.searchKeywords = this.getRecordKeywords(record); + recordToSend.filterValues = this.getRecordFilterValues(record); + recordToSend.color = this.getRecordColor(record); + + return recordToSend; + }, + + /** + Gets the values for each column. + + @private + @method getRecordColumnValues + @return {Object} Keys should match column names defined + by the model type. + */ + getRecordColumnValues: function(record) { + return {}; + }, + + /** + Returns keywords to match when searching records. + + @private + @method getRecordKeywords + @return {Array} Relevant keywords for search. + */ + getRecordKeywords: function(record) { + return emberA(); + }, + + /** + Returns the values of filters defined by `getFilters`. + + @private + @method getRecordFilterValues + @param {Object} record The record instance + @return {Object} The filter values + */ + getRecordFilterValues: function(record) { + return {}; + }, + + /** + Each record can have a color that represents its state. + + @private + @method getRecordColor + @param {Object} record The record instance + @return {String} The record's color + Possible options: black, red, blue, green + */ + getRecordColor: function(record) { + return null; + }, + + /** + Observes all relevant properties and re-sends the wrapped record + when a change occurs. + + @private + @method observerRecord + @param {Object} record The record instance + @param {Function} recordUpdated The callback to call when a record is updated. + @return {Function} The function to call to remove all observers. + */ + observeRecord: function(record, recordUpdated) { + return function(){}; + } + }); + }); +define("ember-extension-support/initializers", + [], + function() { + "use strict"; + + }); +define("ember-handlebars-compiler", + ["ember-metal/core","exports"], + function(__dependency1__, __exports__) { + "use strict"; + /* global Handlebars:true */ + + /** + @module ember + @submodule ember-handlebars-compiler + */ + + var Ember = __dependency1__["default"]; + + // ES6Todo: you'll need to import debugger once debugger is es6'd. + if (typeof Ember.assert === 'undefined') { Ember.assert = function(){}; } + if (typeof Ember.FEATURES === 'undefined') { Ember.FEATURES = { isEnabled: function(){} }; } + + var objectCreate = Object.create || function(parent) { + function F() {} + F.prototype = parent; + return new F(); + }; + + // set up for circular references later + var View, Component; + + // ES6Todo: when ember-debug is es6'ed import this. + // var emberAssert = Ember.assert; + var Handlebars = (Ember.imports && Ember.imports.Handlebars) || (this && this.Handlebars); + if (!Handlebars && typeof require === 'function') { + Handlebars = require('handlebars'); + } + + + + /** + Prepares the Handlebars templating library for use inside Ember's view + system. + + The `Ember.Handlebars` object is the standard Handlebars library, extended to + use Ember's `get()` method instead of direct property access, which allows + computed properties to be used inside templates. + + To create an `Ember.Handlebars` template, call `Ember.Handlebars.compile()`. + This will return a function that can be used by `Ember.View` for rendering. + + @class Handlebars + @namespace Ember + */ + var EmberHandlebars = Ember.Handlebars = objectCreate(Handlebars); + + /** + Register a bound helper or custom view helper. + + ## Simple bound helper example + + ```javascript + Ember.Handlebars.helper('capitalize', function(value) { + return value.toUpperCase(); + }); + ``` + + The above bound helper can be used inside of templates as follows: + + ```handlebars + {{capitalize name}} + ``` + + In this case, when the `name` property of the template's context changes, + the rendered value of the helper will update to reflect this change. + + For more examples of bound helpers, see documentation for + `Ember.Handlebars.registerBoundHelper`. + + ## Custom view helper example + + Assuming a view subclass named `App.CalendarView` were defined, a helper + for rendering instances of this view could be registered as follows: + + ```javascript + Ember.Handlebars.helper('calendar', App.CalendarView): + ``` + + The above bound helper can be used inside of templates as follows: + + ```handlebars + {{calendar}} + ``` + + Which is functionally equivalent to: + + ```handlebars + {{view App.CalendarView}} + ``` + + Options in the helper will be passed to the view in exactly the same + manner as with the `view` helper. + + @method helper + @for Ember.Handlebars + @param {String} name + @param {Function|Ember.View} function or view class constructor + @param {String} dependentKeys* + */ + EmberHandlebars.helper = function(name, value) { + if (!View) { View = requireModule('ember-views/views/view')['default']; } // ES6TODO: stupid circular dep + if (!Component) { Component = requireModule('ember-views/views/component')['default']; } // ES6TODO: stupid circular dep + + + if (View.detect(value)) { + EmberHandlebars.registerHelper(name, EmberHandlebars.makeViewHelper(value)); + } else { + EmberHandlebars.registerBoundHelper.apply(null, arguments); + } + }; + + /** + Returns a helper function that renders the provided ViewClass. + + Used internally by Ember.Handlebars.helper and other methods + involving helper/component registration. + + @private + @method makeViewHelper + @for Ember.Handlebars + @param {Function} ViewClass view class constructor + @since 1.2.0 + */ + EmberHandlebars.makeViewHelper = function(ViewClass) { + return function(options) { + return EmberHandlebars.helpers.view.call(this, ViewClass, options); + }; + }; + + /** + @class helpers + @namespace Ember.Handlebars + */ + EmberHandlebars.helpers = objectCreate(Handlebars.helpers); + + /** + Override the the opcode compiler and JavaScript compiler for Handlebars. + + @class Compiler + @namespace Ember.Handlebars + @private + @constructor + */ + EmberHandlebars.Compiler = function() {}; + + // Handlebars.Compiler doesn't exist in runtime-only + if (Handlebars.Compiler) { + EmberHandlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); + } + + EmberHandlebars.Compiler.prototype.compiler = EmberHandlebars.Compiler; + + /** + @class JavaScriptCompiler + @namespace Ember.Handlebars + @private + @constructor + */ + EmberHandlebars.JavaScriptCompiler = function() {}; + + // Handlebars.JavaScriptCompiler doesn't exist in runtime-only + if (Handlebars.JavaScriptCompiler) { + EmberHandlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); + EmberHandlebars.JavaScriptCompiler.prototype.compiler = EmberHandlebars.JavaScriptCompiler; + } + + + EmberHandlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; + + EmberHandlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { + return "''"; + }; + + /** + Override the default buffer for Ember Handlebars. By default, Handlebars + creates an empty String at the beginning of each invocation and appends to + it. Ember's Handlebars overrides this to append to a single shared buffer. + + @private + @method appendToBuffer + @param string {String} + */ + EmberHandlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) { + return "data.buffer.push("+string+");"; + }; + + // Hacks ahead: + // Handlebars presently has a bug where the `blockHelperMissing` hook + // doesn't get passed the name of the missing helper name, but rather + // gets passed the value of that missing helper evaluated on the current + // context, which is most likely `undefined` and totally useless. + // + // So we alter the compiled template function to pass the name of the helper + // instead, as expected. + // + // This can go away once the following is closed: + // https://github.com/wycats/handlebars.js/issues/634 + + var DOT_LOOKUP_REGEX = /helpers\.(.*?)\)/, + BRACKET_STRING_LOOKUP_REGEX = /helpers\['(.*?)'/, + INVOCATION_SPLITTING_REGEX = /(.*blockHelperMissing\.call\(.*)(stack[0-9]+)(,.*)/; + + EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation = function(source) { + var helperInvocation = source[source.length - 1], + helperName = (DOT_LOOKUP_REGEX.exec(helperInvocation) || BRACKET_STRING_LOOKUP_REGEX.exec(helperInvocation))[1], + matches = INVOCATION_SPLITTING_REGEX.exec(helperInvocation); + + source[source.length - 1] = matches[1] + "'" + helperName + "'" + matches[3]; + }; + + var stringifyBlockHelperMissing = EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation; + + var originalBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.blockValue; + EmberHandlebars.JavaScriptCompiler.prototype.blockValue = function() { + originalBlockValue.apply(this, arguments); + stringifyBlockHelperMissing(this.source); + }; + + var originalAmbiguousBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue; + EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue = function() { + originalAmbiguousBlockValue.apply(this, arguments); + stringifyBlockHelperMissing(this.source); + }; + + /** + Rewrite simple mustaches from `{{foo}}` to `{{bind "foo"}}`. This means that + all simple mustaches in Ember's Handlebars will also set up an observer to + keep the DOM up to date when the underlying property changes. + + @private + @method mustache + @for Ember.Handlebars.Compiler + @param mustache + */ + EmberHandlebars.Compiler.prototype.mustache = function(mustache) { + if (!(mustache.params.length || mustache.hash)) { + var id = new Handlebars.AST.IdNode([{ part: '_triageMustache' }]); + + // Update the mustache node to include a hash value indicating whether the original node + // was escaped. This will allow us to properly escape values when the underlying value + // changes and we need to re-render the value. + if (!mustache.escaped) { + mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]); + mustache.hash.pairs.push(["unescaped", new Handlebars.AST.StringNode("true")]); + } + mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped); + } + + return Handlebars.Compiler.prototype.mustache.call(this, mustache); + }; + + /** + Used for precompilation of Ember Handlebars templates. This will not be used + during normal app execution. + + @method precompile + @for Ember.Handlebars + @static + @param {String} string The template to precompile + @param {Boolean} asObject optional parameter, defaulting to true, of whether or not the + compiled template should be returned as an Object or a String + */ + EmberHandlebars.precompile = function(string, asObject) { + var ast = Handlebars.parse(string); + + var options = { + knownHelpers: { + action: true, + unbound: true, + 'bind-attr': true, + template: true, + view: true, + _triageMustache: true + }, + data: true, + stringParams: true + }; + + asObject = asObject === undefined ? true : asObject; + + var environment = new EmberHandlebars.Compiler().compile(ast, options); + return new EmberHandlebars.JavaScriptCompiler().compile(environment, options, undefined, asObject); + }; + + // We don't support this for Handlebars runtime-only + if (Handlebars.compile) { + /** + The entry point for Ember Handlebars. This replaces the default + `Handlebars.compile` and turns on template-local data and String + parameters. + + @method compile + @for Ember.Handlebars + @static + @param {String} string The template to compile + @return {Function} + */ + EmberHandlebars.compile = function(string) { + var ast = Handlebars.parse(string); + var options = { data: true, stringParams: true }; + var environment = new EmberHandlebars.Compiler().compile(ast, options); + var templateSpec = new EmberHandlebars.JavaScriptCompiler().compile(environment, options, undefined, true); + + var template = EmberHandlebars.template(templateSpec); + template.isMethod = false; //Make sure we don't wrap templates with ._super + + return template; + }; + } + + __exports__["default"] = EmberHandlebars; + }); +define("ember-handlebars", + ["ember-handlebars-compiler","ember-metal/core","ember-runtime/system/lazy_load","ember-handlebars/loader","ember-handlebars/ext","ember-handlebars/string","ember-handlebars/helpers/shared","ember-handlebars/helpers/binding","ember-handlebars/helpers/collection","ember-handlebars/helpers/view","ember-handlebars/helpers/unbound","ember-handlebars/helpers/debug","ember-handlebars/helpers/each","ember-handlebars/helpers/template","ember-handlebars/helpers/partial","ember-handlebars/helpers/yield","ember-handlebars/helpers/loc","ember-handlebars/controls/checkbox","ember-handlebars/controls/select","ember-handlebars/controls/text_area","ember-handlebars/controls/text_field","ember-handlebars/controls/text_support","ember-handlebars/controls","ember-handlebars/component_lookup","ember-handlebars/views/handlebars_bound_view","ember-handlebars/views/metamorph_view","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __dependency23__, __dependency24__, __dependency25__, __dependency26__, __exports__) { + "use strict"; + var EmberHandlebars = __dependency1__["default"]; + var Ember = __dependency2__["default"]; + // to add to globals + + var runLoadHooks = __dependency3__.runLoadHooks; + var bootstrap = __dependency4__["default"]; + + var normalizePath = __dependency5__.normalizePath; + var template = __dependency5__.template; + var makeBoundHelper = __dependency5__.makeBoundHelper; + var registerBoundHelper = __dependency5__.registerBoundHelper; + var resolveHash = __dependency5__.resolveHash; + var resolveParams = __dependency5__.resolveParams; + var getEscaped = __dependency5__.getEscaped; + var handlebarsGet = __dependency5__.handlebarsGet; + var evaluateUnboundHelper = __dependency5__.evaluateUnboundHelper; + var helperMissingHelper = __dependency5__.helperMissingHelper; + var blockHelperMissingHelper = __dependency5__.blockHelperMissingHelper; + + + // side effect of extending StringUtils of htmlSafe + + var resolvePaths = __dependency7__["default"]; + var bind = __dependency8__.bind; + var _triageMustacheHelper = __dependency8__._triageMustacheHelper; + var resolveHelper = __dependency8__.resolveHelper; + var bindHelper = __dependency8__.bindHelper; + var boundIfHelper = __dependency8__.boundIfHelper; + var unboundIfHelper = __dependency8__.unboundIfHelper; + var withHelper = __dependency8__.withHelper; + var ifHelper = __dependency8__.ifHelper; + var unlessHelper = __dependency8__.unlessHelper; + var bindAttrHelper = __dependency8__.bindAttrHelper; + var bindAttrHelperDeprecated = __dependency8__.bindAttrHelperDeprecated; + var bindClasses = __dependency8__.bindClasses; + + var collectionHelper = __dependency9__["default"]; + var ViewHelper = __dependency10__.ViewHelper; + var viewHelper = __dependency10__.viewHelper; + var unboundHelper = __dependency11__["default"]; + var logHelper = __dependency12__.logHelper; + var debuggerHelper = __dependency12__.debuggerHelper; + var EachView = __dependency13__.EachView; + var GroupedEach = __dependency13__.GroupedEach; + var eachHelper = __dependency13__.eachHelper; + var templateHelper = __dependency14__["default"]; + var partialHelper = __dependency15__["default"]; + var yieldHelper = __dependency16__["default"]; + var locHelper = __dependency17__["default"]; + + + var Checkbox = __dependency18__["default"]; + var Select = __dependency19__.Select; + var SelectOption = __dependency19__.SelectOption; + var SelectOptgroup = __dependency19__.SelectOptgroup; + var TextArea = __dependency20__["default"]; + var TextField = __dependency21__["default"]; + var TextSupport = __dependency22__["default"]; + var inputHelper = __dependency23__.inputHelper; + var textareaHelper = __dependency23__.textareaHelper; + + + var ComponentLookup = __dependency24__["default"]; + var _HandlebarsBoundView = __dependency25__._HandlebarsBoundView; + var SimpleHandlebarsView = __dependency25__.SimpleHandlebarsView; + var _wrapMap = __dependency26__._wrapMap; + var _SimpleMetamorphView = __dependency26__._SimpleMetamorphView; + var _MetamorphView = __dependency26__._MetamorphView; + var _Metamorph = __dependency26__._Metamorph; + + + /** + Ember Handlebars + + @module ember + @submodule ember-handlebars + @requires ember-views + */ + + // Ember.Handlebars.Globals + EmberHandlebars.bootstrap = bootstrap; + EmberHandlebars.template = template; + EmberHandlebars.makeBoundHelper = makeBoundHelper; + EmberHandlebars.registerBoundHelper = registerBoundHelper; + EmberHandlebars.resolveHash = resolveHash; + EmberHandlebars.resolveParams = resolveParams; + EmberHandlebars.resolveHelper = resolveHelper; + EmberHandlebars.get = handlebarsGet; + EmberHandlebars.getEscaped = getEscaped; + EmberHandlebars.evaluateUnboundHelper = evaluateUnboundHelper; + EmberHandlebars.bind = bind; + EmberHandlebars.bindClasses = bindClasses; + EmberHandlebars.EachView = EachView; + EmberHandlebars.GroupedEach = GroupedEach; + EmberHandlebars.resolvePaths = resolvePaths; + EmberHandlebars.ViewHelper = ViewHelper; + EmberHandlebars.normalizePath = normalizePath; + + + // Ember Globals + Ember.Handlebars = EmberHandlebars; + Ember.ComponentLookup = ComponentLookup; + Ember._SimpleHandlebarsView = SimpleHandlebarsView; + Ember._HandlebarsBoundView = _HandlebarsBoundView; + Ember._SimpleMetamorphView = _SimpleMetamorphView; + Ember._MetamorphView = _MetamorphView; + Ember._Metamorph = _Metamorph; + Ember._metamorphWrapMap = _wrapMap; + Ember.TextSupport = TextSupport; + Ember.Checkbox = Checkbox; + Ember.Select = Select; + Ember.SelectOption = SelectOption; + Ember.SelectOptgroup = SelectOptgroup; + Ember.TextArea = TextArea; + Ember.TextField = TextField; + Ember.TextSupport = TextSupport; + + // register helpers + EmberHandlebars.registerHelper('helperMissing', helperMissingHelper); + EmberHandlebars.registerHelper('blockHelperMissing', blockHelperMissingHelper); + EmberHandlebars.registerHelper('bind', bindHelper); + EmberHandlebars.registerHelper('boundIf', boundIfHelper); + EmberHandlebars.registerHelper('_triageMustache', _triageMustacheHelper); + EmberHandlebars.registerHelper('unboundIf', unboundIfHelper); + EmberHandlebars.registerHelper('with', withHelper); + EmberHandlebars.registerHelper('if', ifHelper); + EmberHandlebars.registerHelper('unless', unlessHelper); + EmberHandlebars.registerHelper('bind-attr', bindAttrHelper); + EmberHandlebars.registerHelper('bindAttr', bindAttrHelperDeprecated); + EmberHandlebars.registerHelper('collection', collectionHelper); + EmberHandlebars.registerHelper("log", logHelper); + EmberHandlebars.registerHelper("debugger", debuggerHelper); + EmberHandlebars.registerHelper("each", eachHelper); + EmberHandlebars.registerHelper("loc", locHelper); + EmberHandlebars.registerHelper("partial", partialHelper); + EmberHandlebars.registerHelper("template", templateHelper); + EmberHandlebars.registerHelper("yield", yieldHelper); + EmberHandlebars.registerHelper("view", viewHelper); + EmberHandlebars.registerHelper("unbound", unboundHelper); + EmberHandlebars.registerHelper("input", inputHelper); + EmberHandlebars.registerHelper("textarea", textareaHelper); + + // run load hooks + runLoadHooks('Ember.Handlebars', EmberHandlebars); + + __exports__["default"] = EmberHandlebars; + }); +define("ember-handlebars/component_lookup", + ["ember-runtime/system/object","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var EmberObject = __dependency1__["default"]; + + var ComponentLookup = EmberObject.extend({ + lookupFactory: function(name, container) { + + container = container || this.container; + + var fullName = 'component:' + name, + templateFullName = 'template:components/' + name, + templateRegistered = container && container.has(templateFullName); + + if (templateRegistered) { + container.injection(fullName, 'layout', templateFullName); + } + + var Component = container.lookupFactory(fullName); + + // Only treat as a component if either the component + // or a template has been registered. + if (templateRegistered || Component) { + if (!Component) { + container.register(fullName, Ember.Component); + Component = container.lookupFactory(fullName); + } + return Component; + } + } + }); + + __exports__["default"] = ComponentLookup; + }); +define("ember-handlebars/controls", + ["ember-handlebars/controls/checkbox","ember-handlebars/controls/text_field","ember-handlebars/controls/text_area","ember-metal/core","ember-handlebars-compiler","ember-handlebars/ext","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __exports__) { + "use strict"; + var Checkbox = __dependency1__["default"]; + var TextField = __dependency2__["default"]; + var TextArea = __dependency3__["default"]; + + var Ember = __dependency4__["default"]; + // Ember.assert + // var emberAssert = Ember.assert; + + var EmberHandlebars = __dependency5__["default"]; + var handlebarsGet = __dependency6__.handlebarsGet; + var helpers = EmberHandlebars.helpers; + /** + @module ember + @submodule ember-handlebars-compiler + */ + + function _resolveOption(context, options, key) { + if (options.hashTypes[key] === "ID") { + return handlebarsGet(context, options.hash[key], options); + } else { + return options.hash[key]; + } + } + + /** + + The `{{input}}` helper inserts an HTML `` tag into the template, + with a `type` value of either `text` or `checkbox`. If no `type` is provided, + `text` will be the default value applied. The attributes of `{{input}}` + match those of the native HTML tag as closely as possible for these two types. + + ## Use as text field + An `{{input}}` with no `type` or a `type` of `text` will render an HTML text input. + The following HTML attributes can be set via the helper: + + + + + + + + + + + + +
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    + + + When set to a quoted string, these values will be directly applied to the HTML + element. When left unquoted, these values will be bound to a property on the + template's current rendering context (most typically a controller instance). + + ## Unbound: + + ```handlebars + {{input value="http://www.facebook.com"}} + ``` + + + ```html + + ``` + + ## Bound: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + firstName: "Stanley", + entryNotAllowed: true + }); + ``` + + + ```handlebars + {{input type="text" value=firstName disabled=entryNotAllowed size="50"}} + ``` + + + ```html + + ``` + + ## Actions + + The helper can send multiple actions based on user events. + + The action property defines the action which is send when + the user presses the return key. + + ```handlebars + {{input action="submit"}} + ``` + + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. + + ```handlebars + {{input focus-in="alertMessage"}} + ``` + + See more about [Text Support Actions](/api/classes/Ember.TextField.html) + + ## Extension + + Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing + arguments from the helper to `Ember.TextField`'s `create` method. You can extend the + capabilities of text inputs in your applications by reopening this class. For example, + if you are building a Bootstrap project where `data-*` attributes are used, you + can add one to the `TextField`'s `attributeBindings` property: + + + ```javascript + Ember.TextField.reopen({ + attributeBindings: ['data-error'] + }); + ``` + + Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` + itself extends `Ember.Component`, meaning that it does NOT inherit + the `controller` of the parent view. + + See more about [Ember components](/api/classes/Ember.Component.html) + + + ## Use as checkbox + + An `{{input}}` with a `type` of `checkbox` will render an HTML checkbox input. + The following HTML attributes can be set via the helper: + + * `checked` + * `disabled` + * `tabindex` + * `indeterminate` + * `name` + * `autofocus` + * `form` + + + When set to a quoted string, these values will be directly applied to the HTML + element. When left unquoted, these values will be bound to a property on the + template's current rendering context (most typically a controller instance). + + ## Unbound: + + ```handlebars + {{input type="checkbox" name="isAdmin"}} + ``` + + ```html + + ``` + + ## Bound: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + isAdmin: true + }); + ``` + + + ```handlebars + {{input type="checkbox" checked=isAdmin }} + ``` + + + ```html + + ``` + + ## Extension + + Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing + arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the + capablilties of checkbox inputs in your applications by reopening this class. For example, + if you wanted to add a css class to all checkboxes in your application: + + + ```javascript + Ember.Checkbox.reopen({ + classNames: ['my-app-checkbox'] + }); + ``` + + + @method input + @for Ember.Handlebars.helpers + @param {Hash} options + */ + function inputHelper(options) { + + var hash = options.hash, + types = options.hashTypes, + inputType = _resolveOption(this, options, 'type'), + onEvent = hash.on; + + delete hash.type; + delete hash.on; + + if (inputType === 'checkbox') { + return helpers.view.call(this, Checkbox, options); + } else { + if (inputType) { hash.type = inputType; } + hash.onEvent = onEvent || 'enter'; + return helpers.view.call(this, TextField, options); + } + } + + __exports__.inputHelper = inputHelper;/** + `{{textarea}}` inserts a new instance of ` + ``` + + Bound: + + In the following example, the `writtenWords` property on `App.ApplicationController` + will be updated live as the user types 'Lots of text that IS bound' into + the text area of their browser's window. + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound" + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} + ``` + + Would result in the following HTML: + + ```html + + ``` + + If you wanted a one way binding between the text area and a div tag + somewhere else on your screen, you could use `Ember.computed.oneWay`: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + outputWrittenWords: Ember.computed.oneWay("writtenWords") + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} + +
    + {{outputWrittenWords}} +
    + ``` + + Would result in the following HTML: + + ```html + + + <-- the following div will be updated in real time as you type --> + +
    + Lots of text that IS bound +
    + ``` + + Finally, this example really shows the power and ease of Ember when two + properties are bound to eachother via `Ember.computed.alias`. Type into + either text area box and they'll both stay in sync. Note that + `Ember.computed.alias` costs more in terms of performance, so only use it when + your really binding in both directions: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + twoWayWrittenWords: Ember.computed.alias("writtenWords") + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} + {{textarea value=twoWayWrittenWords}} + ``` + + ```html + + + <-- both updated in real time --> + + + ``` + + ## Actions + + The helper can send multiple actions based on user events. + + The action property defines the action which is send when + the user presses the return key. + + ```handlebars + {{input action="submit"}} + ``` + + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. + + ```handlebars + {{textarea focus-in="alertMessage"}} + ``` + + See more about [Text Support Actions](/api/classes/Ember.TextArea.html) + + ## Extension + + Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing + arguments from the helper to `Ember.TextArea`'s `create` method. You can + extend the capabilities of text areas in your application by reopening this + class. For example, if you are building a Bootstrap project where `data-*` + attributes are used, you can globally add support for a `data-*` attribute + on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or + `Ember.TextSupport` and adding it to the `attributeBindings` concatenated + property: + + ```javascript + Ember.TextArea.reopen({ + attributeBindings: ['data-error'] + }); + ``` + + Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` + itself extends `Ember.Component`, meaning that it does NOT inherit + the `controller` of the parent view. + + See more about [Ember components](/api/classes/Ember.Component.html) + + @method textarea + @for Ember.Handlebars.helpers + @param {Hash} options + */ + function textareaHelper(options) { + + var hash = options.hash, + types = options.hashTypes; + + return helpers.view.call(this, TextArea, options); + } + + __exports__.textareaHelper = textareaHelper; + }); +define("ember-handlebars/controls/checkbox", + ["ember-metal/property_get","ember-metal/property_set","ember-views/views/view","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var get = __dependency1__.get; + var set = __dependency2__.set; + var View = __dependency3__["default"]; + + /** + @module ember + @submodule ember-handlebars + */ + + /** + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `checkbox`. + + See [handlebars.helpers.input](/api/classes/Ember.Handlebars.helpers.html#method_input) for usage details. + + ## Direct manipulation of `checked` + + The `checked` attribute of an `Ember.Checkbox` object should always be set + through the Ember object or by interacting with its rendered element + representation via the mouse, keyboard, or touch. Updating the value of the + checkbox via jQuery will result in the checked value of the object and its + element losing synchronization. + + ## Layout and LayoutName properties + + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class Checkbox + @namespace Ember + @extends Ember.View + */ + __exports__["default"] = View.extend({ + instrumentDisplay: '{{input type="checkbox"}}', + + classNames: ['ember-checkbox'], + + tagName: 'input', + + attributeBindings: [ + 'type', + 'checked', + 'indeterminate', + 'disabled', + 'tabindex', + 'name', + 'autofocus', + 'required', + 'form' + ], + + type: 'checkbox', + checked: false, + disabled: false, + indeterminate: false, + + init: function() { + this._super(); + this.on('change', this, this._updateElementValue); + }, + + didInsertElement: function() { + this._super(); + get(this, 'element').indeterminate = !!get(this, 'indeterminate'); + }, + + _updateElementValue: function() { + set(this, 'checked', this.$().prop('checked')); + } + }); + }); +define("ember-handlebars/controls/select", + ["ember-handlebars-compiler","ember-metal/enumerable_utils","ember-metal/property_get","ember-metal/property_set","ember-views/views/view","ember-views/views/collection_view","ember-metal/utils","ember-metal/is_none","ember-metal/computed","ember-runtime/system/native_array","ember-metal/mixin","ember-metal/properties","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-handlebars + */ + + var EmberHandlebars = __dependency1__["default"]; + + var forEach = __dependency2__.forEach; + var indexOf = __dependency2__.indexOf; + var indexesOf = __dependency2__.indexesOf; + var replace = __dependency2__.replace; + + var get = __dependency3__.get; + var set = __dependency4__.set; + var View = __dependency5__["default"]; + var CollectionView = __dependency6__["default"]; + var isArray = __dependency7__.isArray; + var isNone = __dependency8__["default"]; + var computed = __dependency9__.computed; + var emberA = __dependency10__.A; + var observer = __dependency11__.observer; + var defineProperty = __dependency12__.defineProperty; + + var precompileTemplate = EmberHandlebars.compile; + + var SelectOption = View.extend({ + instrumentDisplay: 'Ember.SelectOption', + + tagName: 'option', + attributeBindings: ['value', 'selected'], + + defaultTemplate: function(context, options) { + options = { data: options.data, hash: {} }; + EmberHandlebars.helpers.bind.call(context, "view.label", options); + }, + + init: function() { + this.labelPathDidChange(); + this.valuePathDidChange(); + + this._super(); + }, + + selected: computed(function() { + var content = get(this, 'content'), + selection = get(this, 'parentView.selection'); + if (get(this, 'parentView.multiple')) { + return selection && indexOf(selection, content.valueOf()) > -1; + } else { + // Primitives get passed through bindings as objects... since + // `new Number(4) !== 4`, we use `==` below + return content == selection; // jshint ignore:line + } + }).property('content', 'parentView.selection'), + + labelPathDidChange: observer('parentView.optionLabelPath', function() { + var labelPath = get(this, 'parentView.optionLabelPath'); + + if (!labelPath) { return; } + + defineProperty(this, 'label', computed(function() { + return get(this, labelPath); + }).property(labelPath)); + }), + + valuePathDidChange: observer('parentView.optionValuePath', function() { + var valuePath = get(this, 'parentView.optionValuePath'); + + if (!valuePath) { return; } + + defineProperty(this, 'value', computed(function() { + return get(this, valuePath); + }).property(valuePath)); + }) + }); + + var SelectOptgroup = CollectionView.extend({ + instrumentDisplay: 'Ember.SelectOptgroup', + + tagName: 'optgroup', + attributeBindings: ['label'], + + selectionBinding: 'parentView.selection', + multipleBinding: 'parentView.multiple', + optionLabelPathBinding: 'parentView.optionLabelPath', + optionValuePathBinding: 'parentView.optionValuePath', + + itemViewClassBinding: 'parentView.optionView' + }); + + /** + The `Ember.Select` view class renders a + [select](https://developer.mozilla.org/en/HTML/Element/select) HTML element, + allowing the user to choose from a list of options. + + The text and `value` property of each ` + + + ``` + + The `value` attribute of the selected `"); + return buffer; + } + + function program3(depth0,data) { + + var stack1; + stack1 = helpers.each.call(depth0, "view.groupedContent", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(4, program4, data),contexts:[depth0],types:["ID"],data:data}); + if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + else { data.buffer.push(''); } + } + function program4(depth0,data) { + + + data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.groupView", {hash:{ + 'content': ("content"), + 'label': ("label") + },hashTypes:{'content': "ID",'label': "ID"},hashContexts:{'content': depth0,'label': depth0},contexts:[depth0],types:["ID"],data:data}))); + } + + function program6(depth0,data) { + + var stack1; + stack1 = helpers.each.call(depth0, "view.content", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(7, program7, data),contexts:[depth0],types:["ID"],data:data}); + if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + else { data.buffer.push(''); } + } + function program7(depth0,data) { + + + data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.optionView", {hash:{ + 'content': ("") + },hashTypes:{'content': "ID"},hashContexts:{'content': depth0},contexts:[depth0],types:["ID"],data:data}))); + } + + stack1 = helpers['if'].call(depth0, "view.prompt", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(1, program1, data),contexts:[depth0],types:["ID"],data:data}); + if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + stack1 = helpers['if'].call(depth0, "view.optionGroupPath", {hash:{},hashTypes:{},hashContexts:{},inverse:self.program(6, program6, data),fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],data:data}); + if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + return buffer; + + }), + attributeBindings: ['multiple', 'disabled', 'tabindex', 'name', 'required', 'autofocus', + 'form', 'size'], + + /** + The `multiple` attribute of the select element. Indicates whether multiple + options can be selected. + + @property multiple + @type Boolean + @default false + */ + multiple: false, + + /** + The `disabled` attribute of the select element. Indicates whether + the element is disabled from interactions. + + @property disabled + @type Boolean + @default false + */ + disabled: false, + + /** + The `required` attribute of the select element. Indicates whether + a selected option is required for form validation. + + @property required + @type Boolean + @default false + @since 1.5.0 + */ + required: false, + + /** + The list of options. + + If `optionLabelPath` and `optionValuePath` are not overridden, this should + be a list of strings, which will serve simultaneously as labels and values. + + Otherwise, this should be a list of objects. For instance: + + ```javascript + Ember.Select.create({ + content: Ember.A([ + { id: 1, firstName: 'Yehuda' }, + { id: 2, firstName: 'Tom' } + ]), + optionLabelPath: 'content.firstName', + optionValuePath: 'content.id' + }); + ``` + + @property content + @type Array + @default null + */ + content: null, + + /** + When `multiple` is `false`, the element of `content` that is currently + selected, if any. + + When `multiple` is `true`, an array of such elements. + + @property selection + @type Object or Array + @default null + */ + selection: null, + + /** + In single selection mode (when `multiple` is `false`), value can be used to + get the current selection's value or set the selection by it's value. + + It is not currently supported in multiple selection mode. + + @property value + @type String + @default null + */ + value: computed(function(key, value) { + if (arguments.length === 2) { return value; } + var valuePath = get(this, 'optionValuePath').replace(/^content\.?/, ''); + return valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection'); + }).property('selection'), + + /** + If given, a top-most dummy option will be rendered to serve as a user + prompt. + + @property prompt + @type String + @default null + */ + prompt: null, + + /** + The path of the option labels. See [content](/api/classes/Ember.Select.html#property_content). + + @property optionLabelPath + @type String + @default 'content' + */ + optionLabelPath: 'content', + + /** + The path of the option values. See [content](/api/classes/Ember.Select.html#property_content). + + @property optionValuePath + @type String + @default 'content' + */ + optionValuePath: 'content', + + /** + The path of the option group. + When this property is used, `content` should be sorted by `optionGroupPath`. + + @property optionGroupPath + @type String + @default null + */ + optionGroupPath: null, + + /** + The view class for optgroup. + + @property groupView + @type Ember.View + @default Ember.SelectOptgroup + */ + groupView: SelectOptgroup, + + groupedContent: computed(function() { + var groupPath = get(this, 'optionGroupPath'); + var groupedContent = emberA(); + var content = get(this, 'content') || []; + + forEach(content, function(item) { + var label = get(item, groupPath); + + if (get(groupedContent, 'lastObject.label') !== label) { + groupedContent.pushObject({ + label: label, + content: emberA() + }); + } + + get(groupedContent, 'lastObject.content').push(item); + }); + + return groupedContent; + }).property('optionGroupPath', 'content.@each'), + + /** + The view class for option. + + @property optionView + @type Ember.View + @default Ember.SelectOption + */ + optionView: SelectOption, + + _change: function() { + if (get(this, 'multiple')) { + this._changeMultiple(); + } else { + this._changeSingle(); + } + }, + + selectionDidChange: observer('selection.@each', function() { + var selection = get(this, 'selection'); + if (get(this, 'multiple')) { + if (!isArray(selection)) { + set(this, 'selection', emberA([selection])); + return; + } + this._selectionDidChangeMultiple(); + } else { + this._selectionDidChangeSingle(); + } + }), + + valueDidChange: observer('value', function() { + var content = get(this, 'content'), + value = get(this, 'value'), + valuePath = get(this, 'optionValuePath').replace(/^content\.?/, ''), + selectedValue = (valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection')), + selection; + + if (value !== selectedValue) { + selection = content ? content.find(function(obj) { + return value === (valuePath ? get(obj, valuePath) : obj); + }) : null; + + this.set('selection', selection); + } + }), + + + _triggerChange: function() { + var selection = get(this, 'selection'); + var value = get(this, 'value'); + + if (!isNone(selection)) { this.selectionDidChange(); } + if (!isNone(value)) { this.valueDidChange(); } + + this._change(); + }, + + _changeSingle: function() { + var selectedIndex = this.$()[0].selectedIndex, + content = get(this, 'content'), + prompt = get(this, 'prompt'); + + if (!content || !get(content, 'length')) { return; } + if (prompt && selectedIndex === 0) { set(this, 'selection', null); return; } + + if (prompt) { selectedIndex -= 1; } + set(this, 'selection', content.objectAt(selectedIndex)); + }, + + + _changeMultiple: function() { + var options = this.$('option:selected'), + prompt = get(this, 'prompt'), + offset = prompt ? 1 : 0, + content = get(this, 'content'), + selection = get(this, 'selection'); + + if (!content) { return; } + if (options) { + var selectedIndexes = options.map(function() { + return this.index - offset; + }).toArray(); + var newSelection = content.objectsAt(selectedIndexes); + + if (isArray(selection)) { + replace(selection, 0, get(selection, 'length'), newSelection); + } else { + set(this, 'selection', newSelection); + } + } + }, + + _selectionDidChangeSingle: function() { + var el = this.get('element'); + if (!el) { return; } + + var content = get(this, 'content'), + selection = get(this, 'selection'), + selectionIndex = content ? indexOf(content, selection) : -1, + prompt = get(this, 'prompt'); + + if (prompt) { selectionIndex += 1; } + if (el) { el.selectedIndex = selectionIndex; } + }, + + _selectionDidChangeMultiple: function() { + var content = get(this, 'content'), + selection = get(this, 'selection'), + selectedIndexes = content ? indexesOf(content, selection) : [-1], + prompt = get(this, 'prompt'), + offset = prompt ? 1 : 0, + options = this.$('option'), + adjusted; + + if (options) { + options.each(function() { + adjusted = this.index > -1 ? this.index - offset : -1; + this.selected = indexOf(selectedIndexes, adjusted) > -1; + }); + } + }, + + init: function() { + this._super(); + this.on("didInsertElement", this, this._triggerChange); + this.on("change", this, this._change); + } + }); + + __exports__["default"] = Select; + __exports__.Select = Select; + __exports__.SelectOption = SelectOption; + __exports__.SelectOptgroup = SelectOptgroup; + }); +define("ember-handlebars/controls/text_area", + ["ember-metal/property_get","ember-views/views/component","ember-handlebars/controls/text_support","ember-metal/mixin","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + + /** + @module ember + @submodule ember-handlebars + */ + var get = __dependency1__.get; + var Component = __dependency2__["default"]; + var TextSupport = __dependency3__["default"]; + var observer = __dependency4__.observer; + + /** + The internal class used to create textarea element when the `{{textarea}}` + helper is used. + + See [handlebars.helpers.textarea](/api/classes/Ember.Handlebars.helpers.html#method_textarea) for usage details. + + ## Layout and LayoutName properties + + Because HTML `textarea` elements do not contain inner HTML the `layout` and + `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextArea + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + */ + __exports__["default"] = Component.extend(TextSupport, { + instrumentDisplay: '{{textarea}}', + + classNames: ['ember-text-area'], + + tagName: "textarea", + attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap'], + rows: null, + cols: null, + + _updateElementValue: observer('value', function() { + // We do this check so cursor position doesn't get affected in IE + var value = get(this, 'value'), + $el = this.$(); + if ($el && value !== $el.val()) { + $el.val(value); + } + }), + + init: function() { + this._super(); + this.on("didInsertElement", this, this._updateElementValue); + } + }); + }); +define("ember-handlebars/controls/text_field", + ["ember-metal/property_get","ember-metal/property_set","ember-views/views/component","ember-handlebars/controls/text_support","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-handlebars + */ + + var get = __dependency1__.get; + var set = __dependency2__.set; + var Component = __dependency3__["default"]; + var TextSupport = __dependency4__["default"]; + + /** + + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `text`. + + See [Handlebars.helpers.input](/api/classes/Ember.Handlebars.helpers.html#method_input) for usage details. + + ## Layout and LayoutName properties + + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextField + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + */ + __exports__["default"] = Component.extend(TextSupport, { + instrumentDisplay: '{{input type="text"}}', + + classNames: ['ember-text-field'], + tagName: "input", + attributeBindings: ['type', 'value', 'size', 'pattern', 'name', 'min', 'max', + 'accept', 'autocomplete', 'autosave', 'formaction', + 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', + 'height', 'inputmode', 'list', 'multiple', 'step', + 'width'], + + /** + The `value` attribute of the input element. As the user inputs text, this + property is updated live. + + @property value + @type String + @default "" + */ + value: "", + + /** + The `type` attribute of the input element. + + @property type + @type String + @default "text" + */ + type: "text", + + /** + The `size` of the text field in characters. + + @property size + @type String + @default null + */ + size: null, + + /** + The `pattern` attribute of input element. + + @property pattern + @type String + @default null + */ + pattern: null, + + /** + The `min` attribute of input element used with `type="number"` or `type="range"`. + + @property min + @type String + @default null + @since 1.4.0 + */ + min: null, + + /** + The `max` attribute of input element used with `type="number"` or `type="range"`. + + @property max + @type String + @default null + @since 1.4.0 + */ + max: null + }); + }); +define("ember-handlebars/controls/text_support", + ["ember-metal/property_get","ember-metal/property_set","ember-metal/mixin","ember-runtime/mixins/target_action_support","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-handlebars + */ + + var get = __dependency1__.get; + var set = __dependency2__.set; + var Mixin = __dependency3__.Mixin; + var TargetActionSupport = __dependency4__["default"]; + + /** + Shared mixin used by `Ember.TextField` and `Ember.TextArea`. + + @class TextSupport + @namespace Ember + @uses Ember.TargetActionSupport + @extends Ember.Mixin + @private + */ + var TextSupport = Mixin.create(TargetActionSupport, { + value: "", + + attributeBindings: ['placeholder', 'disabled', 'maxlength', 'tabindex', 'readonly', + 'autofocus', 'form', 'selectionDirection', 'spellcheck', 'required', + 'title', 'autocapitalize', 'autocorrect'], + placeholder: null, + disabled: false, + maxlength: null, + + init: function() { + this._super(); + this.on("focusOut", this, this._elementValueDidChange); + this.on("change", this, this._elementValueDidChange); + this.on("paste", this, this._elementValueDidChange); + this.on("cut", this, this._elementValueDidChange); + this.on("input", this, this._elementValueDidChange); + this.on("keyUp", this, this.interpretKeyEvents); + }, + + /** + The action to be sent when the user presses the return key. + + This is similar to the `{{action}}` helper, but is fired when + the user presses the return key when editing a text field, and sends + the value of the field as the context. + + @property action + @type String + @default null + */ + action: null, + + /** + The event that should send the action. + + Options are: + + * `enter`: the user pressed enter + * `keyPress`: the user pressed a key + + @property onEvent + @type String + @default enter + */ + onEvent: 'enter', + + /** + Whether they `keyUp` event that triggers an `action` to be sent continues + propagating to other views. + + By default, when the user presses the return key on their keyboard and + the text field has an `action` set, the action will be sent to the view's + controller and the key event will stop propagating. + + If you would like parent views to receive the `keyUp` event even after an + action has been dispatched, set `bubbles` to true. + + @property bubbles + @type Boolean + @default false + */ + bubbles: false, + + interpretKeyEvents: function(event) { + var map = TextSupport.KEY_EVENTS; + var method = map[event.keyCode]; + + this._elementValueDidChange(); + if (method) { return this[method](event); } + }, + + _elementValueDidChange: function() { + set(this, 'value', this.$().val()); + }, + + /** + Called when the user inserts a new line. + + Called by the `Ember.TextSupport` mixin on keyUp if keycode matches 13. + Uses sendAction to send the `enter` action. + + @method insertNewline + @param {Event} event + */ + insertNewline: function(event) { + sendAction('enter', this, event); + sendAction('insert-newline', this, event); + }, + + /** + Called when the user hits escape. + + Called by the `Ember.TextSupport` mixin on keyUp if keycode matches 27. + Uses sendAction to send the `escape-press` action. + + @method cancel + @param {Event} event + */ + cancel: function(event) { + sendAction('escape-press', this, event); + }, + + /** + Called when the text area is focused. + + Uses sendAction to send the `focus-in` action. + + @method focusIn + @param {Event} event + */ + focusIn: function(event) { + sendAction('focus-in', this, event); + }, + + /** + Called when the text area is blurred. + + Uses sendAction to send the `focus-out` action. + + @method focusOut + @param {Event} event + */ + focusOut: function(event) { + sendAction('focus-out', this, event); + }, + + /** + Called when the user presses a key. Enabled by setting + the `onEvent` property to `keyPress`. + + Uses sendAction to send the `key-press` action. + + @method keyPress + @param {Event} event + */ + keyPress: function(event) { + sendAction('key-press', this, event); + } + + }); + + TextSupport.KEY_EVENTS = { + 13: 'insertNewline', + 27: 'cancel' + }; + + // In principle, this shouldn't be necessary, but the legacy + // sendAction semantics for TextField are different from + // the component semantics so this method normalizes them. + function sendAction(eventName, view, event) { + var action = get(view, eventName), + on = get(view, 'onEvent'), + value = get(view, 'value'); + + // back-compat support for keyPress as an event name even though + // it's also a method name that consumes the event (and therefore + // incompatible with sendAction semantics). + if (on === eventName || (on === 'keyPress' && eventName === 'key-press')) { + view.sendAction('action', value); + } + + view.sendAction(eventName, value); + + if (action || on === eventName) { + if(!get(view, 'bubbles')) { + event.stopPropagation(); + } + } + } + + __exports__["default"] = TextSupport; + }); +define("ember-handlebars/ext", + ["ember-metal/core","ember-runtime/system/string","ember-handlebars-compiler","ember-metal/property_get","ember-metal/binding","ember-metal/error","ember-metal/mixin","ember-metal/is_empty","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + // Ember.FEATURES, Ember.assert, Ember.Handlebars, Ember.lookup + // var emberAssert = Ember.assert; + + var fmt = __dependency2__.fmt; + + var EmberHandlebars = __dependency3__["default"]; + var helpers = EmberHandlebars.helpers; + + var get = __dependency4__.get; + var isGlobalPath = __dependency5__.isGlobalPath; + var EmberError = __dependency6__["default"]; + var IS_BINDING = __dependency7__.IS_BINDING; + + // late bound via requireModule because of circular dependencies. + var resolveHelper, + SimpleHandlebarsView; + + var isEmpty = __dependency8__["default"]; + + var slice = [].slice, originalTemplate = EmberHandlebars.template; + + /** + If a path starts with a reserved keyword, returns the root + that should be used. + + @private + @method normalizePath + @for Ember + @param root {Object} + @param path {String} + @param data {Hash} + */ + function normalizePath(root, path, data) { + var keywords = (data && data.keywords) || {}, + keyword, isKeyword; + + // Get the first segment of the path. For example, if the + // path is "foo.bar.baz", returns "foo". + keyword = path.split('.', 1)[0]; + + // Test to see if the first path is a keyword that has been + // passed along in the view's data hash. If so, we will treat + // that object as the new root. + if (keywords.hasOwnProperty(keyword)) { + // Look up the value in the template's data hash. + root = keywords[keyword]; + isKeyword = true; + + // Handle cases where the entire path is the reserved + // word. In that case, return the object itself. + if (path === keyword) { + path = ''; + } else { + // Strip the keyword from the path and look up + // the remainder from the newly found root. + path = path.substr(keyword.length+1); + } + } + + return { root: root, path: path, isKeyword: isKeyword }; + } + + + /** + Lookup both on root and on window. If the path starts with + a keyword, the corresponding object will be looked up in the + template's data hash and used to resolve the path. + + @method get + @for Ember.Handlebars + @param {Object} root The object to look up the property on + @param {String} path The path to be lookedup + @param {Object} options The template's option hash + */ + function handlebarsGet(root, path, options) { + var data = options && options.data, + normalizedPath = normalizePath(root, path, data), + value; + + + root = normalizedPath.root; + path = normalizedPath.path; + + value = get(root, path); + + if (value === undefined && root !== Ember.lookup && isGlobalPath(path)) { + value = get(Ember.lookup, path); + } + + + return value; + } + + /** + This method uses `Ember.Handlebars.get` to lookup a value, then ensures + that the value is escaped properly. + + If `unescaped` is a truthy value then the escaping will not be performed. + + @method getEscaped + @for Ember.Handlebars + @param {Object} root The object to look up the property on + @param {String} path The path to be lookedup + @param {Object} options The template's option hash + @since 1.4.0 + */ + function getEscaped(root, path, options) { + var result = handlebarsGet(root, path, options); + + if (result === null || result === undefined) { + result = ""; + } else if (!(result instanceof Handlebars.SafeString)) { + result = String(result); + } + if (!options.hash.unescaped){ + result = Handlebars.Utils.escapeExpression(result); + } + + return result; + } + + __exports__.getEscaped = getEscaped;function resolveParams(context, params, options) { + var resolvedParams = [], types = options.types, param, type; + + for (var i=0, l=params.length; i{{user.name}} + +
    +
    {{user.role.label}}
    + {{user.role.id}} + +

    {{user.role.description}}

    +
    + ``` + + `{{with}}` can be our best friend in these cases, + instead of writing `user.role.*` over and over, we use `{{#with user.role}}`. + Now the context within the `{{#with}} .. {{/with}}` block is `user.role` so you can do the following: + + ```handlebars +
    {{user.name}}
    + +
    + {{#with user.role}} +
    {{label}}
    + {{id}} + +

    {{description}}

    + {{/with}} +
    + ``` + + ### `as` operator + + This operator aliases the scope to a new name. It's helpful for semantic clarity and to retain + default scope or to reference from another `{{with}}` block. + + ```handlebars + // posts might not be + {{#with user.posts as blogPosts}} +
    + There are {{blogPosts.length}} blog posts written by {{user.name}}. +
    + + {{#each post in blogPosts}} +
  • {{post.title}}
  • + {{/each}} + {{/with}} + ``` + + Without the `as` operator, it would be impossible to reference `user.name` in the example above. + + NOTE: The alias should not reuse a name from the bound property path. + For example: `{{#with foo.bar as foo}}` is not supported because it attempts to alias using + the first part of the property path, `foo`. Instead, use `{{#with foo.bar as baz}}`. + + ### `controller` option + + Adding `controller='something'` instructs the `{{with}}` helper to create and use an instance of + the specified controller with the new context as its content. + + This is very similar to using an `itemController` option with the `{{each}}` helper. + + ```handlebars + {{#with users.posts controller='userBlogPosts'}} + {{!- The current context is wrapped in our controller instance }} + {{/with}} + ``` + + In the above example, the template provided to the `{{with}}` block is now wrapped in the + `userBlogPost` controller, which provides a very elegant way to decorate the context with custom + functions/properties. + + @method with + @for Ember.Handlebars.helpers + @param {Function} context + @param {Hash} options + @return {String} HTML string + */ + function withHelper(context, options) { + var bindContext, preserveContext, controller, helperName = 'with'; + + if (arguments.length === 4) { + var keywordName, path, rootPath, normalized, contextPath; + + options = arguments[3]; + keywordName = arguments[2]; + path = arguments[0]; + + if (path) { + helperName += ' ' + path + ' as ' + keywordName; + } + + + var localizedOptions = o_create(options); + localizedOptions.data = o_create(options.data); + localizedOptions.data.keywords = o_create(options.data.keywords || {}); + + if (isGlobalPath(path)) { + contextPath = path; + } else { + normalized = normalizePath(this, path, options.data); + path = normalized.path; + rootPath = normalized.root; + + // This is a workaround for the fact that you cannot bind separate objects + // together. When we implement that functionality, we should use it here. + var contextKey = jQuery.expando + guidFor(rootPath); + localizedOptions.data.keywords[contextKey] = rootPath; + // if the path is '' ("this"), just bind directly to the current context + contextPath = path ? contextKey + '.' + path : contextKey; + } + + localizedOptions.hash.keywordName = keywordName; + localizedOptions.hash.keywordPath = contextPath; + + bindContext = this; + context = contextPath; + options = localizedOptions; + preserveContext = true; + } else { + + helperName += ' ' + context; + bindContext = options.contexts[0]; + preserveContext = false; + } + + options.helperName = helperName; + options.isWithHelper = true; + + return bind.call(bindContext, context, options, preserveContext, exists); + } + /** + See [boundIf](/api/classes/Ember.Handlebars.helpers.html#method_boundIf) + and [unboundIf](/api/classes/Ember.Handlebars.helpers.html#method_unboundIf) + + @method if + @for Ember.Handlebars.helpers + @param {Function} context + @param {Hash} options + @return {String} HTML string + */ + function ifHelper(context, options) { + + options.helperName = options.helperName || ('if ' + context); + + if (options.data.isUnbound) { + return helpers.unboundIf.call(options.contexts[0], context, options); + } else { + return helpers.boundIf.call(options.contexts[0], context, options); + } + } + + /** + @method unless + @for Ember.Handlebars.helpers + @param {Function} context + @param {Hash} options + @return {String} HTML string + */ + function unlessHelper(context, options) { + + var fn = options.fn, inverse = options.inverse, helperName = 'unless'; + + if (context) { + helperName += ' ' + context; + } + + options.fn = inverse; + options.inverse = fn; + + options.helperName = options.helperName || helperName; + + if (options.data.isUnbound) { + return helpers.unboundIf.call(options.contexts[0], context, options); + } else { + return helpers.boundIf.call(options.contexts[0], context, options); + } + } + + /** + `bind-attr` allows you to create a binding between DOM element attributes and + Ember objects. For example: + + ```handlebars + imageTitle + ``` + + The above handlebars template will fill the ``'s `src` attribute with + the value of the property referenced with `"imageUrl"` and its `alt` + attribute with the value of the property referenced with `"imageTitle"`. + + If the rendering context of this template is the following object: + + ```javascript + { + imageUrl: 'http://lolcats.info/haz-a-funny', + imageTitle: 'A humorous image of a cat' + } + ``` + + The resulting HTML output will be: + + ```html + A humorous image of a cat + ``` + + `bind-attr` cannot redeclare existing DOM element attributes. The use of `src` + in the following `bind-attr` example will be ignored and the hard coded value + of `src="/failwhale.gif"` will take precedence: + + ```handlebars + imageTitle + ``` + + ### `bind-attr` and the `class` attribute + + `bind-attr` supports a special syntax for handling a number of cases unique + to the `class` DOM element attribute. The `class` attribute combines + multiple discrete values into a single attribute as a space-delimited + list of strings. Each string can be: + + * a string return value of an object's property. + * a boolean return value of an object's property + * a hard-coded value + + A string return value works identically to other uses of `bind-attr`. The + return value of the property will become the value of the attribute. For + example, the following view and template: + + ```javascript + AView = View.extend({ + someProperty: function() { + return "aValue"; + }.property() + }) + ``` + + ```handlebars + + ``` + + A boolean return value will insert a specified class name if the property + returns `true` and remove the class name if the property returns `false`. + + A class name is provided via the syntax + `somePropertyName:class-name-if-true`. + + ```javascript + AView = View.extend({ + someBool: true + }) + ``` + + ```handlebars + + ``` + + Result in the following rendered output: + + ```html + + ``` + + An additional section of the binding can be provided if you want to + replace the existing class instead of removing it when the boolean + value changes: + + ```handlebars + + ``` + + A hard-coded value can be used by prepending `:` to the desired + class name: `:class-name-to-always-apply`. + + ```handlebars + + ``` + + Results in the following rendered output: + + ```html + + ``` + + All three strategies - string return value, boolean return value, and + hard-coded value – can be combined in a single declaration: + + ```handlebars + + ``` + + @method bind-attr + @for Ember.Handlebars.helpers + @param {Hash} options + @return {String} HTML string + */ + function bindAttrHelper(options) { + var attrs = options.hash; + + + var view = options.data.view; + var ret = []; + + // we relied on the behavior of calling without + // context to mean this === window, but when running + // "use strict", it's possible for this to === undefined; + var ctx = this || window; + + // Generate a unique id for this element. This will be added as a + // data attribute to the element so it can be looked up when + // the bound property changes. + var dataId = uuid(); + + // Handle classes differently, as we can bind multiple classes + var classBindings = attrs['class']; + if (classBindings != null) { + var classResults = bindClasses(ctx, classBindings, view, dataId, options); + + ret.push('class="' + Handlebars.Utils.escapeExpression(classResults.join(' ')) + '"'); + delete attrs['class']; + } + + var attrKeys = keys(attrs); + + // For each attribute passed, create an observer and emit the + // current value of the property as an attribute. + forEach.call(attrKeys, function(attr) { + var path = attrs[attr], + normalized; + + + normalized = normalizePath(ctx, path, options.data); + + var value = (path === 'this') ? normalized.root : handlebarsGet(ctx, path, options), + type = typeOf(value); + + + var observer; + + observer = function observer() { + var result = handlebarsGet(ctx, path, options); + + + var elem = view.$("[data-bindattr-" + dataId + "='" + dataId + "']"); + + // If we aren't able to find the element, it means the element + // to which we were bound has been removed from the view. + // In that case, we can assume the template has been re-rendered + // and we need to clean up the observer. + if (!elem || elem.length === 0) { + removeObserver(normalized.root, normalized.path, observer); + return; + } + + View.applyAttributeBindings(elem, attr, result); + }; + + // Add an observer to the view for when the property changes. + // When the observer fires, find the element using the + // unique data id and update the attribute to the new value. + // Note: don't add observer when path is 'this' or path + // is whole keyword e.g. {{#each x in list}} ... {{bind-attr attr="x"}} + if (path !== 'this' && !(normalized.isKeyword && normalized.path === '' )) { + view.registerObserver(normalized.root, normalized.path, observer); + } + + // if this changes, also change the logic in ember-views/lib/views/view.js + if ((type === 'string' || (type === 'number' && !isNaN(value)))) { + ret.push(attr + '="' + Handlebars.Utils.escapeExpression(value) + '"'); + } else if (value && type === 'boolean') { + // The developer controls the attr name, so it should always be safe + ret.push(attr + '="' + attr + '"'); + } + }, this); + + // Add the unique identifier + // NOTE: We use all lower-case since Firefox has problems with mixed case in SVG + ret.push('data-bindattr-' + dataId + '="' + dataId + '"'); + return new SafeString(ret.join(' ')); + } + + /** + See `bind-attr` + + @method bindAttr + @for Ember.Handlebars.helpers + @deprecated + @param {Function} context + @param {Hash} options + @return {String} HTML string + */ + function bindAttrHelperDeprecated() { + return helpers['bind-attr'].apply(this, arguments); + } + + /** + Helper that, given a space-separated string of property paths and a context, + returns an array of class names. Calling this method also has the side + effect of setting up observers at those property paths, such that if they + change, the correct class name will be reapplied to the DOM element. + + For example, if you pass the string "fooBar", it will first look up the + "fooBar" value of the context. If that value is true, it will add the + "foo-bar" class to the current element (i.e., the dasherized form of + "fooBar"). If the value is a string, it will add that string as the class. + Otherwise, it will not add any new class name. + + @private + @method bindClasses + @for Ember.Handlebars + @param {Ember.Object} context The context from which to lookup properties + @param {String} classBindings A string, space-separated, of class bindings + to use + @param {View} view The view in which observers should look for the + element to update + @param {Srting} bindAttrId Optional bindAttr id used to lookup elements + @return {Array} An array of class names to add + */ + function bindClasses(context, classBindings, view, bindAttrId, options) { + var ret = [], newClass, value, elem; + + // Helper method to retrieve the property from the context and + // determine which class string to return, based on whether it is + // a Boolean or not. + var classStringForPath = function(root, parsedPath, options) { + var val, + path = parsedPath.path; + + if (path === 'this') { + val = root; + } else if (path === '') { + val = true; + } else { + val = handlebarsGet(root, path, options); + } + + return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName); + }; + + // For each property passed, loop through and setup + // an observer. + forEach.call(classBindings.split(' '), function(binding) { + + // Variable in which the old class value is saved. The observer function + // closes over this variable, so it knows which string to remove when + // the property changes. + var oldClass; + + var observer; + + var parsedPath = View._parsePropertyPath(binding), + path = parsedPath.path, + pathRoot = context, + normalized; + + if (path !== '' && path !== 'this') { + normalized = normalizePath(context, path, options.data); + + pathRoot = normalized.root; + path = normalized.path; + } + + // Set up an observer on the context. If the property changes, toggle the + // class name. + observer = function() { + // Get the current value of the property + newClass = classStringForPath(context, parsedPath, options); + elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$(); + + // If we can't find the element anymore, a parent template has been + // re-rendered and we've been nuked. Remove the observer. + if (!elem || elem.length === 0) { + removeObserver(pathRoot, path, observer); + } else { + // If we had previously added a class to the element, remove it. + if (oldClass) { + elem.removeClass(oldClass); + } + + // If necessary, add a new class. Make sure we keep track of it so + // it can be removed in the future. + if (newClass) { + elem.addClass(newClass); + oldClass = newClass; + } else { + oldClass = null; + } + } + }; + + if (path !== '' && path !== 'this') { + view.registerObserver(pathRoot, path, observer); + } + + // We've already setup the observer; now we just need to figure out the + // correct behavior right now on the first pass through. + value = classStringForPath(context, parsedPath, options); + + if (value) { + ret.push(value); + + // Make sure we save the current value so that it can be removed if the + // observer fires. + oldClass = value; + } + }); + + return ret; + } + + __exports__.bind = bind; + __exports__._triageMustacheHelper = _triageMustacheHelper; + __exports__.resolveHelper = resolveHelper; + __exports__.bindHelper = bindHelper; + __exports__.boundIfHelper = boundIfHelper; + __exports__.unboundIfHelper = unboundIfHelper; + __exports__.withHelper = withHelper; + __exports__.ifHelper = ifHelper; + __exports__.unlessHelper = unlessHelper; + __exports__.bindAttrHelper = bindAttrHelper; + __exports__.bindAttrHelperDeprecated = bindAttrHelperDeprecated; + __exports__.bindClasses = bindClasses; + }); +define("ember-handlebars/helpers/collection", + ["ember-metal/core","ember-metal/utils","ember-handlebars-compiler","ember-runtime/system/string","ember-metal/property_get","ember-handlebars/ext","ember-handlebars/helpers/view","ember-metal/computed","ember-views/views/collection_view","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) { + "use strict"; + /** + @module ember + @submodule ember-handlebars + */ + + var Ember = __dependency1__["default"]; + // Ember.assert, Ember.deprecate + var inspect = __dependency2__.inspect; + + // var emberAssert = Ember.assert; + // emberDeprecate = Ember.deprecate; + + var EmberHandlebars = __dependency3__["default"]; + var helpers = EmberHandlebars.helpers; + + var fmt = __dependency4__.fmt; + var get = __dependency5__.get; + var handlebarsGet = __dependency6__.handlebarsGet; + var ViewHelper = __dependency7__.ViewHelper; + var computed = __dependency8__.computed; + var CollectionView = __dependency9__["default"]; + + var alias = computed.alias; + /** + `{{collection}}` is a `Ember.Handlebars` helper for adding instances of + `Ember.CollectionView` to a template. See [Ember.CollectionView](/api/classes/Ember.CollectionView.html) + for additional information on how a `CollectionView` functions. + + `{{collection}}`'s primary use is as a block helper with a `contentBinding` + option pointing towards an `Ember.Array`-compatible object. An `Ember.View` + instance will be created for each item in its `content` property. Each view + will have its own `content` property set to the appropriate item in the + collection. + + The provided block will be applied as the template for each item's view. + + Given an empty `` the following template: + + ```handlebars + {{#collection contentBinding="App.items"}} + Hi {{view.content.name}} + {{/collection}} + ``` + + And the following application code + + ```javascript + App = Ember.Application.create() + App.items = [ + Ember.Object.create({name: 'Dave'}), + Ember.Object.create({name: 'Mary'}), + Ember.Object.create({name: 'Sara'}) + ] + ``` + + Will result in the HTML structure below + + ```html +
    +
    Hi Dave
    +
    Hi Mary
    +
    Hi Sara
    +
    + ``` + + ### Blockless use in a collection + + If you provide an `itemViewClass` option that has its own `template` you can + omit the block. + + The following template: + + ```handlebars + {{collection contentBinding="App.items" itemViewClass="App.AnItemView"}} + ``` + + And application code + + ```javascript + App = Ember.Application.create(); + App.items = [ + Ember.Object.create({name: 'Dave'}), + Ember.Object.create({name: 'Mary'}), + Ember.Object.create({name: 'Sara'}) + ]; + + App.AnItemView = Ember.View.extend({ + template: Ember.Handlebars.compile("Greetings {{view.content.name}}") + }); + ``` + + Will result in the HTML structure below + + ```html +
    +
    Greetings Dave
    +
    Greetings Mary
    +
    Greetings Sara
    +
    + ``` + + ### Specifying a CollectionView subclass + + By default the `{{collection}}` helper will create an instance of + `Ember.CollectionView`. You can supply a `Ember.CollectionView` subclass to + the helper by passing it as the first argument: + + ```handlebars + {{#collection App.MyCustomCollectionClass contentBinding="App.items"}} + Hi {{view.content.name}} + {{/collection}} + ``` + + ### Forwarded `item.*`-named Options + + As with the `{{view}}`, helper options passed to the `{{collection}}` will be + set on the resulting `Ember.CollectionView` as properties. Additionally, + options prefixed with `item` will be applied to the views rendered for each + item (note the camelcasing): + + ```handlebars + {{#collection contentBinding="App.items" + itemTagName="p" + itemClassNames="greeting"}} + Howdy {{view.content.name}} + {{/collection}} + ``` + + Will result in the following HTML structure: + + ```html +
    +

    Howdy Dave

    +

    Howdy Mary

    +

    Howdy Sara

    +
    + ``` + + @method collection + @for Ember.Handlebars.helpers + @param {String} path + @param {Hash} options + @return {String} HTML string + @deprecated Use `{{each}}` helper instead. + */ + function collectionHelper(path, options) { + + // If no path is provided, treat path param as options. + if (path && path.data && path.data.isRenderData) { + options = path; + path = undefined; + } else { + } + + var fn = options.fn; + var data = options.data; + var inverse = options.inverse; + var view = options.data.view; + + + var controller, container; + // If passed a path string, convert that into an object. + // Otherwise, just default to the standard class. + var collectionClass; + if (path) { + controller = data.keywords.controller; + container = controller && controller.container; + collectionClass = handlebarsGet(this, path, options) || container.lookupFactory('view:' + path); + } + else { + collectionClass = CollectionView; + } + + var hash = options.hash, itemHash = {}, match; + + // Extract item view class if provided else default to the standard class + var collectionPrototype = collectionClass.proto(), itemViewClass; + + if (hash.itemView) { + controller = data.keywords.controller; + container = controller.container; + itemViewClass = container.lookupFactory('view:' + hash.itemView); + } else if (hash.itemViewClass) { + itemViewClass = handlebarsGet(collectionPrototype, hash.itemViewClass, options); + } else { + itemViewClass = collectionPrototype.itemViewClass; + } + + + delete hash.itemViewClass; + delete hash.itemView; + + // Go through options passed to the {{collection}} helper and extract options + // that configure item views instead of the collection itself. + for (var prop in hash) { + if (hash.hasOwnProperty(prop)) { + match = prop.match(/^item(.)(.*)$/); + + if (match && prop !== 'itemController') { + // Convert itemShouldFoo -> shouldFoo + itemHash[match[1].toLowerCase() + match[2]] = hash[prop]; + // Delete from hash as this will end up getting passed to the + // {{view}} helper method. + delete hash[prop]; + } + } + } + + if (fn) { + itemHash.template = fn; + delete options.fn; + } + + var emptyViewClass; + if (inverse && inverse !== EmberHandlebars.VM.noop) { + emptyViewClass = get(collectionPrototype, 'emptyViewClass'); + emptyViewClass = emptyViewClass.extend({ + template: inverse, + tagName: itemHash.tagName + }); + } else if (hash.emptyViewClass) { + emptyViewClass = handlebarsGet(this, hash.emptyViewClass, options); + } + if (emptyViewClass) { hash.emptyView = emptyViewClass; } + + if (hash.keyword) { + itemHash._context = this; + } else { + itemHash._context = alias('content'); + } + + var viewOptions = ViewHelper.propertiesFromHTMLOptions({ data: data, hash: itemHash }, this); + hash.itemViewClass = itemViewClass.extend(viewOptions); + + options.helperName = options.helperName || 'collection'; + + return helpers.view.call(this, collectionClass, options); + } + + __exports__["default"] = collectionHelper; + }); +define("ember-handlebars/helpers/debug", + ["ember-metal/core","ember-metal/utils","ember-metal/logger","ember-metal/property_get","ember-handlebars/ext","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) { + "use strict"; + /*jshint debug:true*/ + + /** + @module ember + @submodule ember-handlebars + */ + var Ember = __dependency1__["default"]; + // Ember.FEATURES, + var inspect = __dependency2__.inspect; + var Logger = __dependency3__["default"]; + + var get = __dependency4__.get; + var normalizePath = __dependency5__.normalizePath; + var handlebarsGet = __dependency5__.handlebarsGet; + + var a_slice = [].slice; + + /** + `log` allows you to output the value of variables in the current rendering + context. `log` also accepts primitive types such as strings or numbers. + + ```handlebars + {{log "myVariable:" myVariable }} + ``` + + @method log + @for Ember.Handlebars.helpers + @param {String} property + */ + function logHelper() { + var params = a_slice.call(arguments, 0, -1), + options = arguments[arguments.length - 1], + logger = Logger.log, + values = [], + allowPrimitives = true; + + for (var i = 0; i < params.length; i++) { + var type = options.types[i]; + + if (type === 'ID' || !allowPrimitives) { + var context = (options.contexts && options.contexts[i]) || this, + normalized = normalizePath(context, params[i], options.data); + + if (normalized.path === 'this') { + values.push(normalized.root); + } else { + values.push(handlebarsGet(normalized.root, normalized.path, options)); + } + } else { + values.push(params[i]); + } + } + + logger.apply(logger, values); + } + + /** + Execute the `debugger` statement in the current context. + + ```handlebars + {{debugger}} + ``` + + Before invoking the `debugger` statement, there + are a few helpful variables defined in the + body of this helper that you can inspect while + debugging that describe how and where this + helper was invoked: + + - templateContext: this is most likely a controller + from which this template looks up / displays properties + - typeOfTemplateContext: a string description of + what the templateContext is + + For example, if you're wondering why a value `{{foo}}` + isn't rendering as expected within a template, you + could place a `{{debugger}}` statement, and when + the `debugger;` breakpoint is hit, you can inspect + `templateContext`, determine if it's the object you + expect, and/or evaluate expressions in the console + to perform property lookups on the `templateContext`: + + ``` + > templateContext.get('foo') // -> "" + ``` + + @method debugger + @for Ember.Handlebars.helpers + @param {String} property + */ + function debuggerHelper(options) { + + // These are helpful values you can inspect while debugging. + var templateContext = this; + var typeOfTemplateContext = inspect(templateContext); + + debugger; + } + + __exports__.logHelper = logHelper; + __exports__.debuggerHelper = debuggerHelper; + }); +define("ember-handlebars/helpers/each", + ["ember-metal/core","ember-handlebars-compiler","ember-runtime/system/string","ember-metal/property_get","ember-metal/property_set","ember-views/views/collection_view","ember-metal/binding","ember-runtime/mixins/controller","ember-runtime/controllers/array_controller","ember-runtime/mixins/array","ember-runtime/copy","ember-metal/run_loop","ember-metal/events","ember-handlebars/ext","ember-metal/computed","ember-metal/observer","ember-handlebars/views/metamorph_view","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __exports__) { + "use strict"; + + /** + @module ember + @submodule ember-handlebars + */ + var Ember = __dependency1__["default"]; + // Ember.assert;, Ember.K + // var emberAssert = Ember.assert, + var K = Ember.K; + + var EmberHandlebars = __dependency2__["default"]; + var helpers = EmberHandlebars.helpers; + + var fmt = __dependency3__.fmt; + var get = __dependency4__.get; + var set = __dependency5__.set; + var CollectionView = __dependency6__["default"]; + var Binding = __dependency7__.Binding; + var ControllerMixin = __dependency8__["default"]; + var ArrayController = __dependency9__["default"]; + var EmberArray = __dependency10__["default"]; + var copy = __dependency11__["default"]; + var run = __dependency12__["default"]; + var on = __dependency13__.on; + var handlebarsGet = __dependency14__.handlebarsGet; + var computed = __dependency15__.computed; + + var addObserver = __dependency16__.addObserver; + var removeObserver = __dependency16__.removeObserver; + var addBeforeObserver = __dependency16__.addBeforeObserver; + var removeBeforeObserver = __dependency16__.removeBeforeObserver; + + var _Metamorph = __dependency17__._Metamorph; + var _MetamorphView = __dependency17__._MetamorphView; + + var EachView = CollectionView.extend(_Metamorph, { + + init: function() { + var itemController = get(this, 'itemController'); + var binding; + + if (itemController) { + var controller = get(this, 'controller.container').lookupFactory('controller:array').create({ + _isVirtual: true, + parentController: get(this, 'controller'), + itemController: itemController, + target: get(this, 'controller'), + _eachView: this + }); + + this.disableContentObservers(function() { + set(this, 'content', controller); + binding = new Binding('content', '_eachView.dataSource').oneWay(); + binding.connect(controller); + }); + + set(this, '_arrayController', controller); + } else { + this.disableContentObservers(function() { + binding = new Binding('content', 'dataSource').oneWay(); + binding.connect(this); + }); + } + + return this._super(); + }, + + _assertArrayLike: function(content) { + }, + + disableContentObservers: function(callback) { + removeBeforeObserver(this, 'content', null, '_contentWillChange'); + removeObserver(this, 'content', null, '_contentDidChange'); + + callback.call(this); + + addBeforeObserver(this, 'content', null, '_contentWillChange'); + addObserver(this, 'content', null, '_contentDidChange'); + }, + + itemViewClass: _MetamorphView, + emptyViewClass: _MetamorphView, + + createChildView: function(view, attrs) { + view = this._super(view, attrs); + + // At the moment, if a container view subclass wants + // to insert keywords, it is responsible for cloning + // the keywords hash. This will be fixed momentarily. + var keyword = get(this, 'keyword'); + var content = get(view, 'content'); + + if (keyword) { + var data = get(view, 'templateData'); + + data = copy(data); + data.keywords = view.cloneKeywords(); + set(view, 'templateData', data); + + // In this case, we do not bind, because the `content` of + // a #each item cannot change. + data.keywords[keyword] = content; + } + + // If {{#each}} is looping over an array of controllers, + // point each child view at their respective controller. + if (content && content.isController) { + set(view, 'controller', content); + } + + return view; + }, + + destroy: function() { + if (!this._super()) { return; } + + var arrayController = get(this, '_arrayController'); + + if (arrayController) { + arrayController.destroy(); + } + + return this; + } + }); + + // Defeatureify doesn't seem to like nested functions that need to be removed + function _addMetamorphCheck() { + EachView.reopen({ + _checkMetamorph: on('didInsertElement', function() { + }) + }); + } + + // until ember-debug is es6ed + var runInDebug = function(f){ f(); }; + + var GroupedEach = EmberHandlebars.GroupedEach = function(context, path, options) { + var self = this, + normalized = EmberHandlebars.normalizePath(context, path, options.data); + + this.context = context; + this.path = path; + this.options = options; + this.template = options.fn; + this.containingView = options.data.view; + this.normalizedRoot = normalized.root; + this.normalizedPath = normalized.path; + this.content = this.lookupContent(); + + this.addContentObservers(); + this.addArrayObservers(); + + this.containingView.on('willClearRender', function() { + self.destroy(); + }); + }; + + GroupedEach.prototype = { + contentWillChange: function() { + this.removeArrayObservers(); + }, + + contentDidChange: function() { + this.content = this.lookupContent(); + this.addArrayObservers(); + this.rerenderContainingView(); + }, + + contentArrayWillChange: K, + + contentArrayDidChange: function() { + this.rerenderContainingView(); + }, + + lookupContent: function() { + return handlebarsGet(this.normalizedRoot, this.normalizedPath, this.options); + }, + + addArrayObservers: function() { + if (!this.content) { return; } + + this.content.addArrayObserver(this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + }, + + removeArrayObservers: function() { + if (!this.content) { return; } + + this.content.removeArrayObserver(this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + }, + + addContentObservers: function() { + addBeforeObserver(this.normalizedRoot, this.normalizedPath, this, this.contentWillChange); + addObserver(this.normalizedRoot, this.normalizedPath, this, this.contentDidChange); + }, + + removeContentObservers: function() { + removeBeforeObserver(this.normalizedRoot, this.normalizedPath, this.contentWillChange); + removeObserver(this.normalizedRoot, this.normalizedPath, this.contentDidChange); + }, + + render: function() { + if (!this.content) { return; } + + var content = this.content, + contentLength = get(content, 'length'), + options = this.options, + data = options.data, + template = this.template; + + data.insideEach = true; + for (var i = 0; i < contentLength; i++) { + var context = content.objectAt(i); + options.data.keywords[options.hash.keyword] = context; + template(context, { data: data }); + } + }, + + rerenderContainingView: function() { + var self = this; + run.scheduleOnce('render', this, function() { + // It's possible it's been destroyed after we enqueued a re-render call. + if (!self.destroyed) { + self.containingView.rerender(); + } + }); + }, + + destroy: function() { + this.removeContentObservers(); + if (this.content) { + this.removeArrayObservers(); + } + this.destroyed = true; + } + }; + + /** + The `{{#each}}` helper loops over elements in a collection, rendering its + block once for each item. It is an extension of the base Handlebars `{{#each}}` + helper: + + ```javascript + Developers = [{name: 'Yehuda'},{name: 'Tom'}, {name: 'Paul'}]; + ``` + + ```handlebars + {{#each Developers}} + {{name}} + {{/each}} + ``` + + `{{each}}` supports an alternative syntax with element naming: + + ```handlebars + {{#each person in Developers}} + {{person.name}} + {{/each}} + ``` + + When looping over objects that do not have properties, `{{this}}` can be used + to render the object: + + ```javascript + DeveloperNames = ['Yehuda', 'Tom', 'Paul'] + ``` + + ```handlebars + {{#each DeveloperNames}} + {{this}} + {{/each}} + ``` + ### {{else}} condition + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. + + ``` + {{#each person in Developers}} + {{person.name}} + {{else}} +

    Sorry, nobody is available for this task.

    + {{/each}} + ``` + ### Specifying a View class for items + If you provide an `itemViewClass` option that references a view class + with its own `template` you can omit the block. + + The following template: + + ```handlebars + {{#view App.MyView }} + {{each view.items itemViewClass="App.AnItemView"}} + {{/view}} + ``` + + And application code + + ```javascript + App = Ember.Application.create({ + MyView: Ember.View.extend({ + items: [ + Ember.Object.create({name: 'Dave'}), + Ember.Object.create({name: 'Mary'}), + Ember.Object.create({name: 'Sara'}) + ] + }) + }); + + App.AnItemView = Ember.View.extend({ + template: Ember.Handlebars.compile("Greetings {{name}}") + }); + ``` + + Will result in the HTML structure below + + ```html +
    +
    Greetings Dave
    +
    Greetings Mary
    +
    Greetings Sara
    +
    + ``` + + If an `itemViewClass` is defined on the helper, and therefore the helper is not + being used as a block, an `emptyViewClass` can also be provided optionally. + The `emptyViewClass` will match the behavior of the `{{else}}` condition + described above. That is, the `emptyViewClass` will render if the collection + is empty. + + ### Representing each item with a Controller. + By default the controller lookup within an `{{#each}}` block will be + the controller of the template where the `{{#each}}` was used. If each + item needs to be presented by a custom controller you can provide a + `itemController` option which references a controller by lookup name. + Each item in the loop will be wrapped in an instance of this controller + and the item itself will be set to the `model` property of that controller. + + This is useful in cases where properties of model objects need transformation + or synthesis for display: + + ```javascript + App.DeveloperController = Ember.ObjectController.extend({ + isAvailableForHire: function() { + return !this.get('model.isEmployed') && this.get('model.isSeekingWork'); + }.property('isEmployed', 'isSeekingWork') + }) + ``` + + ```handlebars + {{#each person in developers itemController="developer"}} + {{person.name}} {{#if person.isAvailableForHire}}Hire me!{{/if}} + {{/each}} + ``` + + Each itemController will receive a reference to the current controller as + a `parentController` property. + + ### (Experimental) Grouped Each + + When used in conjunction with the experimental [group helper](https://github.com/emberjs/group-helper), + you can inform Handlebars to re-render an entire group of items instead of + re-rendering them one at a time (in the event that they are changed en masse + or an item is added/removed). + + ```handlebars + {{#group}} + {{#each people}} + {{firstName}} {{lastName}} + {{/each}} + {{/group}} + ``` + + This can be faster than the normal way that Handlebars re-renders items + in some cases. + + If for some reason you have a group with more than one `#each`, you can make + one of the collections be updated in normal (non-grouped) fashion by setting + the option `groupedRows=true` (counter-intuitive, I know). + + For example, + + ```handlebars + {{dealershipName}} + + {{#group}} + {{#each dealers}} + {{firstName}} {{lastName}} + {{/each}} + + {{#each car in cars groupedRows=true}} + {{car.make}} {{car.model}} {{car.color}} + {{/each}} + {{/group}} + ``` + Any change to `dealershipName` or the `dealers` collection will cause the + entire group to be re-rendered. However, changes to the `cars` collection + will be re-rendered individually (as normal). + + Note that `group` behavior is also disabled by specifying an `itemViewClass`. + + @method each + @for Ember.Handlebars.helpers + @param [name] {String} name for item (used with `in`) + @param [path] {String} path + @param [options] {Object} Handlebars key/value pairs of options + @param [options.itemViewClass] {String} a path to a view class used for each item + @param [options.itemController] {String} name of a controller to be created for each item + @param [options.groupedRows] {boolean} enable normal item-by-item rendering when inside a `#group` helper + */ + function eachHelper(path, options) { + var ctx, helperName = 'each'; + + if (arguments.length === 4) { + + var keywordName = arguments[0]; + + + options = arguments[3]; + path = arguments[2]; + + helperName += ' ' + keywordName + ' in ' + path; + + if (path === '') { path = "this"; } + + options.hash.keyword = keywordName; + + } else if (arguments.length === 1) { + options = path; + path = 'this'; + } else { + helperName += ' ' + path; + } + + options.hash.dataSourceBinding = path; + // Set up emptyView as a metamorph with no tag + //options.hash.emptyViewClass = Ember._MetamorphView; + + // can't rely on this default behavior when use strict + ctx = this || window; + + options.helperName = options.helperName || helperName; + + if (options.data.insideGroup && !options.hash.groupedRows && !options.hash.itemViewClass) { + new GroupedEach(ctx, path, options).render(); + } else { + // ES6TODO: figure out how to do this without global lookup. + return helpers.collection.call(ctx, 'Ember.Handlebars.EachView', options); + } + } + + __exports__.EachView = EachView; + __exports__.GroupedEach = GroupedEach; + __exports__.eachHelper = eachHelper; + }); +define("ember-handlebars/helpers/loc", + ["ember-runtime/system/string","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var loc = __dependency1__.loc; + + /** + @module ember + @submodule ember-handlebars + */ + + // ES6TODO: + // Pretty sure this can be expressed as + // var locHelper EmberStringUtils.loc ? + + /** + Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the + provided string. + + This is a convenient way to localize text. For example: + + ```html + + ``` + + Take note that `"welcome"` is a string and not an object + reference. + + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to + set up localized string references. + + @method loc + @for Ember.Handlebars.helpers + @param {String} str The string to format + @see {Ember.String#loc} + */ + __exports__["default"] = function locHelper(str) { + return loc(str); + } + }); +define("ember-handlebars/helpers/partial", + ["ember-metal/core","ember-metal/is_none","ember-handlebars/ext","ember-handlebars/helpers/binding","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + // Ember.assert + // var emberAssert = Ember.assert; + + var isNone = __dependency2__.isNone; + var handlebarsGet = __dependency3__.handlebarsGet; + var bind = __dependency4__.bind; + + /** + @module ember + @submodule ember-handlebars + */ + + /** + The `partial` helper renders another template without + changing the template context: + + ```handlebars + {{foo}} + {{partial "nav"}} + ``` + + The above example template will render a template named + "_nav", which has the same context as the parent template + it's rendered into, so if the "_nav" template also referenced + `{{foo}}`, it would print the same thing as the `{{foo}}` + in the above example. + + If a "_nav" template isn't found, the `partial` helper will + fall back to a template named "nav". + + ## Bound template names + + The parameter supplied to `partial` can also be a path + to a property containing a template name, e.g.: + + ```handlebars + {{partial someTemplateName}} + ``` + + The above example will look up the value of `someTemplateName` + on the template context (e.g. a controller) and use that + value as the name of the template to render. If the resolved + value is falsy, nothing will be rendered. If `someTemplateName` + changes, the partial will be re-rendered using the new template + name. + + ## Setting the partial's context with `with` + + The `partial` helper can be used in conjunction with the `with` + helper to set a context that will be used by the partial: + + ```handlebars + {{#with currentUser}} + {{partial "user_info"}} + {{/with}} + ``` + + @method partial + @for Ember.Handlebars.helpers + @param {String} partialName the name of the template to render minus the leading underscore + */ + + __exports__["default"] = function partialHelper(name, options) { + + var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this; + + options.helperName = options.helperName || 'partial'; + + if (options.types[0] === "ID") { + // Helper was passed a property path; we need to + // create a binding that will re-render whenever + // this property changes. + options.fn = function(context, fnOptions) { + var partialName = handlebarsGet(context, name, fnOptions); + renderPartial(context, partialName, fnOptions); + }; + + return bind.call(context, name, options, true, exists); + } else { + // Render the partial right into parent template. + renderPartial(context, name, options); + } + } + + function exists(value) { + return !isNone(value); + } + + function renderPartial(context, name, options) { + var nameParts = name.split("/"); + var lastPart = nameParts[nameParts.length - 1]; + + nameParts[nameParts.length - 1] = "_" + lastPart; + + var view = options.data.view; + var underscoredName = nameParts.join("/"); + var template = view.templateForName(underscoredName); + var deprecatedTemplate = !template && view.templateForName(name); + + + template = template || deprecatedTemplate; + + template(context, { data: options.data }); + } + }); +define("ember-handlebars/helpers/shared", + ["ember-handlebars/ext","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var handlebarsGet = __dependency1__.handlebarsGet; + + __exports__["default"] = function resolvePaths(options) { + var ret = [], + contexts = options.contexts, + roots = options.roots, + data = options.data; + + for (var i=0, l=contexts.length; i + {{#with loggedInUser}} + Last Login: {{lastLogin}} + User Info: {{template "user_info"}} + {{/with}} + + ``` + + ```html + + ``` + + ```handlebars + {{#if isUser}} + {{template "user_info"}} + {{else}} + {{template "unlogged_user_info"}} + {{/if}} + ``` + + This helper looks for templates in the global `Ember.TEMPLATES` hash. If you + add `"; + return testEl.firstChild.innerHTML === ''; + })(); + + // IE 8 (and likely earlier) likes to move whitespace preceeding + // a script tag to appear after it. This means that we can + // accidentally remove whitespace when updating a morph. + var movesWhitespace = typeof document !== 'undefined' && (function() { + var testEl = document.createElement('div'); + testEl.innerHTML = "Test: Value"; + return testEl.childNodes[0].nodeValue === 'Test:' && + testEl.childNodes[2].nodeValue === ' Value'; + })(); + + // Use this to find children by ID instead of using jQuery + var findChildById = function(element, id) { + if (element.getAttribute('id') === id) { return element; } + + var len = element.childNodes.length, idx, node, found; + for (idx=0; idx 0) { + var len = matches.length, idx; + for (idx=0; idxTest'); + canSet = el.options.length === 1; + } + + innerHTMLTags[tagName] = canSet; + + return canSet; + }; + + function setInnerHTML(element, html) { + var tagName = element.tagName; + + if (canSetInnerHTML(tagName)) { + setInnerHTMLWithoutFix(element, html); + } else { + // Firefox versions < 11 do not have support for element.outerHTML. + var outerHTML = element.outerHTML || new XMLSerializer().serializeToString(element); + + var startTag = outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0], + endTag = ''; + + var wrapper = document.createElement('div'); + setInnerHTMLWithoutFix(wrapper, startTag + html + endTag); + element = wrapper.firstChild; + while (element.tagName !== tagName) { + element = element.nextSibling; + } + } + + return element; + } + + __exports__.setInnerHTML = setInnerHTML;function isSimpleClick(event) { + var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey, + secondaryClick = event.which > 1; // IE9 may return undefined + + return !modifier && !secondaryClick; + } + + __exports__.isSimpleClick = isSimpleClick; + }); +define("ember-views/views/collection_view", + ["ember-metal/core","ember-metal/platform","ember-metal/binding","ember-metal/merge","ember-metal/property_get","ember-metal/property_set","ember-runtime/system/string","ember-views/views/container_view","ember-views/views/core_view","ember-views/views/view","ember-metal/mixin","ember-runtime/mixins/array","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __exports__) { + "use strict"; + + /** + @module ember + @submodule ember-views + */ + + var Ember = __dependency1__["default"]; + // Ember.assert + var create = __dependency2__.create; + var isGlobalPath = __dependency3__.isGlobalPath; + var merge = __dependency4__["default"]; + var get = __dependency5__.get; + var set = __dependency6__.set; + var fmt = __dependency7__.fmt; + var ContainerView = __dependency8__["default"]; + var CoreView = __dependency9__["default"]; + var View = __dependency10__["default"]; + var observer = __dependency11__.observer; + var beforeObserver = __dependency11__.beforeObserver; + var EmberArray = __dependency12__["default"]; + + /** + `Ember.CollectionView` is an `Ember.View` descendent responsible for managing + a collection (an array or array-like object) by maintaining a child view object + and associated DOM representation for each item in the array and ensuring + that child views and their associated rendered HTML are updated when items in + the array are added, removed, or replaced. + + ## Setting content + + The managed collection of objects is referenced as the `Ember.CollectionView` + instance's `content` property. + + ```javascript + someItemsView = Ember.CollectionView.create({ + content: ['A', 'B','C'] + }) + ``` + + The view for each item in the collection will have its `content` property set + to the item. + + ## Specifying itemViewClass + + By default the view class for each item in the managed collection will be an + instance of `Ember.View`. You can supply a different class by setting the + `CollectionView`'s `itemViewClass` property. + + Given an empty `` and the following code: + + ```javascript + someItemsView = Ember.CollectionView.create({ + classNames: ['a-collection'], + content: ['A','B','C'], + itemViewClass: Ember.View.extend({ + template: Ember.Handlebars.compile("the letter: {{view.content}}") + }) + }); + + someItemsView.appendTo('body'); + ``` + + Will result in the following HTML structure + + ```html +
    +
    the letter: A
    +
    the letter: B
    +
    the letter: C
    +
    + ``` + + ## Automatic matching of parent/child tagNames + + Setting the `tagName` property of a `CollectionView` to any of + "ul", "ol", "table", "thead", "tbody", "tfoot", "tr", or "select" will result + in the item views receiving an appropriately matched `tagName` property. + + Given an empty `` and the following code: + + ```javascript + anUnorderedListView = Ember.CollectionView.create({ + tagName: 'ul', + content: ['A','B','C'], + itemViewClass: Ember.View.extend({ + template: Ember.Handlebars.compile("the letter: {{view.content}}") + }) + }); + + anUnorderedListView.appendTo('body'); + ``` + + Will result in the following HTML structure + + ```html +
      +
    • the letter: A
    • +
    • the letter: B
    • +
    • the letter: C
    • +
    + ``` + + Additional `tagName` pairs can be provided by adding to + `Ember.CollectionView.CONTAINER_MAP ` + + ```javascript + Ember.CollectionView.CONTAINER_MAP['article'] = 'section' + ``` + + ## Programmatic creation of child views + + For cases where additional customization beyond the use of a single + `itemViewClass` or `tagName` matching is required CollectionView's + `createChildView` method can be overidden: + + ```javascript + CustomCollectionView = Ember.CollectionView.extend({ + createChildView: function(viewClass, attrs) { + if (attrs.content.kind == 'album') { + viewClass = App.AlbumView; + } else { + viewClass = App.SongView; + } + return this._super(viewClass, attrs); + } + }); + ``` + + ## Empty View + + You can provide an `Ember.View` subclass to the `Ember.CollectionView` + instance as its `emptyView` property. If the `content` property of a + `CollectionView` is set to `null` or an empty array, an instance of this view + will be the `CollectionView`s only child. + + ```javascript + aListWithNothing = Ember.CollectionView.create({ + classNames: ['nothing'] + content: null, + emptyView: Ember.View.extend({ + template: Ember.Handlebars.compile("The collection is empty") + }) + }); + + aListWithNothing.appendTo('body'); + ``` + + Will result in the following HTML structure + + ```html +
    +
    + The collection is empty +
    +
    + ``` + + ## Adding and Removing items + + The `childViews` property of a `CollectionView` should not be directly + manipulated. Instead, add, remove, replace items from its `content` property. + This will trigger appropriate changes to its rendered HTML. + + + @class CollectionView + @namespace Ember + @extends Ember.ContainerView + @since Ember 0.9 + */ + var CollectionView = ContainerView.extend({ + + /** + A list of items to be displayed by the `Ember.CollectionView`. + + @property content + @type Ember.Array + @default null + */ + content: null, + + /** + This provides metadata about what kind of empty view class this + collection would like if it is being instantiated from another + system (like Handlebars) + + @private + @property emptyViewClass + */ + emptyViewClass: View, + + /** + An optional view to display if content is set to an empty array. + + @property emptyView + @type Ember.View + @default null + */ + emptyView: null, + + /** + @property itemViewClass + @type Ember.View + @default Ember.View + */ + itemViewClass: View, + + /** + Setup a CollectionView + + @method init + */ + init: function() { + var ret = this._super(); + this._contentDidChange(); + return ret; + }, + + /** + Invoked when the content property is about to change. Notifies observers that the + entire array content will change. + + @private + @method _contentWillChange + */ + _contentWillChange: beforeObserver('content', function() { + var content = this.get('content'); + + if (content) { content.removeArrayObserver(this); } + var len = content ? get(content, 'length') : 0; + this.arrayWillChange(content, 0, len); + }), + + /** + Check to make sure that the content has changed, and if so, + update the children directly. This is always scheduled + asynchronously, to allow the element to be created before + bindings have synchronized and vice versa. + + @private + @method _contentDidChange + */ + _contentDidChange: observer('content', function() { + var content = get(this, 'content'); + + if (content) { + this._assertArrayLike(content); + content.addArrayObserver(this); + } + + var len = content ? get(content, 'length') : 0; + this.arrayDidChange(content, 0, null, len); + }), + + /** + Ensure that the content implements Ember.Array + + @private + @method _assertArrayLike + */ + _assertArrayLike: function(content) { + }, + + /** + Removes the content and content observers. + + @method destroy + */ + destroy: function() { + if (!this._super()) { return; } + + var content = get(this, 'content'); + if (content) { content.removeArrayObserver(this); } + + if (this._createdEmptyView) { + this._createdEmptyView.destroy(); + } + + return this; + }, + + /** + Called when a mutation to the underlying content array will occur. + + This method will remove any views that are no longer in the underlying + content array. + + Invokes whenever the content array itself will change. + + @method arrayWillChange + @param {Array} content the managed collection of objects + @param {Number} start the index at which the changes will occurr + @param {Number} removed number of object to be removed from content + */ + arrayWillChange: function(content, start, removedCount) { + // If the contents were empty before and this template collection has an + // empty view remove it now. + var emptyView = get(this, 'emptyView'); + if (emptyView && emptyView instanceof View) { + emptyView.removeFromParent(); + } + + // Loop through child views that correspond with the removed items. + // Note that we loop from the end of the array to the beginning because + // we are mutating it as we go. + var childViews = this._childViews, childView, idx, len; + + len = this._childViews.length; + + var removingAll = removedCount === len; + + if (removingAll) { + this.currentState.empty(this); + this.invokeRecursively(function(view) { + view.removedFromDOM = true; + }, false); + } + + for (idx = start + removedCount - 1; idx >= start; idx--) { + childView = childViews[idx]; + childView.destroy(); + } + }, + + /** + Called when a mutation to the underlying content array occurs. + + This method will replay that mutation against the views that compose the + `Ember.CollectionView`, ensuring that the view reflects the model. + + This array observer is added in `contentDidChange`. + + @method arrayDidChange + @param {Array} content the managed collection of objects + @param {Number} start the index at which the changes occurred + @param {Number} removed number of object removed from content + @param {Number} added number of object added to content + */ + arrayDidChange: function(content, start, removed, added) { + var addedViews = [], view, item, idx, len, itemViewClass, + emptyView; + + len = content ? get(content, 'length') : 0; + + if (len) { + itemViewClass = get(this, 'itemViewClass'); + + if ('string' === typeof itemViewClass && isGlobalPath(itemViewClass)) { + itemViewClass = get(itemViewClass) || itemViewClass; + } + + + for (idx = start; idx < start+added; idx++) { + item = content.objectAt(idx); + + view = this.createChildView(itemViewClass, { + content: item, + contentIndex: idx + }); + + addedViews.push(view); + } + } else { + emptyView = get(this, 'emptyView'); + + if (!emptyView) { return; } + + if ('string' === typeof emptyView && isGlobalPath(emptyView)) { + emptyView = get(emptyView) || emptyView; + } + + emptyView = this.createChildView(emptyView); + addedViews.push(emptyView); + set(this, 'emptyView', emptyView); + + if (CoreView.detect(emptyView)) { + this._createdEmptyView = emptyView; + } + } + + this.replace(start, 0, addedViews); + }, + + /** + Instantiates a view to be added to the childViews array during view + initialization. You generally will not call this method directly unless + you are overriding `createChildViews()`. Note that this method will + automatically configure the correct settings on the new view instance to + act as a child of the parent. + + The tag name for the view will be set to the tagName of the viewClass + passed in. + + @method createChildView + @param {Class} viewClass + @param {Hash} [attrs] Attributes to add + @return {Ember.View} new instance + */ + createChildView: function(view, attrs) { + view = this._super(view, attrs); + + var itemTagName = get(view, 'tagName'); + + if (itemTagName === null || itemTagName === undefined) { + itemTagName = CollectionView.CONTAINER_MAP[get(this, 'tagName')]; + set(view, 'tagName', itemTagName); + } + + return view; + } + }); + + /** + A map of parent tags to their default child tags. You can add + additional parent tags if you want collection views that use + a particular parent tag to default to a child tag. + + @property CONTAINER_MAP + @type Hash + @static + @final + */ + CollectionView.CONTAINER_MAP = { + ul: 'li', + ol: 'li', + table: 'tr', + thead: 'tr', + tbody: 'tr', + tfoot: 'tr', + tr: 'td', + select: 'option' + }; + + __exports__["default"] = CollectionView; + }); +define("ember-views/views/component", + ["ember-metal/core","ember-views/mixins/component_template_deprecation","ember-runtime/mixins/target_action_support","ember-views/views/view","ember-metal/property_get","ember-metal/property_set","ember-metal/is_none","ember-metal/computed","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + // Ember.assert, Ember.Handlebars + + var ComponentTemplateDeprecation = __dependency2__["default"]; + var TargetActionSupport = __dependency3__["default"]; + var View = __dependency4__["default"]; + + var get = __dependency5__.get; + var set = __dependency6__.set; + var isNone = __dependency7__.isNone; + + var computed = __dependency8__.computed; + + var a_slice = Array.prototype.slice; + + /** + @module ember + @submodule ember-views + */ + + /** + An `Ember.Component` is a view that is completely + isolated. Property access in its templates go + to the view object and actions are targeted at + the view object. There is no access to the + surrounding context or outer controller; all + contextual information must be passed in. + + The easiest way to create an `Ember.Component` is via + a template. If you name a template + `components/my-foo`, you will be able to use + `{{my-foo}}` in other templates, which will make + an instance of the isolated component. + + ```handlebars + {{app-profile person=currentUser}} + ``` + + ```handlebars + +

    {{person.title}}

    + +

    {{person.signature}}

    + ``` + + You can use `yield` inside a template to + include the **contents** of any block attached to + the component. The block will be executed in the + context of the surrounding context or outer controller: + + ```handlebars + {{#app-profile person=currentUser}} +

    Admin mode

    + {{! Executed in the controller's context. }} + {{/app-profile}} + ``` + + ```handlebars + +

    {{person.title}}

    + {{! Executed in the components context. }} + {{yield}} {{! block contents }} + ``` + + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. Note that `Component` needs to be appended to the name of + your subclass like `AppProfileComponent`. + + For example, you could implement the action + `hello` for the `app-profile` component: + + ```javascript + App.AppProfileComponent = Ember.Component.extend({ + actions: { + hello: function(name) { + console.log("Hello", name); + } + } + }); + ``` + + And then use it in the component's template: + + ```handlebars + + +

    {{person.title}}

    + {{yield}} + + + ``` + + Components must have a `-` in their name to avoid + conflicts with built-in controls that wrap HTML + elements. This is consistent with the same + requirement in web components. + + @class Component + @namespace Ember + @extends Ember.View + */ + var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, { + instrumentName: 'component', + instrumentDisplay: computed(function() { + if (this._debugContainerKey) { + return '{{' + this._debugContainerKey.split(':')[1] + '}}'; + } + }), + + init: function() { + this._super(); + set(this, 'origContext', get(this, 'context')); + set(this, 'context', this); + set(this, 'controller', this); + }, + + defaultLayout: function(context, options){ + Ember.Handlebars.helpers['yield'].call(context, options); + }, + + /** + A components template property is set by passing a block + during its invocation. It is executed within the parent context. + + Example: + + ```handlebars + {{#my-component}} + // something that is run in the context + // of the parent context + {{/my-component}} + ``` + + Specifying a template directly to a component is deprecated without + also specifying the layout property. + + @deprecated + @property template + */ + template: computed(function(key, value) { + if (value !== undefined) { return value; } + + var templateName = get(this, 'templateName'), + template = this.templateForName(templateName, 'template'); + + + return template || get(this, 'defaultTemplate'); + }).property('templateName'), + + /** + Specifying a components `templateName` is deprecated without also + providing the `layout` or `layoutName` properties. + + @deprecated + @property templateName + */ + templateName: null, + + // during render, isolate keywords + cloneKeywords: function() { + return { + view: this, + controller: this + }; + }, + + _yield: function(context, options) { + var view = options.data.view, + parentView = this._parentView, + template = get(this, 'template'); + + if (template) { + + view.appendChild(View, { + isVirtual: true, + tagName: '', + _contextView: parentView, + template: template, + context: options.data.insideGroup ? get(this, 'origContext') : get(parentView, 'context'), + controller: get(parentView, 'controller'), + templateData: { keywords: parentView.cloneKeywords(), insideGroup: options.data.insideGroup } + }); + } + }, + + /** + If the component is currently inserted into the DOM of a parent view, this + property will point to the controller of the parent view. + + @property targetObject + @type Ember.Controller + @default null + */ + targetObject: computed(function(key) { + var parentView = get(this, '_parentView'); + return parentView ? get(parentView, 'controller') : null; + }).property('_parentView'), + + /** + Triggers a named action on the controller context where the component is used if + this controller has registered for notifications of the action. + + For example a component for playing or pausing music may translate click events + into action notifications of "play" or "stop" depending on some internal state + of the component: + + + ```javascript + App.PlayButtonComponent = Ember.Component.extend({ + click: function(){ + if (this.get('isPlaying')) { + this.sendAction('play'); + } else { + this.sendAction('stop'); + } + } + }); + ``` + + When used inside a template these component actions are configured to + trigger actions in the outer application context: + + ```handlebars + {{! application.hbs }} + {{play-button play="musicStarted" stop="musicStopped"}} + ``` + + When the component receives a browser `click` event it translate this + interaction into application-specific semantics ("play" or "stop") and + triggers the specified action name on the controller for the template + where the component is used: + + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + actions: { + musicStarted: function(){ + // called when the play button is clicked + // and the music started playing + }, + musicStopped: function(){ + // called when the play button is clicked + // and the music stopped playing + } + } + }); + ``` + + If no action name is passed to `sendAction` a default name of "action" + is assumed. + + ```javascript + App.NextButtonComponent = Ember.Component.extend({ + click: function(){ + this.sendAction(); + } + }); + ``` + + ```handlebars + {{! application.hbs }} + {{next-button action="playNextSongInAlbum"}} + ``` + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + actions: { + playNextSongInAlbum: function(){ + ... + } + } + }); + ``` + + @method sendAction + @param [action] {String} the action to trigger + @param [context] {*} a context to send with the action + */ + sendAction: function(action) { + var actionName, + contexts = a_slice.call(arguments, 1); + + // Send the default action + if (action === undefined) { + actionName = get(this, 'action'); + } else { + actionName = get(this, action); + } + + // If no action name for that action could be found, just abort. + if (actionName === undefined) { return; } + + this.triggerAction({ + action: actionName, + actionContext: contexts + }); + } + }); + + __exports__["default"] = Component; + }); +define("ember-views/views/container_view", + ["ember-metal/core","ember-metal/merge","ember-runtime/mixins/mutable_array","ember-metal/property_get","ember-metal/property_set","ember-views/views/view","ember-views/views/view_collection","ember-views/views/states","ember-metal/error","ember-metal/enumerable_utils","ember-metal/computed","ember-metal/run_loop","ember-metal/properties","ember-views/system/render_buffer","ember-metal/mixin","ember-runtime/system/native_array","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __exports__) { + "use strict"; + var Ember = __dependency1__["default"]; + // Ember.assert, Ember.K + + var merge = __dependency2__["default"]; + var MutableArray = __dependency3__["default"]; + var get = __dependency4__.get; + var set = __dependency5__.set; + + var View = __dependency6__["default"]; + var ViewCollection = __dependency7__["default"]; + + var cloneStates = __dependency8__.cloneStates; + var EmberViewStates = __dependency8__.states; + + var EmberError = __dependency9__["default"]; + + var forEach = __dependency10__.forEach; + + var computed = __dependency11__.computed; + var run = __dependency12__["default"]; + var defineProperty = __dependency13__.defineProperty; + var renderBuffer = __dependency14__["default"]; + var observer = __dependency15__.observer; + var beforeObserver = __dependency15__.beforeObserver; + var emberA = __dependency16__.A; + + /** + @module ember + @submodule ember-views + */ + + var states = cloneStates(EmberViewStates); + + /** + A `ContainerView` is an `Ember.View` subclass that implements `Ember.MutableArray` + allowing programmatic management of its child views. + + ## Setting Initial Child Views + + The initial array of child views can be set in one of two ways. You can + provide a `childViews` property at creation time that contains instance of + `Ember.View`: + + ```javascript + aContainer = Ember.ContainerView.create({ + childViews: [Ember.View.create(), Ember.View.create()] + }); + ``` + + You can also provide a list of property names whose values are instances of + `Ember.View`: + + ```javascript + aContainer = Ember.ContainerView.create({ + childViews: ['aView', 'bView', 'cView'], + aView: Ember.View.create(), + bView: Ember.View.create(), + cView: Ember.View.create() + }); + ``` + + The two strategies can be combined: + + ```javascript + aContainer = Ember.ContainerView.create({ + childViews: ['aView', Ember.View.create()], + aView: Ember.View.create() + }); + ``` + + Each child view's rendering will be inserted into the container's rendered + HTML in the same order as its position in the `childViews` property. + + ## Adding and Removing Child Views + + The container view implements `Ember.MutableArray` allowing programmatic management of its child views. + + To remove a view, pass that view into a `removeObject` call on the container view. + + Given an empty `` the following code + + ```javascript + aContainer = Ember.ContainerView.create({ + classNames: ['the-container'], + childViews: ['aView', 'bView'], + aView: Ember.View.create({ + template: Ember.Handlebars.compile("A") + }), + bView: Ember.View.create({ + template: Ember.Handlebars.compile("B") + }) + }); + + aContainer.appendTo('body'); + ``` + + Results in the HTML + + ```html +
    +
    A
    +
    B
    +
    + ``` + + Removing a view + + ```javascript + aContainer.toArray(); // [aContainer.aView, aContainer.bView] + aContainer.removeObject(aContainer.get('bView')); + aContainer.toArray(); // [aContainer.aView] + ``` + + Will result in the following HTML + + ```html +
    +
    A
    +
    + ``` + + Similarly, adding a child view is accomplished by adding `Ember.View` instances to the + container view. + + Given an empty `` the following code + + ```javascript + aContainer = Ember.ContainerView.create({ + classNames: ['the-container'], + childViews: ['aView', 'bView'], + aView: Ember.View.create({ + template: Ember.Handlebars.compile("A") + }), + bView: Ember.View.create({ + template: Ember.Handlebars.compile("B") + }) + }); + + aContainer.appendTo('body'); + ``` + + Results in the HTML + + ```html +
    +
    A
    +
    B
    +
    + ``` + + Adding a view + + ```javascript + AnotherViewClass = Ember.View.extend({ + template: Ember.Handlebars.compile("Another view") + }); + + aContainer.toArray(); // [aContainer.aView, aContainer.bView] + aContainer.pushObject(AnotherViewClass.create()); + aContainer.toArray(); // [aContainer.aView, aContainer.bView, ] + ``` + + Will result in the following HTML + + ```html +
    +
    A
    +
    B
    +
    Another view
    +
    + ``` + + ## Templates and Layout + + A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or + `defaultLayout` property on a container view will not result in the template + or layout being rendered. The HTML contents of a `Ember.ContainerView`'s DOM + representation will only be the rendered HTML of its child views. + + @class ContainerView + @namespace Ember + @extends Ember.View + */ + var ContainerView = View.extend(MutableArray, { + _states: states, + + willWatchProperty: function(prop){ + }, + + init: function() { + this._super(); + + var childViews = get(this, 'childViews'); + + // redefine view's childViews property that was obliterated + defineProperty(this, 'childViews', View.childViewsProperty); + + var _childViews = this._childViews; + + forEach(childViews, function(viewName, idx) { + var view; + + if ('string' === typeof viewName) { + view = get(this, viewName); + view = this.createChildView(view); + set(this, viewName, view); + } else { + view = this.createChildView(viewName); + } + + _childViews[idx] = view; + }, this); + + var currentView = get(this, 'currentView'); + if (currentView) { + if (!_childViews.length) { _childViews = this._childViews = this._childViews.slice(); } + _childViews.push(this.createChildView(currentView)); + } + }, + + replace: function(idx, removedCount, addedViews) { + var addedCount = addedViews ? get(addedViews, 'length') : 0; + var self = this; + + this.arrayContentWillChange(idx, removedCount, addedCount); + this.childViewsWillChange(this._childViews, idx, removedCount); + + if (addedCount === 0) { + this._childViews.splice(idx, removedCount) ; + } else { + var args = [idx, removedCount].concat(addedViews); + if (addedViews.length && !this._childViews.length) { this._childViews = this._childViews.slice(); } + this._childViews.splice.apply(this._childViews, args); + } + + this.arrayContentDidChange(idx, removedCount, addedCount); + this.childViewsDidChange(this._childViews, idx, removedCount, addedCount); + + return this; + }, + + objectAt: function(idx) { + return this._childViews[idx]; + }, + + length: computed(function () { + return this._childViews.length; + })["volatile"](), + + /** + Instructs each child view to render to the passed render buffer. + + @private + @method render + @param {Ember.RenderBuffer} buffer the buffer to render to + */ + render: function(buffer) { + this.forEachChildView(function(view) { + view.renderToBuffer(buffer); + }); + }, + + instrumentName: 'container', + + /** + When a child view is removed, destroy its element so that + it is removed from the DOM. + + The array observer that triggers this action is set up in the + `renderToBuffer` method. + + @private + @method childViewsWillChange + @param {Ember.Array} views the child views array before mutation + @param {Number} start the start position of the mutation + @param {Number} removed the number of child views removed + **/ + childViewsWillChange: function(views, start, removed) { + this.propertyWillChange('childViews'); + + if (removed > 0) { + var changedViews = views.slice(start, start+removed); + // transition to preRender before clearing parentView + this.currentState.childViewsWillChange(this, views, start, removed); + this.initializeViews(changedViews, null, null); + } + }, + + removeChild: function(child) { + this.removeObject(child); + return this; + }, + + /** + When a child view is added, make sure the DOM gets updated appropriately. + + If the view has already rendered an element, we tell the child view to + create an element and insert it into the DOM. If the enclosing container + view has already written to a buffer, but not yet converted that buffer + into an element, we insert the string representation of the child into the + appropriate place in the buffer. + + @private + @method childViewsDidChange + @param {Ember.Array} views the array of child views after the mutation has occurred + @param {Number} start the start position of the mutation + @param {Number} removed the number of child views removed + @param {Number} added the number of child views added + */ + childViewsDidChange: function(views, start, removed, added) { + if (added > 0) { + var changedViews = views.slice(start, start+added); + this.initializeViews(changedViews, this, get(this, 'templateData')); + this.currentState.childViewsDidChange(this, views, start, added); + } + this.propertyDidChange('childViews'); + }, + + initializeViews: function(views, parentView, templateData) { + forEach(views, function(view) { + set(view, '_parentView', parentView); + + if (!view.container && parentView) { + set(view, 'container', parentView.container); + } + + if (!get(view, 'templateData')) { + set(view, 'templateData', templateData); + } + }); + }, + + currentView: null, + + _currentViewWillChange: beforeObserver('currentView', function() { + var currentView = get(this, 'currentView'); + if (currentView) { + currentView.destroy(); + } + }), + + _currentViewDidChange: observer('currentView', function() { + var currentView = get(this, 'currentView'); + if (currentView) { + this.pushObject(currentView); + } + }), + + _ensureChildrenAreInDOM: function () { + this.currentState.ensureChildrenAreInDOM(this); + } + }); + + merge(states._default, { + childViewsWillChange: Ember.K, + childViewsDidChange: Ember.K, + ensureChildrenAreInDOM: Ember.K + }); + + merge(states.inBuffer, { + childViewsDidChange: function(parentView, views, start, added) { + throw new EmberError('You cannot modify child views while in the inBuffer state'); + } + }); + + merge(states.hasElement, { + childViewsWillChange: function(view, views, start, removed) { + for (var i=start; i + ``` + + ## HTML `class` Attribute + + The HTML `class` attribute of a view's tag can be set by providing a + `classNames` property that is set to an array of strings: + + ```javascript + MyView = Ember.View.extend({ + classNames: ['my-class', 'my-other-class'] + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + `class` attribute values can also be set by providing a `classNameBindings` + property set to an array of properties names for the view. The return value + of these properties will be added as part of the value for the view's `class` + attribute. These properties can be computed properties: + + ```javascript + MyView = Ember.View.extend({ + classNameBindings: ['propertyA', 'propertyB'], + propertyA: 'from-a', + propertyB: function() { + if (someLogic) { return 'from-b'; } + }.property() + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + If the value of a class name binding returns a boolean the property name + itself will be used as the class name if the property is true. The class name + will not be added if the value is `false` or `undefined`. + + ```javascript + MyView = Ember.View.extend({ + classNameBindings: ['hovered'], + hovered: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + When using boolean class name bindings you can supply a string value other + than the property name for use as the `class` HTML attribute by appending the + preferred value after a ":" character when defining the binding: + + ```javascript + MyView = Ember.View.extend({ + classNameBindings: ['awesome:so-very-cool'], + awesome: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + Boolean value class name bindings whose property names are in a + camelCase-style format will be converted to a dasherized format: + + ```javascript + MyView = Ember.View.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + Class name bindings can also refer to object values that are found by + traversing a path relative to the view itself: + + ```javascript + MyView = Ember.View.extend({ + classNameBindings: ['messages.empty'] + messages: Ember.Object.create({ + empty: true + }) + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + If you want to add a class name for a property which evaluates to true and + and a different class name if it evaluates to false, you can pass a binding + like this: + + ```javascript + // Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false + Ember.View.extend({ + classNameBindings: ['isEnabled:enabled:disabled'] + isEnabled: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + When isEnabled is `false`, the resulting HTML reprensentation looks like + this: + + ```html +
    + ``` + + This syntax offers the convenience to add a class if a property is `false`: + + ```javascript + // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false + Ember.View.extend({ + classNameBindings: ['isEnabled::disabled'] + isEnabled: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    + ``` + + When the `isEnabled` property on the view is set to `false`, it will result + in view instances with an HTML representation of: + + ```html +
    + ``` + + Updates to the the value of a class name binding will result in automatic + update of the HTML `class` attribute in the view's rendered HTML + representation. If the value becomes `false` or `undefined` the class name + will be removed. + + Both `classNames` and `classNameBindings` are concatenated properties. See + [Ember.Object](/api/classes/Ember.Object.html) documentation for more + information about concatenated properties. + + ## HTML Attributes + + The HTML attribute section of a view's tag can be set by providing an + `attributeBindings` property set to an array of property names on the view. + The return value of these properties will be used as the value of the view's + HTML associated attribute: + + ```javascript + AnchorView = Ember.View.extend({ + tagName: 'a', + attributeBindings: ['href'], + href: 'http://google.com' + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html + + ``` + + One property can be mapped on to another by placing a ":" between + the source property and the destination property: + + ```javascript + AnchorView = Ember.View.extend({ + tagName: 'a', + attributeBindings: ['url:href'], + url: 'http://google.com' + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html + + ``` + + If the return value of an `attributeBindings` monitored property is a boolean + the property will follow HTML's pattern of repeating the attribute's name as + its value: + + ```javascript + MyTextInput = Ember.View.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: true + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html + + ``` + + `attributeBindings` can refer to computed properties: + + ```javascript + MyTextInput = Ember.View.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: function() { + if (someLogic) { + return true; + } else { + return false; + } + }.property() + }); + ``` + + Updates to the the property of an attribute binding will result in automatic + update of the HTML attribute in the view's rendered HTML representation. + + `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) + documentation for more information about concatenated properties. + + ## Templates + + The HTML contents of a view's rendered representation are determined by its + template. Templates can be any function that accepts an optional context + parameter and returns a string of HTML that will be inserted within the + view's tag. Most typically in Ember this function will be a compiled + `Ember.Handlebars` template. + + ```javascript + AView = Ember.View.extend({ + template: Ember.Handlebars.compile('I am the template') + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    I am the template
    + ``` + + Within an Ember application is more common to define a Handlebars templates as + part of a page: + + ```html + + ``` + + And associate it by name using a view's `templateName` property: + + ```javascript + AView = Ember.View.extend({ + templateName: 'some-template' + }); + ``` + + If you have nested resources, your Handlebars template will look like this: + + ```html + + ``` + + And `templateName` property: + + ```javascript + AView = Ember.View.extend({ + templateName: 'posts/new' + }); + ``` + + Using a value for `templateName` that does not have a Handlebars template + with a matching `data-template-name` attribute will throw an error. + + For views classes that may have a template later defined (e.g. as the block + portion of a `{{view}}` Handlebars helper call in another template or in + a subclass), you can provide a `defaultTemplate` property set to compiled + template function. If a template is not later provided for the view instance + the `defaultTemplate` value will be used: + + ```javascript + AView = Ember.View.extend({ + defaultTemplate: Ember.Handlebars.compile('I was the default'), + template: null, + templateName: null + }); + ``` + + Will result in instances with an HTML representation of: + + ```html +
    I was the default
    + ``` + + If a `template` or `templateName` is provided it will take precedence over + `defaultTemplate`: + + ```javascript + AView = Ember.View.extend({ + defaultTemplate: Ember.Handlebars.compile('I was the default') + }); + + aView = AView.create({ + template: Ember.Handlebars.compile('I was the template, not default') + }); + ``` + + Will result in the following HTML representation when rendered: + + ```html +
    I was the template, not default
    + ``` + + ## View Context + + The default context of the compiled template is the view's controller: + + ```javascript + AView = Ember.View.extend({ + template: Ember.Handlebars.compile('Hello {{excitedGreeting}}') + }); + + aController = Ember.Object.create({ + firstName: 'Barry', + excitedGreeting: function() { + return this.get("content.firstName") + "!!!" + }.property() + }); + + aView = AView.create({ + controller: aController + }); + ``` + + Will result in an HTML representation of: + + ```html +
    Hello Barry!!!
    + ``` + + A context can also be explicitly supplied through the view's `context` + property. If the view has neither `context` nor `controller` properties, the + `parentView`'s context will be used. + + ## Layouts + + Views can have a secondary template that wraps their main template. Like + primary templates, layouts can be any function that accepts an optional + context parameter and returns a string of HTML that will be inserted inside + view's tag. Views whose HTML element is self closing (e.g. ``) + cannot have a layout and this property will be ignored. + + Most typically in Ember a layout will be a compiled `Ember.Handlebars` + template. + + A view's layout can be set directly with the `layout` property or reference + an existing Handlebars template by name with the `layoutName` property. + + A template used as a layout must contain a single use of the Handlebars + `{{yield}}` helper. The HTML contents of a view's rendered `template` will be + inserted at this location: + + ```javascript + AViewWithLayout = Ember.View.extend({ + layout: Ember.Handlebars.compile("
    {{yield}}
    "), + template: Ember.Handlebars.compile("I got wrapped") + }); + ``` + + Will result in view instances with an HTML representation of: + + ```html +
    +
    + I got wrapped +
    +
    + ``` + + See [Ember.Handlebars.helpers.yield](/api/classes/Ember.Handlebars.helpers.html#method_yield) + for more information. + + ## Responding to Browser Events + + Views can respond to user-initiated events in one of three ways: method + implementation, through an event manager, and through `{{action}}` helper use + in their template or layout. + + ### Method Implementation + + Views can respond to user-initiated events by implementing a method that + matches the event name. A `jQuery.Event` object will be passed as the + argument to this method. + + ```javascript + AView = Ember.View.extend({ + click: function(event) { + // will be called when when an instance's + // rendered element is clicked + } + }); + ``` + + ### Event Managers + + Views can define an object as their `eventManager` property. This object can + then implement methods that match the desired event names. Matching events + that occur on the view's rendered HTML or the rendered HTML of any of its DOM + descendants will trigger this method. A `jQuery.Event` object will be passed + as the first argument to the method and an `Ember.View` object as the + second. The `Ember.View` will be the view whose rendered HTML was interacted + with. This may be the view with the `eventManager` property or one of its + descendent views. + + ```javascript + AView = Ember.View.extend({ + eventManager: Ember.Object.create({ + doubleClick: function(event, view) { + // will be called when when an instance's + // rendered element or any rendering + // of this views's descendent + // elements is clicked + } + }) + }); + ``` + + An event defined for an event manager takes precedence over events of the + same name handled through methods on the view. + + ```javascript + AView = Ember.View.extend({ + mouseEnter: function(event) { + // will never trigger. + }, + eventManager: Ember.Object.create({ + mouseEnter: function(event, view) { + // takes precedence over AView#mouseEnter + } + }) + }); + ``` + + Similarly a view's event manager will take precedence for events of any views + rendered as a descendent. A method name that matches an event name will not + be called if the view instance was rendered inside the HTML representation of + a view that has an `eventManager` property defined that handles events of the + name. Events not handled by the event manager will still trigger method calls + on the descendent. + + ```javascript + OuterView = Ember.View.extend({ + template: Ember.Handlebars.compile("outer {{#view InnerView}}inner{{/view}} outer"), + eventManager: Ember.Object.create({ + mouseEnter: function(event, view) { + // view might be instance of either + // OuterView or InnerView depending on + // where on the page the user interaction occured + } + }) + }); + + InnerView = Ember.View.extend({ + click: function(event) { + // will be called if rendered inside + // an OuterView because OuterView's + // eventManager doesn't handle click events + }, + mouseEnter: function(event) { + // will never be called if rendered inside + // an OuterView. + } + }); + ``` + + ### Handlebars `{{action}}` Helper + + See [Handlebars.helpers.action](/api/classes/Ember.Handlebars.helpers.html#method_action). + + ### Event Names + + All of the event handling approaches described above respond to the same set + of events. The names of the built-in events are listed below. (The hash of + built-in events exists in `Ember.EventDispatcher`.) Additional, custom events + can be registered by using `Ember.Application.customEvents`. + + Touch events: + + * `touchStart` + * `touchMove` + * `touchEnd` + * `touchCancel` + + Keyboard events + + * `keyDown` + * `keyUp` + * `keyPress` + + Mouse events + + * `mouseDown` + * `mouseUp` + * `contextMenu` + * `click` + * `doubleClick` + * `mouseMove` + * `focusIn` + * `focusOut` + * `mouseEnter` + * `mouseLeave` + + Form events: + + * `submit` + * `change` + * `focusIn` + * `focusOut` + * `input` + + HTML5 drag and drop events: + + * `dragStart` + * `drag` + * `dragEnter` + * `dragLeave` + * `dragOver` + * `dragEnd` + * `drop` + + ## Handlebars `{{view}}` Helper + + Other `Ember.View` instances can be included as part of a view's template by + using the `{{view}}` Handlebars helper. See [Ember.Handlebars.helpers.view](/api/classes/Ember.Handlebars.helpers.html#method_view) + for additional information. + + @class View + @namespace Ember + @extends Ember.CoreView + */ + var View = CoreView.extend({ + + concatenatedProperties: ['classNames', 'classNameBindings', 'attributeBindings'], + + /** + @property isView + @type Boolean + @default true + @static + */ + isView: true, + + // .......................................................... + // TEMPLATE SUPPORT + // + + /** + The name of the template to lookup if no template is provided. + + By default `Ember.View` will lookup a template with this name in + `Ember.TEMPLATES` (a shared global object). + + @property templateName + @type String + @default null + */ + templateName: null, + + /** + The name of the layout to lookup if no layout is provided. + + By default `Ember.View` will lookup a template with this name in + `Ember.TEMPLATES` (a shared global object). + + @property layoutName + @type String + @default null + */ + layoutName: null, + + /** + Used to identify this view during debugging + + @property instrumentDisplay + @type String + */ + instrumentDisplay: computed(function() { + if (this.helperName) { + return '{{' + this.helperName + '}}'; + } + }), + + /** + The template used to render the view. This should be a function that + accepts an optional context parameter and returns a string of HTML that + will be inserted into the DOM relative to its parent view. + + In general, you should set the `templateName` property instead of setting + the template yourself. + + @property template + @type Function + */ + template: computed('templateName', function(key, value) { + if (value !== undefined) { return value; } + + var templateName = get(this, 'templateName'), + template = this.templateForName(templateName, 'template'); + + + return template || get(this, 'defaultTemplate'); + }), + + /** + The controller managing this view. If this property is set, it will be + made available for use by the template. + + @property controller + @type Object + */ + controller: computed('_parentView', function(key) { + var parentView = get(this, '_parentView'); + return parentView ? get(parentView, 'controller') : null; + }), + + /** + A view may contain a layout. A layout is a regular template but + supersedes the `template` property during rendering. It is the + responsibility of the layout template to retrieve the `template` + property from the view (or alternatively, call `Handlebars.helpers.yield`, + `{{yield}}`) to render it in the correct location. + + This is useful for a view that has a shared wrapper, but which delegates + the rendering of the contents of the wrapper to the `template` property + on a subclass. + + @property layout + @type Function + */ + layout: computed(function(key) { + var layoutName = get(this, 'layoutName'), + layout = this.templateForName(layoutName, 'layout'); + + + return layout || get(this, 'defaultLayout'); + }).property('layoutName'), + + _yield: function(context, options) { + var template = get(this, 'template'); + if (template) { template(context, options); } + }, + + templateForName: function(name, type) { + if (!name) { return; } + + if (!this.container) { + throw new EmberError('Container was not found when looking up a views template. ' + + 'This is most likely due to manually instantiating an Ember.View. ' + + 'See: http://git.io/EKPpnA'); + } + + return this.container.lookup('template:' + name); + }, + + /** + The object from which templates should access properties. + + This object will be passed to the template function each time the render + method is called, but it is up to the individual function to decide what + to do with it. + + By default, this will be the view's controller. + + @property context + @type Object + */ + context: computed(function(key, value) { + if (arguments.length === 2) { + set(this, '_context', value); + return value; + } else { + return get(this, '_context'); + } + })["volatile"](), + + /** + Private copy of the view's template context. This can be set directly + by Handlebars without triggering the observer that causes the view + to be re-rendered. + + The context of a view is looked up as follows: + + 1. Supplied context (usually by Handlebars) + 2. Specified controller + 3. `parentView`'s context (for a child of a ContainerView) + + The code in Handlebars that overrides the `_context` property first + checks to see whether the view has a specified controller. This is + something of a hack and should be revisited. + + @property _context + @private + */ + _context: computed(function(key) { + var parentView, controller; + + if (controller = get(this, 'controller')) { + return controller; + } + + parentView = this._parentView; + if (parentView) { + return get(parentView, '_context'); + } + + return null; + }), + + /** + If a value that affects template rendering changes, the view should be + re-rendered to reflect the new value. + + @method _contextDidChange + @private + */ + _contextDidChange: observer('context', function() { + this.rerender(); + }), + + /** + If `false`, the view will appear hidden in DOM. + + @property isVisible + @type Boolean + @default null + */ + isVisible: true, + + /** + Array of child views. You should never edit this array directly. + Instead, use `appendChild` and `removeFromParent`. + + @property childViews + @type Array + @default [] + @private + */ + childViews: childViewsProperty, + + _childViews: EMPTY_ARRAY, + + // When it's a virtual view, we need to notify the parent that their + // childViews will change. + _childViewsWillChange: beforeObserver('childViews', function() { + if (this.isVirtual) { + var parentView = get(this, 'parentView'); + if (parentView) { propertyWillChange(parentView, 'childViews'); } + } + }), + + // When it's a virtual view, we need to notify the parent that their + // childViews did change. + _childViewsDidChange: observer('childViews', function() { + if (this.isVirtual) { + var parentView = get(this, 'parentView'); + if (parentView) { propertyDidChange(parentView, 'childViews'); } + } + }), + + /** + Return the nearest ancestor that is an instance of the provided + class. + + @method nearestInstanceOf + @param {Class} klass Subclass of Ember.View (or Ember.View itself) + @return Ember.View + @deprecated + */ + nearestInstanceOf: function(klass) { + var view = get(this, 'parentView'); + + while (view) { + if (view instanceof klass) { return view; } + view = get(view, 'parentView'); + } + }, + + /** + Return the nearest ancestor that is an instance of the provided + class or mixin. + + @method nearestOfType + @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), + or an instance of Ember.Mixin. + @return Ember.View + */ + nearestOfType: function(klass) { + var view = get(this, 'parentView'), + isOfType = klass instanceof Mixin ? + function(view) { return klass.detect(view); } : + function(view) { return klass.detect(view.constructor); }; + + while (view) { + if (isOfType(view)) { return view; } + view = get(view, 'parentView'); + } + }, + + /** + Return the nearest ancestor that has a given property. + + @method nearestWithProperty + @param {String} property A property name + @return Ember.View + */ + nearestWithProperty: function(property) { + var view = get(this, 'parentView'); + + while (view) { + if (property in view) { return view; } + view = get(view, 'parentView'); + } + }, + + /** + Return the nearest ancestor whose parent is an instance of + `klass`. + + @method nearestChildOf + @param {Class} klass Subclass of Ember.View (or Ember.View itself) + @return Ember.View + */ + nearestChildOf: function(klass) { + var view = get(this, 'parentView'); + + while (view) { + if (get(view, 'parentView') instanceof klass) { return view; } + view = get(view, 'parentView'); + } + }, + + /** + When the parent view changes, recursively invalidate `controller` + + @method _parentViewDidChange + @private + */ + _parentViewDidChange: observer('_parentView', function() { + if (this.isDestroying) { return; } + + this.trigger('parentViewDidChange'); + + if (get(this, 'parentView.controller') && !get(this, 'controller')) { + this.notifyPropertyChange('controller'); + } + }), + + _controllerDidChange: observer('controller', function() { + if (this.isDestroying) { return; } + + this.rerender(); + + this.forEachChildView(function(view) { + view.propertyDidChange('controller'); + }); + }), + + cloneKeywords: function() { + var templateData = get(this, 'templateData'); + + var keywords = templateData ? copy(templateData.keywords) : {}; + set(keywords, 'view', this.isVirtual ? keywords.view : this); + set(keywords, '_view', this); + set(keywords, 'controller', get(this, 'controller')); + + return keywords; + }, + + /** + Called on your view when it should push strings of HTML into a + `Ember.RenderBuffer`. Most users will want to override the `template` + or `templateName` properties instead of this method. + + By default, `Ember.View` will look for a function in the `template` + property and invoke it with the value of `context`. The value of + `context` will be the view's controller unless you override it. + + @method render + @param {Ember.RenderBuffer} buffer The render buffer + */ + render: function(buffer) { + // If this view has a layout, it is the responsibility of the + // the layout to render the view's template. Otherwise, render the template + // directly. + var template = get(this, 'layout') || get(this, 'template'); + + if (template) { + var context = get(this, 'context'); + var keywords = this.cloneKeywords(); + var output; + + var data = { + view: this, + buffer: buffer, + isRenderData: true, + keywords: keywords, + insideGroup: get(this, 'templateData.insideGroup') + }; + + // Invoke the template with the provided template context, which + // is the view's controller by default. A hash of data is also passed that provides + // the template with access to the view and render buffer. + + // The template should write directly to the render buffer instead + // of returning a string. + output = template(context, { data: data }); + + // If the template returned a string instead of writing to the buffer, + // push the string onto the buffer. + if (output !== undefined) { buffer.push(output); } + } + }, + + /** + Renders the view again. This will work regardless of whether the + view is already in the DOM or not. If the view is in the DOM, the + rendering process will be deferred to give bindings a chance + to synchronize. + + If children were added during the rendering process using `appendChild`, + `rerender` will remove them, because they will be added again + if needed by the next `render`. + + In general, if the display of your view changes, you should modify + the DOM element directly instead of manually calling `rerender`, which can + be slow. + + @method rerender + */ + rerender: function() { + return this.currentState.rerender(this); + }, + + clearRenderedChildren: function() { + var lengthBefore = this.lengthBeforeRender, + lengthAfter = this.lengthAfterRender; + + // If there were child views created during the last call to render(), + // remove them under the assumption that they will be re-created when + // we re-render. + + // VIEW-TODO: Unit test this path. + var childViews = this._childViews; + for (var i=lengthAfter-1; i>=lengthBefore; i--) { + if (childViews[i]) { childViews[i].destroy(); } + } + }, + + /** + Iterates over the view's `classNameBindings` array, inserts the value + of the specified property into the `classNames` array, then creates an + observer to update the view's element if the bound property ever changes + in the future. + + @method _applyClassNameBindings + @private + */ + _applyClassNameBindings: function(classBindings) { + var classNames = this.classNames, + elem, newClass, dasherizedClass; + + // Loop through all of the configured bindings. These will be either + // property names ('isUrgent') or property paths relative to the view + // ('content.isUrgent') + forEach(classBindings, function(binding) { + + + // Variable in which the old class value is saved. The observer function + // closes over this variable, so it knows which string to remove when + // the property changes. + var oldClass; + // Extract just the property name from bindings like 'foo:bar' + var parsedPath = View._parsePropertyPath(binding); + + // Set up an observer on the context. If the property changes, toggle the + // class name. + var observer = function() { + // Get the current value of the property + newClass = this._classStringForProperty(binding); + elem = this.$(); + + // If we had previously added a class to the element, remove it. + if (oldClass) { + elem.removeClass(oldClass); + // Also remove from classNames so that if the view gets rerendered, + // the class doesn't get added back to the DOM. + classNames.removeObject(oldClass); + } + + // If necessary, add a new class. Make sure we keep track of it so + // it can be removed in the future. + if (newClass) { + elem.addClass(newClass); + oldClass = newClass; + } else { + oldClass = null; + } + }; + + // Get the class name for the property at its current value + dasherizedClass = this._classStringForProperty(binding); + + if (dasherizedClass) { + // Ensure that it gets into the classNames array + // so it is displayed when we render. + addObject(classNames, dasherizedClass); + + // Save a reference to the class name so we can remove it + // if the observer fires. Remember that this variable has + // been closed over by the observer. + oldClass = dasherizedClass; + } + + this.registerObserver(this, parsedPath.path, observer); + // Remove className so when the view is rerendered, + // the className is added based on binding reevaluation + this.one('willClearRender', function() { + if (oldClass) { + classNames.removeObject(oldClass); + oldClass = null; + } + }); + + }, this); + }, + + _unspecifiedAttributeBindings: null, + + /** + Iterates through the view's attribute bindings, sets up observers for each, + then applies the current value of the attributes to the passed render buffer. + + @method _applyAttributeBindings + @param {Ember.RenderBuffer} buffer + @private + */ + _applyAttributeBindings: function(buffer, attributeBindings) { + var attributeValue, + unspecifiedAttributeBindings = this._unspecifiedAttributeBindings = this._unspecifiedAttributeBindings || {}; + + forEach(attributeBindings, function(binding) { + var split = binding.split(':'), + property = split[0], + attributeName = split[1] || property; + + if (property in this) { + this._setupAttributeBindingObservation(property, attributeName); + + // Determine the current value and add it to the render buffer + // if necessary. + attributeValue = get(this, property); + View.applyAttributeBindings(buffer, attributeName, attributeValue); + } else { + unspecifiedAttributeBindings[property] = attributeName; + } + }, this); + + // Lazily setup setUnknownProperty after attributeBindings are initially applied + this.setUnknownProperty = this._setUnknownProperty; + }, + + _setupAttributeBindingObservation: function(property, attributeName) { + var attributeValue, elem; + + // Create an observer to add/remove/change the attribute if the + // JavaScript property changes. + var observer = function() { + elem = this.$(); + + attributeValue = get(this, property); + + View.applyAttributeBindings(elem, attributeName, attributeValue); + }; + + this.registerObserver(this, property, observer); + }, + + /** + We're using setUnknownProperty as a hook to setup attributeBinding observers for + properties that aren't defined on a view at initialization time. + + Note: setUnknownProperty will only be called once for each property. + + @method setUnknownProperty + @param key + @param value + @private + */ + setUnknownProperty: null, // Gets defined after initialization by _applyAttributeBindings + + _setUnknownProperty: function(key, value) { + var attributeName = this._unspecifiedAttributeBindings && this._unspecifiedAttributeBindings[key]; + if (attributeName) { + this._setupAttributeBindingObservation(key, attributeName); + } + + defineProperty(this, key); + return set(this, key, value); + }, + + /** + Given a property name, returns a dasherized version of that + property name if the property evaluates to a non-falsy value. + + For example, if the view has property `isUrgent` that evaluates to true, + passing `isUrgent` to this method will return `"is-urgent"`. + + @method _classStringForProperty + @param property + @private + */ + _classStringForProperty: function(property) { + var parsedPath = View._parsePropertyPath(property); + var path = parsedPath.path; + + var val = get(this, path); + if (val === undefined && isGlobalPath(path)) { + val = get(Ember.lookup, path); + } + + return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName); + }, + + // .......................................................... + // ELEMENT SUPPORT + // + + /** + Returns the current DOM element for the view. + + @property element + @type DOMElement + */ + element: computed('_parentView', function(key, value) { + if (value !== undefined) { + return this.currentState.setElement(this, value); + } else { + return this.currentState.getElement(this); + } + }), + + /** + Returns a jQuery object for this view's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + + For example, calling `view.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this view. + + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + */ + $: function(sel) { + return this.currentState.$(this, sel); + }, + + mutateChildViews: function(callback) { + var childViews = this._childViews, + idx = childViews.length, + view; + + while(--idx >= 0) { + view = childViews[idx]; + callback(this, view, idx); + } + + return this; + }, + + forEachChildView: function(callback) { + var childViews = this._childViews; + + if (!childViews) { return this; } + + var len = childViews.length, + view, idx; + + for (idx = 0; idx < len; idx++) { + view = childViews[idx]; + callback(view); + } + + return this; + }, + + /** + Appends the view's element to the specified parent element. + + If the view does not have an HTML representation yet, `createElement()` + will be called automatically. + + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing. + + This is not typically a function that you will need to call directly when + building your application. You might consider using `Ember.ContainerView` + instead. If you do need to use `appendTo`, be sure that the target element + you are providing is associated with an `Ember.Application` and does not + have an ancestor element that is associated with an Ember view. + + @method appendTo + @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object + @return {Ember.View} receiver + */ + appendTo: function(target) { + // Schedule the DOM element to be created and appended to the given + // element after bindings have synchronized. + this._insertElementLater(function() { + this.$().appendTo(target); + }); + + return this; + }, + + /** + Replaces the content of the specified parent element with this view's + element. If the view does not have an HTML representation yet, + `createElement()` will be called automatically. + + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing + + @method replaceIn + @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object + @return {Ember.View} received + */ + replaceIn: function(target) { + + this._insertElementLater(function() { + jQuery(target).empty(); + this.$().appendTo(target); + }); + + return this; + }, + + /** + Schedules a DOM operation to occur during the next render phase. This + ensures that all bindings have finished synchronizing before the view is + rendered. + + To use, pass a function that performs a DOM operation. + + Before your function is called, this view and all child views will receive + the `willInsertElement` event. After your function is invoked, this view + and all of its child views will receive the `didInsertElement` event. + + ```javascript + view._insertElementLater(function() { + this.createElement(); + this.$().appendTo('body'); + }); + ``` + + @method _insertElementLater + @param {Function} fn the function that inserts the element into the DOM + @private + */ + _insertElementLater: function(fn) { + this._scheduledInsert = run.scheduleOnce('render', this, '_insertElement', fn); + }, + + _insertElement: function (fn) { + this._scheduledInsert = null; + this.currentState.insertElement(this, fn); + }, + + /** + Appends the view's element to the document body. If the view does + not have an HTML representation yet, `createElement()` will be called + automatically. + + If your application uses the `rootElement` property, you must append + the view within that element. Rendering views outside of the `rootElement` + is not supported. + + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the document body until all bindings have + finished synchronizing. + + @method append + @return {Ember.View} receiver + */ + append: function() { + return this.appendTo(document.body); + }, + + /** + Removes the view's element from the element to which it is attached. + + @method remove + @return {Ember.View} receiver + */ + remove: function() { + // What we should really do here is wait until the end of the run loop + // to determine if the element has been re-appended to a different + // element. + // In the interim, we will just re-render if that happens. It is more + // important than elements get garbage collected. + if (!this.removedFromDOM) { this.destroyElement(); } + this.invokeRecursively(function(view) { + if (view.clearRenderedChildren) { view.clearRenderedChildren(); } + }); + }, + + elementId: null, + + /** + Attempts to discover the element in the parent element. The default + implementation looks for an element with an ID of `elementId` (or the + view's guid if `elementId` is null). You can override this method to + provide your own form of lookup. For example, if you want to discover your + element using a CSS class name instead of an ID. + + @method findElementInParentElement + @param {DOMElement} parentElement The parent's DOM element + @return {DOMElement} The discovered element + */ + findElementInParentElement: function(parentElem) { + var id = "#" + this.elementId; + return jQuery(id)[0] || jQuery(id, parentElem)[0]; + }, + + /** + Creates a DOM representation of the view and all of its + child views by recursively calling the `render()` method. + + After the element has been created, `didInsertElement` will + be called on this view and all of its child views. + + @method createElement + @return {Ember.View} receiver + */ + createElement: function() { + if (get(this, 'element')) { return this; } + + var buffer = this.renderToBuffer(); + set(this, 'element', buffer.element()); + + return this; + }, + + /** + Called when a view is going to insert an element into the DOM. + + @event willInsertElement + */ + willInsertElement: Ember.K, + + /** + Called when the element of the view has been inserted into the DOM + or after the view was re-rendered. Override this function to do any + set up that requires an element in the document body. + + @event didInsertElement + */ + didInsertElement: Ember.K, + + /** + Called when the view is about to rerender, but before anything has + been torn down. This is a good opportunity to tear down any manual + observers you have installed based on the DOM state + + @event willClearRender + */ + willClearRender: Ember.K, + + /** + Run this callback on the current view (unless includeSelf is false) and recursively on child views. + + @method invokeRecursively + @param fn {Function} + @param includeSelf {Boolean} Includes itself if true. + @private + */ + invokeRecursively: function(fn, includeSelf) { + var childViews = (includeSelf === false) ? this._childViews : [this]; + var currentViews, view, currentChildViews; + + while (childViews.length) { + currentViews = childViews.slice(); + childViews = []; + + for (var i=0, l=currentViews.length; i` tag for views. + + @property tagName + @type String + @default null + */ + + // We leave this null by default so we can tell the difference between + // the default case and a user-specified tag. + tagName: null, + + /** + The WAI-ARIA role of the control represented by this view. For example, a + button may have a role of type 'button', or a pane may have a role of + type 'alertdialog'. This property is used by assistive software to help + visually challenged users navigate rich web applications. + + The full list of valid WAI-ARIA roles is available at: + [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) + + @property ariaRole + @type String + @default null + */ + ariaRole: null, + + /** + Standard CSS class names to apply to the view's outer element. This + property automatically inherits any class names defined by the view's + superclasses as well. + + @property classNames + @type Array + @default ['ember-view'] + */ + classNames: ['ember-view'], + + /** + A list of properties of the view to apply as class names. If the property + is a string value, the value of that string will be applied as a class + name. + + ```javascript + // Applies the 'high' class to the view element + Ember.View.extend({ + classNameBindings: ['priority'] + priority: 'high' + }); + ``` + + If the value of the property is a Boolean, the name of that property is + added as a dasherized class name. + + ```javascript + // Applies the 'is-urgent' class to the view element + Ember.View.extend({ + classNameBindings: ['isUrgent'] + isUrgent: true + }); + ``` + + If you would prefer to use a custom value instead of the dasherized + property name, you can pass a binding like this: + + ```javascript + // Applies the 'urgent' class to the view element + Ember.View.extend({ + classNameBindings: ['isUrgent:urgent'] + isUrgent: true + }); + ``` + + This list of properties is inherited from the view's superclasses as well. + + @property classNameBindings + @type Array + @default [] + */ + classNameBindings: EMPTY_ARRAY, + + /** + A list of properties of the view to apply as attributes. If the property is + a string value, the value of that string will be applied as the attribute. + + ```javascript + // Applies the type attribute to the element + // with the value "button", like
    + Ember.View.extend({ + attributeBindings: ['type'], + type: 'button' + }); + ``` + + If the value of the property is a Boolean, the name of that property is + added as an attribute. + + ```javascript + // Renders something like
    + Ember.View.extend({ + attributeBindings: ['enabled'], + enabled: true + }); + ``` + + @property attributeBindings + */ + attributeBindings: EMPTY_ARRAY, + + // ....................................................... + // CORE DISPLAY METHODS + // + + /** + Setup a view, but do not finish waking it up. + + * configure `childViews` + * register the view with the global views hash, which is used for event + dispatch + + @method init + @private + */ + init: function() { + this.elementId = this.elementId || guidFor(this); + + this._super(); + + // setup child views. be sure to clone the child views array first + this._childViews = this._childViews.slice(); + + this.classNameBindings = emberA(this.classNameBindings.slice()); + + this.classNames = emberA(this.classNames.slice()); + }, + + appendChild: function(view, options) { + return this.currentState.appendChild(this, view, options); + }, + + /** + Removes the child view from the parent view. + + @method removeChild + @param {Ember.View} view + @return {Ember.View} receiver + */ + removeChild: function(view) { + // If we're destroying, the entire subtree will be + // freed, and the DOM will be handled separately, + // so no need to mess with childViews. + if (this.isDestroying) { return; } + + // update parent node + set(view, '_parentView', null); + + // remove view from childViews array. + var childViews = this._childViews; + + removeObject(childViews, view); + + this.propertyDidChange('childViews'); // HUH?! what happened to will change? + + return this; + }, + + /** + Removes all children from the `parentView`. + + @method removeAllChildren + @return {Ember.View} receiver + */ + removeAllChildren: function() { + return this.mutateChildViews(function(parentView, view) { + parentView.removeChild(view); + }); + }, + + destroyAllChildren: function() { + return this.mutateChildViews(function(parentView, view) { + view.destroy(); + }); + }, + + /** + Removes the view from its `parentView`, if one is found. Otherwise + does nothing. + + @method removeFromParent + @return {Ember.View} receiver + */ + removeFromParent: function() { + var parent = this._parentView; + + // Remove DOM element from parent + this.remove(); + + if (parent) { parent.removeChild(this); } + return this; + }, + + /** + You must call `destroy` on a view to destroy the view (and all of its + child views). This will remove the view from any parent node, then make + sure that the DOM element managed by the view can be released by the + memory manager. + + @method destroy + */ + destroy: function() { + var childViews = this._childViews, + // get parentView before calling super because it'll be destroyed + nonVirtualParentView = get(this, 'parentView'), + viewName = this.viewName, + childLen, i; + + if (!this._super()) { return; } + + childLen = childViews.length; + for (i=childLen-1; i>=0; i--) { + childViews[i].removedFromDOM = true; + } + + // remove from non-virtual parent view if viewName was specified + if (viewName && nonVirtualParentView) { + nonVirtualParentView.set(viewName, null); + } + + childLen = childViews.length; + for (i=childLen-1; i>=0; i--) { + childViews[i].destroy(); + } + + return this; + }, + + /** + Instantiates a view to be added to the childViews array during view + initialization. You generally will not call this method directly unless + you are overriding `createChildViews()`. Note that this method will + automatically configure the correct settings on the new view instance to + act as a child of the parent. + + @method createChildView + @param {Class|String} viewClass + @param {Hash} [attrs] Attributes to add + @return {Ember.View} new instance + */ + createChildView: function(view, attrs) { + if (!view) { + throw new TypeError("createChildViews first argument must exist"); + } + + if (view.isView && view._parentView === this && view.container === this.container) { + return view; + } + + attrs = attrs || {}; + attrs._parentView = this; + + if (CoreView.detect(view)) { + attrs.templateData = attrs.templateData || get(this, 'templateData'); + + attrs.container = this.container; + view = view.create(attrs); + + // don't set the property on a virtual view, as they are invisible to + // consumers of the view API + if (view.viewName) { + set(get(this, 'concreteView'), view.viewName, view); + } + } else if ('string' === typeof view) { + var fullName = 'view:' + view; + var ViewKlass = this.container.lookupFactory(fullName); + + + attrs.templateData = get(this, 'templateData'); + view = ViewKlass.create(attrs); + } else { + attrs.container = this.container; + + if (!get(view, 'templateData')) { + attrs.templateData = get(this, 'templateData'); + } + + setProperties(view, attrs); + + } + + return view; + }, + + becameVisible: Ember.K, + becameHidden: Ember.K, + + /** + When the view's `isVisible` property changes, toggle the visibility + element of the actual DOM element. + + @method _isVisibleDidChange + @private + */ + _isVisibleDidChange: observer('isVisible', function() { + if (this._isVisible === get(this, 'isVisible')) { return ; } + run.scheduleOnce('render', this, this._toggleVisibility); + }), + + _toggleVisibility: function() { + var $el = this.$(); + if (!$el) { return; } + + var isVisible = get(this, 'isVisible'); + + if (this._isVisible === isVisible) { return ; } + + $el.toggle(isVisible); + + this._isVisible = isVisible; + + if (this._isAncestorHidden()) { return; } + + if (isVisible) { + this._notifyBecameVisible(); + } else { + this._notifyBecameHidden(); + } + }, + + _notifyBecameVisible: function() { + this.trigger('becameVisible'); + + this.forEachChildView(function(view) { + var isVisible = get(view, 'isVisible'); + + if (isVisible || isVisible === null) { + view._notifyBecameVisible(); + } + }); + }, + + _notifyBecameHidden: function() { + this.trigger('becameHidden'); + this.forEachChildView(function(view) { + var isVisible = get(view, 'isVisible'); + + if (isVisible || isVisible === null) { + view._notifyBecameHidden(); + } + }); + }, + + _isAncestorHidden: function() { + var parent = get(this, 'parentView'); + + while (parent) { + if (get(parent, 'isVisible') === false) { return true; } + + parent = get(parent, 'parentView'); + } + + return false; + }, + + clearBuffer: function() { + this.invokeRecursively(nullViewsBuffer); + }, + transitionTo: function(state, children) { + this._transitionTo(state, children); + }, + _transitionTo: function(state, children) { + var priorState = this.currentState; + var currentState = this.currentState = this._states[state]; + + this._state = state; + + if (priorState && priorState.exit) { priorState.exit(this); } + if (currentState.enter) { currentState.enter(this); } + if (state === 'inDOM') { meta(this).cache.element = undefined; } + + if (children !== false) { + this.forEachChildView(function(view) { + view._transitionTo(state); + }); + } + }, + + // ....................................................... + // EVENT HANDLING + // + + /** + Handle events from `Ember.EventDispatcher` + + @method handleEvent + @param eventName {String} + @param evt {Event} + @private + */ + handleEvent: function(eventName, evt) { + return this.currentState.handleEvent(this, eventName, evt); + }, + + registerObserver: function(root, path, target, observer) { + if (!observer && 'function' === typeof target) { + observer = target; + target = null; + } + + if (!root || typeof root !== 'object') { + return; + } + + var view = this, + stateCheckedObserver = function() { + view.currentState.invokeObserver(this, observer); + }, + scheduledObserver = function() { + run.scheduleOnce('render', this, stateCheckedObserver); + }; + + addObserver(root, path, target, scheduledObserver); + + this.one('willClearRender', function() { + removeObserver(root, path, target, scheduledObserver); + }); + } + + }); + + /* + Describe how the specified actions should behave in the various + states that a view can exist in. Possible states: + + * preRender: when a view is first instantiated, and after its + element was destroyed, it is in the preRender state + * inBuffer: once a view has been rendered, but before it has + been inserted into the DOM, it is in the inBuffer state + * hasElement: the DOM representation of the view is created, + and is ready to be inserted + * inDOM: once a view has been inserted into the DOM it is in + the inDOM state. A view spends the vast majority of its + existence in this state. + * destroyed: once a view has been destroyed (using the destroy + method), it is in this state. No further actions can be invoked + on a destroyed view. + */ + + // in the destroyed state, everything is illegal + + // before rendering has begun, all legal manipulations are noops. + + // inside the buffer, legal manipulations are done on the buffer + + // once the view has been inserted into the DOM, legal manipulations + // are done on the DOM element. + + function notifyMutationListeners() { + run.once(View, 'notifyMutationListeners'); + } + + var DOMManager = { + prepend: function(view, html) { + view.$().prepend(html); + notifyMutationListeners(); + }, + + after: function(view, html) { + view.$().after(html); + notifyMutationListeners(); + }, + + html: function(view, html) { + view.$().html(html); + notifyMutationListeners(); + }, + + replace: function(view) { + var element = get(view, 'element'); + + set(view, 'element', null); + + view._insertElementLater(function() { + jQuery(element).replaceWith(get(view, 'element')); + notifyMutationListeners(); + }); + }, + + remove: function(view) { + view.$().remove(); + notifyMutationListeners(); + }, + + empty: function(view) { + view.$().empty(); + notifyMutationListeners(); + } + }; + + View.reopen({ + domManager: DOMManager + }); + + View.reopenClass({ + + /** + Parse a path and return an object which holds the parsed properties. + + For example a path like "content.isEnabled:enabled:disabled" will return the + following object: + + ```javascript + { + path: "content.isEnabled", + className: "enabled", + falsyClassName: "disabled", + classNames: ":enabled:disabled" + } + ``` + + @method _parsePropertyPath + @static + @private + */ + _parsePropertyPath: function(path) { + var split = path.split(':'), + propertyPath = split[0], + classNames = "", + className, + falsyClassName; + + // check if the property is defined as prop:class or prop:trueClass:falseClass + if (split.length > 1) { + className = split[1]; + if (split.length === 3) { falsyClassName = split[2]; } + + classNames = ':' + className; + if (falsyClassName) { classNames += ":" + falsyClassName; } + } + + return { + path: propertyPath, + classNames: classNames, + className: (className === '') ? undefined : className, + falsyClassName: falsyClassName + }; + }, + + /** + Get the class name for a given value, based on the path, optional + `className` and optional `falsyClassName`. + + - if a `className` or `falsyClassName` has been specified: + - if the value is truthy and `className` has been specified, + `className` is returned + - if the value is falsy and `falsyClassName` has been specified, + `falsyClassName` is returned + - otherwise `null` is returned + - if the value is `true`, the dasherized last part of the supplied path + is returned + - if the value is not `false`, `undefined` or `null`, the `value` + is returned + - if none of the above rules apply, `null` is returned + + @method _classStringForValue + @param path + @param val + @param className + @param falsyClassName + @static + @private + */ + _classStringForValue: function(path, val, className, falsyClassName) { + if(isArray(val)) { + val = get(val, 'length') !== 0; + } + + // When using the colon syntax, evaluate the truthiness or falsiness + // of the value to determine which className to return + if (className || falsyClassName) { + if (className && !!val) { + return className; + + } else if (falsyClassName && !val) { + return falsyClassName; + + } else { + return null; + } + + // If value is a Boolean and true, return the dasherized property + // name. + } else if (val === true) { + // Normalize property path to be suitable for use + // as a class name. For exaple, content.foo.barBaz + // becomes bar-baz. + var parts = path.split('.'); + return dasherize(parts[parts.length-1]); + + // If the value is not false, undefined, or null, return the current + // value of the property. + } else if (val !== false && val != null) { + return val; + + // Nothing to display. Return null so that the old class is removed + // but no new class is added. + } else { + return null; + } + } + }); + + var mutation = EmberObject.extend(Evented).create(); + + View.addMutationListener = function(callback) { + mutation.on('change', callback); + }; + + View.removeMutationListener = function(callback) { + mutation.off('change', callback); + }; + + View.notifyMutationListeners = function() { + mutation.trigger('change'); + }; + + /** + Global views hash + + @property views + @static + @type Hash + */ + View.views = {}; + + // If someone overrides the child views computed property when + // defining their class, we want to be able to process the user's + // supplied childViews and then restore the original computed property + // at view initialization time. This happens in Ember.ContainerView's init + // method. + View.childViewsProperty = childViewsProperty; + + View.applyAttributeBindings = function(elem, name, value) { + var type = typeOf(value); + + // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js + if (name !== 'value' && (type === 'string' || (type === 'number' && !isNaN(value)))) { + if (value !== elem.attr(name)) { + elem.attr(name, value); + } + } else if (name === 'value' || type === 'boolean') { + if (isNone(value) || value === false) { + // `null`, `undefined` or `false` should remove attribute + elem.removeAttr(name); + // In IE8 `prop` couldn't remove attribute when name is `required`. + if (name === 'required') { + elem.removeProp(name); + } else { + elem.prop(name, ''); + } + } else if (value !== elem.prop(name)) { + // value should always be properties + elem.prop(name, value); + } + } else if (!value) { + elem.removeAttr(name); + } + }; + + __exports__["default"] = View; + }); +define("ember-views/views/view_collection", + ["ember-metal/enumerable_utils","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var forEach = __dependency1__.forEach; + + function ViewCollection(initialViews) { + var views = this.views = initialViews || []; + this.length = views.length; + } + + ViewCollection.prototype = { + length: 0, + + trigger: function(eventName) { + var views = this.views, view; + for (var i = 0, l = views.length; i < l; i++) { + view = views[i]; + if (view.trigger) { view.trigger(eventName); } + } + }, + + triggerRecursively: function(eventName) { + var views = this.views; + for (var i = 0, l = views.length; i < l; i++) { + views[i].triggerRecursively(eventName); + } + }, + + invokeRecursively: function(fn) { + var views = this.views, view; + + for (var i = 0, l = views.length; i < l; i++) { + view = views[i]; + fn(view); + } + }, + + transitionTo: function(state, children) { + var views = this.views; + for (var i = 0, l = views.length; i < l; i++) { + views[i]._transitionTo(state, children); + } + }, + + push: function() { + this.length += arguments.length; + var views = this.views; + return views.push.apply(views, arguments); + }, + + objectAt: function(idx) { + return this.views[idx]; + }, + + forEach: function(callback) { + var views = this.views; + return forEach(views, callback); + }, + + clear: function() { + this.length = 0; + this.views.length = 0; + } + }; + + __exports__["default"] = ViewCollection; + }); +define("ember", + ["ember-metal","ember-runtime","ember-handlebars","ember-views","ember-routing","ember-routing-handlebars","ember-application","ember-extension-support"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) { + "use strict"; + // require the main entry points for each of these packages + // this is so that the global exports occur properly + + // do this to ensure that Ember.Test is defined properly on the global + // if it is present. + if (Ember.__loader.registry['ember-testing']) { + requireModule('ember-testing'); + } + + /** + Ember + + @module ember + */ + + function throwWithMessage(msg) { + return function() { + throw new Ember.Error(msg); + }; + } + + function generateRemovedClass(className) { + var msg = " has been moved into a plugin: https://github.com/emberjs/ember-states"; + + return { + extend: throwWithMessage(className + msg), + create: throwWithMessage(className + msg) + }; + } + + Ember.StateManager = generateRemovedClass("Ember.StateManager"); + + /** + This was exported to ember-states plugin for v 1.0.0 release. See: https://github.com/emberjs/ember-states + + @class StateManager + @namespace Ember + */ + + Ember.State = generateRemovedClass("Ember.State"); + + /** + This was exported to ember-states plugin for v 1.0.0 release. See: https://github.com/emberjs/ember-states + + @class State + @namespace Ember + */ + }); +define("metamorph", + [], + function() { + "use strict"; + // ========================================================================== + // Project: metamorph + // Copyright: ©2014 Tilde, Inc. All rights reserved. + // ========================================================================== + + var K = function() {}, + guid = 0, + disableRange = (function(){ + if ('undefined' !== typeof MetamorphENV) { + return MetamorphENV.DISABLE_RANGE_API; + } else if ('undefined' !== ENV) { + return ENV.DISABLE_RANGE_API; + } else { + return false; + } + })(), + + // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges + supportsRange = (!disableRange) && typeof document !== 'undefined' && ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, + + // Internet Explorer prior to 9 does not allow setting innerHTML if the first element + // is a "zero-scope" element. This problem can be worked around by making + // the first node an invisible text node. We, like Modernizr, use ­ + needsShy = typeof document !== 'undefined' && (function() { + var testEl = document.createElement('div'); + testEl.innerHTML = "
    "; + testEl.firstChild.innerHTML = ""; + return testEl.firstChild.innerHTML === ''; + })(), + + + // IE 8 (and likely earlier) likes to move whitespace preceeding + // a script tag to appear after it. This means that we can + // accidentally remove whitespace when updating a morph. + movesWhitespace = document && (function() { + var testEl = document.createElement('div'); + testEl.innerHTML = "Test: Value"; + return testEl.childNodes[0].nodeValue === 'Test:' && + testEl.childNodes[2].nodeValue === ' Value'; + })(); + + // Constructor that supports either Metamorph('foo') or new + // Metamorph('foo'); + // + // Takes a string of HTML as the argument. + + var Metamorph = function(html) { + var self; + + if (this instanceof Metamorph) { + self = this; + } else { + self = new K(); + } + + self.innerHTML = html; + var myGuid = 'metamorph-'+(guid++); + self.start = myGuid + '-start'; + self.end = myGuid + '-end'; + + return self; + }; + + K.prototype = Metamorph.prototype; + + var rangeFor, htmlFunc, removeFunc, outerHTMLFunc, appendToFunc, afterFunc, prependFunc, startTagFunc, endTagFunc; + + outerHTMLFunc = function() { + return this.startTag() + this.innerHTML + this.endTag(); + }; + + startTagFunc = function() { + /* + * We replace chevron by its hex code in order to prevent escaping problems. + * Check this thread for more explaination: + * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript + */ + return "hi"; + * div.firstChild.firstChild.tagName //=> "" + * + * If our script markers are inside such a node, we need to find that + * node and use *it* as the marker. + */ + var realNode = function(start) { + while (start.parentNode.tagName === "") { + start = start.parentNode; + } + + return start; + }; + + /* + * When automatically adding a tbody, Internet Explorer inserts the + * tbody immediately before the first . Other browsers create it + * before the first node, no matter what. + * + * This means the the following code: + * + * div = document.createElement("div"); + * div.innerHTML = "
    hi
    + * + * Generates the following DOM in IE: + * + * + div + * + table + * - script id='first' + * + tbody + * + tr + * + td + * - "hi" + * - script id='last' + * + * Which means that the two script tags, even though they were + * inserted at the same point in the hierarchy in the original + * HTML, now have different parents. + * + * This code reparents the first script tag by making it the tbody's + * first child. + * + */ + var fixParentage = function(start, end) { + if (start.parentNode !== end.parentNode) { + end.parentNode.insertBefore(start, end.parentNode.firstChild); + } + }; + + htmlFunc = function(html, outerToo) { + // get the real starting node. see realNode for details. + var start = realNode(document.getElementById(this.start)); + var end = document.getElementById(this.end); + var parentNode = end.parentNode; + var node, nextSibling, last; + + // make sure that the start and end nodes share the same + // parent. If not, fix it. + fixParentage(start, end); + + // remove all of the nodes after the starting placeholder and + // before the ending placeholder. + node = start.nextSibling; + while (node) { + nextSibling = node.nextSibling; + last = node === end; + + // if this is the last node, and we want to remove it as well, + // set the `end` node to the next sibling. This is because + // for the rest of the function, we insert the new nodes + // before the end (note that insertBefore(node, null) is + // the same as appendChild(node)). + // + // if we do not want to remove it, just break. + if (last) { + if (outerToo) { end = node.nextSibling; } else { break; } + } + + node.parentNode.removeChild(node); + + // if this is the last node and we didn't break before + // (because we wanted to remove the outer nodes), break + // now. + if (last) { break; } + + node = nextSibling; + } + + // get the first node for the HTML string, even in cases like + // tables and lists where a simple innerHTML on a div would + // swallow some of the content. + node = firstNodeFor(start.parentNode, html); + + if (outerToo) { + start.parentNode.removeChild(start); + } + + // copy the nodes for the HTML between the starting and ending + // placeholder. + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, end); + node = nextSibling; + } + }; + + // remove the nodes in the DOM representing this metamorph. + // + // this includes the starting and ending placeholders. + removeFunc = function() { + var start = realNode(document.getElementById(this.start)); + var end = document.getElementById(this.end); + + this.html(''); + start.parentNode.removeChild(start); + end.parentNode.removeChild(end); + }; + + appendToFunc = function(parentNode) { + var node = firstNodeFor(parentNode, this.outerHTML()); + var nextSibling; + + while (node) { + nextSibling = node.nextSibling; + parentNode.appendChild(node); + node = nextSibling; + } + }; + + afterFunc = function(html) { + // get the real starting node. see realNode for details. + var end = document.getElementById(this.end); + var insertBefore = end.nextSibling; + var parentNode = end.parentNode; + var nextSibling; + var node; + + // get the first node for the HTML string, even in cases like + // tables and lists where a simple innerHTML on a div would + // swallow some of the content. + node = firstNodeFor(parentNode, html); + + // copy the nodes for the HTML between the starting and ending + // placeholder. + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, insertBefore); + node = nextSibling; + } + }; + + prependFunc = function(html) { + var start = document.getElementById(this.start); + var parentNode = start.parentNode; + var nextSibling; + var node; + + node = firstNodeFor(parentNode, html); + var insertBefore = start.nextSibling; + + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, insertBefore); + node = nextSibling; + } + }; + } + + Metamorph.prototype.html = function(html) { + this.checkRemoved(); + if (html === undefined) { return this.innerHTML; } + + htmlFunc.call(this, html); + + this.innerHTML = html; + }; + + Metamorph.prototype.replaceWith = function(html) { + this.checkRemoved(); + htmlFunc.call(this, html, true); + }; + + Metamorph.prototype.remove = removeFunc; + Metamorph.prototype.outerHTML = outerHTMLFunc; + Metamorph.prototype.appendTo = appendToFunc; + Metamorph.prototype.after = afterFunc; + Metamorph.prototype.prepend = prependFunc; + Metamorph.prototype.startTag = startTagFunc; + Metamorph.prototype.endTag = endTagFunc; + + Metamorph.prototype.isRemoved = function() { + var before = document.getElementById(this.start); + var after = document.getElementById(this.end); + + return !before || !after; + }; + + Metamorph.prototype.checkRemoved = function() { + if (this.isRemoved()) { + throw new Error("Cannot perform operations on a Metamorph that is not in the DOM."); + } + }; + + return Metamorph; + }); + +define("route-recognizer", + ["route-recognizer/dsl","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var map = __dependency1__["default"]; + + var specials = [ + '/', '.', '*', '+', '?', '|', + '(', ')', '[', ']', '{', '}', '\\' + ]; + + var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g'); + + function isArray(test) { + return Object.prototype.toString.call(test) === "[object Array]"; + } + + // A Segment represents a segment in the original route description. + // Each Segment type provides an `eachChar` and `regex` method. + // + // The `eachChar` method invokes the callback with one or more character + // specifications. A character specification consumes one or more input + // characters. + // + // The `regex` method returns a regex fragment for the segment. If the + // segment is a dynamic of star segment, the regex fragment also includes + // a capture. + // + // A character specification contains: + // + // * `validChars`: a String with a list of all valid characters, or + // * `invalidChars`: a String with a list of all invalid characters + // * `repeat`: true if the character specification can repeat + + function StaticSegment(string) { this.string = string; } + StaticSegment.prototype = { + eachChar: function(callback) { + var string = this.string, ch; + + for (var i=0, l=string.length; i " + n.nextStates.map(function(s) { return s.debug() }).join(" or ") + " )"; + }).join(", ") + } + END IF **/ + + // This is a somewhat naive strategy, but should work in a lot of cases + // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id. + // + // This strategy generally prefers more static and less dynamic matching. + // Specifically, it + // + // * prefers fewer stars to more, then + // * prefers using stars for less of the match to more, then + // * prefers fewer dynamic segments to more, then + // * prefers more static segments to more + function sortSolutions(states) { + return states.sort(function(a, b) { + if (a.types.stars !== b.types.stars) { return a.types.stars - b.types.stars; } + + if (a.types.stars) { + if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; } + if (a.types.dynamics !== b.types.dynamics) { return b.types.dynamics - a.types.dynamics; } + } + + if (a.types.dynamics !== b.types.dynamics) { return a.types.dynamics - b.types.dynamics; } + if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; } + + return 0; + }); + } + + function recognizeChar(states, ch) { + var nextStates = []; + + for (var i=0, l=states.length; i 2 && key.slice(keyLength -2) === '[]') { + isArray = true; + key = key.slice(0, keyLength - 2); + if(!queryParams[key]) { + queryParams[key] = []; + } + } + value = pair[1] ? decodeURIComponent(pair[1]) : ''; + } + if (isArray) { + queryParams[key].push(value); + } else { + queryParams[key] = value; + } + } + return queryParams; + }, + + recognize: function(path) { + var states = [ this.rootState ], + pathLen, i, l, queryStart, queryParams = {}, + isSlashDropped = false; + + queryStart = path.indexOf('?'); + if (queryStart !== -1) { + var queryString = path.substr(queryStart + 1, path.length); + path = path.substr(0, queryStart); + queryParams = this.parseQueryString(queryString); + } + + path = decodeURI(path); + + // DEBUG GROUP path + + if (path.charAt(0) !== "/") { path = "/" + path; } + + pathLen = path.length; + if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { + path = path.substr(0, pathLen - 1); + isSlashDropped = true; + } + + for (i=0, l=path.length; i= 0 && proceed; --i) { + var route = routes[i]; + recognizer.add(routes, { as: route.handler }); + proceed = route.path === '/' || route.path === '' || route.handler.slice(-6) === '.index'; + } + }); + }, + + hasRoute: function(route) { + return this.recognizer.hasRoute(route); + }, + + queryParamsTransition: function(changelist, wasTransitioning, oldState, newState) { + var router = this; + + fireQueryParamDidChange(this, newState, changelist); + + if (!wasTransitioning && this.activeTransition) { + // One of the handlers in queryParamsDidChange + // caused a transition. Just return that transition. + return this.activeTransition; + } else { + // Running queryParamsDidChange didn't change anything. + // Just update query params and be on our way. + + // We have to return a noop transition that will + // perform a URL update at the end. This gives + // the user the ability to set the url update + // method (default is replaceState). + var newTransition = new Transition(this); + newTransition.queryParamsOnly = true; + + oldState.queryParams = finalizeQueryParamChange(this, newState.handlerInfos, newState.queryParams, newTransition); + + newTransition.promise = newTransition.promise.then(function(result) { + updateURL(newTransition, oldState, true); + if (router.didTransition) { + router.didTransition(router.currentHandlerInfos); + } + return result; + }, null, promiseLabel("Transition complete")); + return newTransition; + } + }, + + // NOTE: this doesn't really belong here, but here + // it shall remain until our ES6 transpiler can + // handle cyclical deps. + transitionByIntent: function(intent, isIntermediate) { + + var wasTransitioning = !!this.activeTransition; + var oldState = wasTransitioning ? this.activeTransition.state : this.state; + var newTransition; + var router = this; + + try { + var newState = intent.applyToState(oldState, this.recognizer, this.getHandler, isIntermediate); + var queryParamChangelist = getChangelist(oldState.queryParams, newState.queryParams); + + if (handlerInfosEqual(newState.handlerInfos, oldState.handlerInfos)) { + + // This is a no-op transition. See if query params changed. + if (queryParamChangelist) { + newTransition = this.queryParamsTransition(queryParamChangelist, wasTransitioning, oldState, newState); + if (newTransition) { + return newTransition; + } + } + + // No-op. No need to create a new transition. + return new Transition(this); + } + + if (isIntermediate) { + setupContexts(this, newState); + return; + } + + // Create a new transition to the destination route. + newTransition = new Transition(this, intent, newState); + + // Abort and usurp any previously active transition. + if (this.activeTransition) { + this.activeTransition.abort(); + } + this.activeTransition = newTransition; + + // Transition promises by default resolve with resolved state. + // For our purposes, swap out the promise to resolve + // after the transition has been finalized. + newTransition.promise = newTransition.promise.then(function(result) { + return finalizeTransition(newTransition, result.state); + }, null, promiseLabel("Settle transition promise when transition is finalized")); + + if (!wasTransitioning) { + notifyExistingHandlers(this, newState, newTransition); + } + + fireQueryParamDidChange(this, newState, queryParamChangelist); + + return newTransition; + } catch(e) { + return new Transition(this, intent, null, e); + } + }, + + /** + Clears the current and target route handlers and triggers exit + on each of them starting at the leaf and traversing up through + its ancestors. + */ + reset: function() { + if (this.state) { + forEach(this.state.handlerInfos.slice().reverse(), function(handlerInfo) { + var handler = handlerInfo.handler; + callHook(handler, 'exit'); + }); + } + + this.state = new TransitionState(); + this.currentHandlerInfos = null; + }, + + activeTransition: null, + + /** + var handler = handlerInfo.handler; + The entry point for handling a change to the URL (usually + via the back and forward button). + + Returns an Array of handlers and the parameters associated + with those parameters. + + @param {String} url a URL to process + + @return {Array} an Array of `[handler, parameter]` tuples + */ + handleURL: function(url) { + // Perform a URL-based transition, but don't change + // the URL afterward, since it already happened. + var args = slice.call(arguments); + if (url.charAt(0) !== '/') { args[0] = '/' + url; } + + return doTransition(this, args).method(null); + }, + + /** + Hook point for updating the URL. + + @param {String} url a URL to update to + */ + updateURL: function() { + throw new Error("updateURL is not implemented"); + }, + + /** + Hook point for replacing the current URL, i.e. with replaceState + + By default this behaves the same as `updateURL` + + @param {String} url a URL to update to + */ + replaceURL: function(url) { + this.updateURL(url); + }, + + /** + Transition into the specified named route. + + If necessary, trigger the exit callback on any handlers + that are no longer represented by the target route. + + @param {String} name the name of the route + */ + transitionTo: function(name) { + return doTransition(this, arguments); + }, + + intermediateTransitionTo: function(name) { + return doTransition(this, arguments, true); + }, + + refresh: function(pivotHandler) { + var state = this.activeTransition ? this.activeTransition.state : this.state; + var handlerInfos = state.handlerInfos; + var params = {}; + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + var handlerInfo = handlerInfos[i]; + params[handlerInfo.name] = handlerInfo.params || {}; + } + + log(this, "Starting a refresh transition"); + var intent = new NamedTransitionIntent({ + name: handlerInfos[handlerInfos.length - 1].name, + pivotHandler: pivotHandler || handlerInfos[0].handler, + contexts: [], // TODO collect contexts...? + queryParams: this._changedQueryParams || state.queryParams || {} + }); + + return this.transitionByIntent(intent, false); + }, + + /** + Identical to `transitionTo` except that the current URL will be replaced + if possible. + + This method is intended primarily for use with `replaceState`. + + @param {String} name the name of the route + */ + replaceWith: function(name) { + return doTransition(this, arguments).method('replace'); + }, + + /** + Take a named route and context objects and generate a + URL. + + @param {String} name the name of the route to generate + a URL for + @param {...Object} objects a list of objects to serialize + + @return {String} a URL + */ + generate: function(handlerName) { + + var partitionedArgs = extractQueryParams(slice.call(arguments, 1)), + suppliedParams = partitionedArgs[0], + queryParams = partitionedArgs[1]; + + // Construct a TransitionIntent with the provided params + // and apply it to the present state of the router. + var intent = new NamedTransitionIntent({ name: handlerName, contexts: suppliedParams }); + var state = intent.applyToState(this.state, this.recognizer, this.getHandler); + var params = {}; + + for (var i = 0, len = state.handlerInfos.length; i < len; ++i) { + var handlerInfo = state.handlerInfos[i]; + var handlerParams = handlerInfo.serialize(); + merge(params, handlerParams); + } + params.queryParams = queryParams; + + return this.recognizer.generate(handlerName, params); + }, + + applyIntent: function(handlerName, contexts) { + var intent = new NamedTransitionIntent({ + name: handlerName, + contexts: contexts + }); + + var state = this.activeTransition && this.activeTransition.state || this.state; + return intent.applyToState(state, this.recognizer, this.getHandler); + }, + + isActiveIntent: function(handlerName, contexts, queryParams) { + var targetHandlerInfos = this.state.handlerInfos, + found = false, names, object, handlerInfo, handlerObj, i, len; + + if (!targetHandlerInfos.length) { return false; } + + var targetHandler = targetHandlerInfos[targetHandlerInfos.length - 1].name; + var recogHandlers = this.recognizer.handlersFor(targetHandler); + + var index = 0; + for (len = recogHandlers.length; index < len; ++index) { + handlerInfo = targetHandlerInfos[index]; + if (handlerInfo.name === handlerName) { break; } + } + + if (index === recogHandlers.length) { + // The provided route name isn't even in the route hierarchy. + return false; + } + + var state = new TransitionState(); + state.handlerInfos = targetHandlerInfos.slice(0, index + 1); + recogHandlers = recogHandlers.slice(0, index + 1); + + var intent = new NamedTransitionIntent({ + name: targetHandler, + contexts: contexts + }); + + var newState = intent.applyToHandlers(state, recogHandlers, this.getHandler, targetHandler, true, true); + + var handlersEqual = handlerInfosEqual(newState.handlerInfos, state.handlerInfos); + if (!queryParams || !handlersEqual) { + return handlersEqual; + } + + // Get a hash of QPs that will still be active on new route + var activeQPsOnNewHandler = {}; + merge(activeQPsOnNewHandler, queryParams); + + var activeQueryParams = this.state.queryParams; + for (var key in activeQueryParams) { + if (activeQueryParams.hasOwnProperty(key) && + activeQPsOnNewHandler.hasOwnProperty(key)) { + activeQPsOnNewHandler[key] = activeQueryParams[key]; + } + } + + return handlersEqual && !getChangelist(activeQPsOnNewHandler, queryParams); + }, + + isActive: function(handlerName) { + var partitionedArgs = extractQueryParams(slice.call(arguments, 1)); + return this.isActiveIntent(handlerName, partitionedArgs[0], partitionedArgs[1]); + }, + + trigger: function(name) { + var args = slice.call(arguments); + trigger(this, this.currentHandlerInfos, false, args); + }, + + /** + Hook point for logging transition status updates. + + @param {String} message The message to log. + */ + log: null, + + _willChangeContextEvent: 'willChangeContext', + _triggerWillChangeContext: function(handlerInfos, newTransition) { + trigger(this, handlerInfos, true, [this._willChangeContextEvent, newTransition]); + }, + + _triggerWillLeave: function(handlerInfos, newTransition, leavingChecker) { + trigger(this, handlerInfos, true, ['willLeave', newTransition, leavingChecker]); + } + }; + + /** + @private + + Fires queryParamsDidChange event + */ + function fireQueryParamDidChange(router, newState, queryParamChangelist) { + // If queryParams changed trigger event + if (queryParamChangelist) { + + // This is a little hacky but we need some way of storing + // changed query params given that no activeTransition + // is guaranteed to have occurred. + router._changedQueryParams = queryParamChangelist.all; + trigger(router, newState.handlerInfos, true, ['queryParamsDidChange', queryParamChangelist.changed, queryParamChangelist.all, queryParamChangelist.removed]); + router._changedQueryParams = null; + } + } + + /** + @private + + Takes an Array of `HandlerInfo`s, figures out which ones are + exiting, entering, or changing contexts, and calls the + proper handler hooks. + + For example, consider the following tree of handlers. Each handler is + followed by the URL segment it handles. + + ``` + |~index ("/") + | |~posts ("/posts") + | | |-showPost ("/:id") + | | |-newPost ("/new") + | | |-editPost ("/edit") + | |~about ("/about/:id") + ``` + + Consider the following transitions: + + 1. A URL transition to `/posts/1`. + 1. Triggers the `*model` callbacks on the + `index`, `posts`, and `showPost` handlers + 2. Triggers the `enter` callback on the same + 3. Triggers the `setup` callback on the same + 2. A direct transition to `newPost` + 1. Triggers the `exit` callback on `showPost` + 2. Triggers the `enter` callback on `newPost` + 3. Triggers the `setup` callback on `newPost` + 3. A direct transition to `about` with a specified + context object + 1. Triggers the `exit` callback on `newPost` + and `posts` + 2. Triggers the `serialize` callback on `about` + 3. Triggers the `enter` callback on `about` + 4. Triggers the `setup` callback on `about` + + @param {Router} transition + @param {TransitionState} newState + */ + function setupContexts(router, newState, transition) { + var partition = partitionHandlers(router.state, newState); + + forEach(partition.exited, function(handlerInfo) { + var handler = handlerInfo.handler; + delete handler.context; + + callHook(handler, 'reset', true, transition); + callHook(handler, 'exit', transition); + }); + + var oldState = router.oldState = router.state; + router.state = newState; + var currentHandlerInfos = router.currentHandlerInfos = partition.unchanged.slice(); + + try { + forEach(partition.reset, function(handlerInfo) { + var handler = handlerInfo.handler; + callHook(handler, 'reset', false, transition); + }); + + forEach(partition.updatedContext, function(handlerInfo) { + return handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, false, transition); + }); + + forEach(partition.entered, function(handlerInfo) { + return handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, true, transition); + }); + } catch(e) { + router.state = oldState; + router.currentHandlerInfos = oldState.handlerInfos; + throw e; + } + + router.state.queryParams = finalizeQueryParamChange(router, currentHandlerInfos, newState.queryParams, transition); + } + + + /** + @private + + Helper method used by setupContexts. Handles errors or redirects + that may happen in enter/setup. + */ + function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transition) { + + var handler = handlerInfo.handler, + context = handlerInfo.context; + + callHook(handler, 'enter', transition); + if (transition && transition.isAborted) { + throw new TransitionAborted(); + } + + handler.context = context; + callHook(handler, 'contextDidChange'); + + callHook(handler, 'setup', context, transition); + if (transition && transition.isAborted) { + throw new TransitionAborted(); + } + + currentHandlerInfos.push(handlerInfo); + + return true; + } + + + /** + @private + + This function is called when transitioning from one URL to + another to determine which handlers are no longer active, + which handlers are newly active, and which handlers remain + active but have their context changed. + + Take a list of old handlers and new handlers and partition + them into four buckets: + + * unchanged: the handler was active in both the old and + new URL, and its context remains the same + * updated context: the handler was active in both the + old and new URL, but its context changed. The handler's + `setup` method, if any, will be called with the new + context. + * exited: the handler was active in the old URL, but is + no longer active. + * entered: the handler was not active in the old URL, but + is now active. + + The PartitionedHandlers structure has four fields: + + * `updatedContext`: a list of `HandlerInfo` objects that + represent handlers that remain active but have a changed + context + * `entered`: a list of `HandlerInfo` objects that represent + handlers that are newly active + * `exited`: a list of `HandlerInfo` objects that are no + longer active. + * `unchanged`: a list of `HanderInfo` objects that remain active. + + @param {Array[HandlerInfo]} oldHandlers a list of the handler + information for the previous URL (or `[]` if this is the + first handled transition) + @param {Array[HandlerInfo]} newHandlers a list of the handler + information for the new URL + + @return {Partition} + */ + function partitionHandlers(oldState, newState) { + var oldHandlers = oldState.handlerInfos; + var newHandlers = newState.handlerInfos; + + var handlers = { + updatedContext: [], + exited: [], + entered: [], + unchanged: [] + }; + + var handlerChanged, contextChanged = false, i, l; + + for (i=0, l=newHandlers.length; i= 0; --i) { + var handlerInfo = handlerInfos[i]; + merge(params, handlerInfo.params); + if (handlerInfo.handler.inaccessibleByURL) { + urlMethod = null; + } + } + + if (urlMethod) { + params.queryParams = transition._visibleQueryParams || state.queryParams; + var url = router.recognizer.generate(handlerName, params); + + if (urlMethod === 'replace') { + router.replaceURL(url); + } else { + router.updateURL(url); + } + } + } + + /** + @private + + Updates the URL (if necessary) and calls `setupContexts` + to update the router's array of `currentHandlerInfos`. + */ + function finalizeTransition(transition, newState) { + + try { + log(transition.router, transition.sequence, "Resolved all models on destination route; finalizing transition."); + + var router = transition.router, + handlerInfos = newState.handlerInfos, + seq = transition.sequence; + + // Run all the necessary enter/setup/exit hooks + setupContexts(router, newState, transition); + + // Check if a redirect occurred in enter/setup + if (transition.isAborted) { + // TODO: cleaner way? distinguish b/w targetHandlerInfos? + router.state.handlerInfos = router.currentHandlerInfos; + return Promise.reject(logAbort(transition)); + } + + updateURL(transition, newState, transition.intent.url); + + transition.isActive = false; + router.activeTransition = null; + + trigger(router, router.currentHandlerInfos, true, ['didTransition']); + + if (router.didTransition) { + router.didTransition(router.currentHandlerInfos); + } + + log(router, transition.sequence, "TRANSITION COMPLETE."); + + // Resolve with the final handler. + return handlerInfos[handlerInfos.length - 1].handler; + } catch(e) { + if (!((e instanceof TransitionAborted))) { + //var erroneousHandler = handlerInfos.pop(); + var infos = transition.state.handlerInfos; + transition.trigger(true, 'error', e, transition, infos[infos.length-1].handler); + transition.abort(); + } + + throw e; + } + } + + /** + @private + + Begins and returns a Transition based on the provided + arguments. Accepts arguments in the form of both URL + transitions and named transitions. + + @param {Router} router + @param {Array[Object]} args arguments passed to transitionTo, + replaceWith, or handleURL + */ + function doTransition(router, args, isIntermediate) { + // Normalize blank transitions to root URL transitions. + var name = args[0] || '/'; + + var lastArg = args[args.length-1]; + var queryParams = {}; + if (lastArg && lastArg.hasOwnProperty('queryParams')) { + queryParams = pop.call(args).queryParams; + } + + var intent; + if (args.length === 0) { + + log(router, "Updating query params"); + + // A query param update is really just a transition + // into the route you're already on. + var handlerInfos = router.state.handlerInfos; + intent = new NamedTransitionIntent({ + name: handlerInfos[handlerInfos.length - 1].name, + contexts: [], + queryParams: queryParams + }); + + } else if (name.charAt(0) === '/') { + + log(router, "Attempting URL transition to " + name); + intent = new URLTransitionIntent({ url: name }); + + } else { + + log(router, "Attempting transition to " + name); + intent = new NamedTransitionIntent({ + name: args[0], + contexts: slice.call(args, 1), + queryParams: queryParams + }); + } + + return router.transitionByIntent(intent, isIntermediate); + } + + function handlerInfosEqual(handlerInfos, otherHandlerInfos) { + if (handlerInfos.length !== otherHandlerInfos.length) { + return false; + } + + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + if (handlerInfos[i] !== otherHandlerInfos[i]) { + return false; + } + } + return true; + } + + function finalizeQueryParamChange(router, resolvedHandlers, newQueryParams, transition) { + // We fire a finalizeQueryParamChange event which + // gives the new route hierarchy a chance to tell + // us which query params it's consuming and what + // their final values are. If a query param is + // no longer consumed in the final route hierarchy, + // its serialized segment will be removed + // from the URL. + + for (var k in newQueryParams) { + if (newQueryParams.hasOwnProperty(k) && + newQueryParams[k] === null) { + delete newQueryParams[k]; + } + } + + var finalQueryParamsArray = []; + trigger(router, resolvedHandlers, true, ['finalizeQueryParamChange', newQueryParams, finalQueryParamsArray, transition]); + + if (transition) { + transition._visibleQueryParams = {}; + } + + var finalQueryParams = {}; + for (var i = 0, len = finalQueryParamsArray.length; i < len; ++i) { + var qp = finalQueryParamsArray[i]; + finalQueryParams[qp.key] = qp.value; + if (transition && qp.visible !== false) { + transition._visibleQueryParams[qp.key] = qp.value; + } + } + return finalQueryParams; + } + + function notifyExistingHandlers(router, newState, newTransition) { + var oldHandlers = router.state.handlerInfos, + changing = [], + leavingIndex = null, + leaving, leavingChecker, i, oldHandlerLen, oldHandler, newHandler; + + oldHandlerLen = oldHandlers.length; + for (i = 0; i < oldHandlerLen; i++) { + oldHandler = oldHandlers[i]; + newHandler = newState.handlerInfos[i]; + + if (!newHandler || oldHandler.name !== newHandler.name) { + leavingIndex = i; + break; + } + + if (!newHandler.isResolved) { + changing.push(oldHandler); + } + } + + if (leavingIndex !== null) { + leaving = oldHandlers.slice(leavingIndex, oldHandlerLen); + leavingChecker = function(name) { + for (var h = 0, len = leaving.length; h < len; h++) { + if (leaving[h].name === name) { + return true; + } + } + return false; + }; + + router._triggerWillLeave(leaving, newTransition, leavingChecker); + } + + if (changing.length > 0) { + router._triggerWillChangeContext(changing, newTransition); + } + + trigger(router, oldHandlers, true, ['willTransition', newTransition]); + } + + __exports__["default"] = Router; + }); +define("router/transition-intent", + ["./utils","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var merge = __dependency1__.merge; + + function TransitionIntent(props) { + this.initialize(props); + + // TODO: wat + this.data = this.data || {}; + } + + TransitionIntent.prototype = { + initialize: null, + applyToState: null + }; + + __exports__["default"] = TransitionIntent; + }); +define("router/transition-intent/named-transition-intent", + ["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + var TransitionIntent = __dependency1__["default"]; + var TransitionState = __dependency2__["default"]; + var handlerInfoFactory = __dependency3__["default"]; + var isParam = __dependency4__.isParam; + var extractQueryParams = __dependency4__.extractQueryParams; + var merge = __dependency4__.merge; + var subclass = __dependency4__.subclass; + + __exports__["default"] = subclass(TransitionIntent, { + name: null, + pivotHandler: null, + contexts: null, + queryParams: null, + + initialize: function(props) { + this.name = props.name; + this.pivotHandler = props.pivotHandler; + this.contexts = props.contexts || []; + this.queryParams = props.queryParams; + }, + + applyToState: function(oldState, recognizer, getHandler, isIntermediate) { + + var partitionedArgs = extractQueryParams([this.name].concat(this.contexts)), + pureArgs = partitionedArgs[0], + queryParams = partitionedArgs[1], + handlers = recognizer.handlersFor(pureArgs[0]); + + var targetRouteName = handlers[handlers.length-1].handler; + + return this.applyToHandlers(oldState, handlers, getHandler, targetRouteName, isIntermediate); + }, + + applyToHandlers: function(oldState, handlers, getHandler, targetRouteName, isIntermediate, checkingIfActive) { + + var i, len; + var newState = new TransitionState(); + var objects = this.contexts.slice(0); + + var invalidateIndex = handlers.length; + + // Pivot handlers are provided for refresh transitions + if (this.pivotHandler) { + for (i = 0, len = handlers.length; i < len; ++i) { + if (getHandler(handlers[i].handler) === this.pivotHandler) { + invalidateIndex = i; + break; + } + } + } + + var pivotHandlerFound = !this.pivotHandler; + + for (i = handlers.length - 1; i >= 0; --i) { + var result = handlers[i]; + var name = result.handler; + var handler = getHandler(name); + + var oldHandlerInfo = oldState.handlerInfos[i]; + var newHandlerInfo = null; + + if (result.names.length > 0) { + if (i >= invalidateIndex) { + newHandlerInfo = this.createParamHandlerInfo(name, handler, result.names, objects, oldHandlerInfo); + } else { + newHandlerInfo = this.getHandlerInfoForDynamicSegment(name, handler, result.names, objects, oldHandlerInfo, targetRouteName, i); + } + } else { + // This route has no dynamic segment. + // Therefore treat as a param-based handlerInfo + // with empty params. This will cause the `model` + // hook to be called with empty params, which is desirable. + newHandlerInfo = this.createParamHandlerInfo(name, handler, result.names, objects, oldHandlerInfo); + } + + if (checkingIfActive) { + // If we're performing an isActive check, we want to + // serialize URL params with the provided context, but + // ignore mismatches between old and new context. + newHandlerInfo = newHandlerInfo.becomeResolved(null, newHandlerInfo.context); + var oldContext = oldHandlerInfo && oldHandlerInfo.context; + if (result.names.length > 0 && newHandlerInfo.context === oldContext) { + // If contexts match in isActive test, assume params also match. + // This allows for flexibility in not requiring that every last + // handler provide a `serialize` method + newHandlerInfo.params = oldHandlerInfo && oldHandlerInfo.params; + } + newHandlerInfo.context = oldContext; + } + + var handlerToUse = oldHandlerInfo; + if (i >= invalidateIndex || newHandlerInfo.shouldSupercede(oldHandlerInfo)) { + invalidateIndex = Math.min(i, invalidateIndex); + handlerToUse = newHandlerInfo; + } + + if (isIntermediate && !checkingIfActive) { + handlerToUse = handlerToUse.becomeResolved(null, handlerToUse.context); + } + + newState.handlerInfos.unshift(handlerToUse); + } + + if (objects.length > 0) { + throw new Error("More context objects were passed than there are dynamic segments for the route: " + targetRouteName); + } + + if (!isIntermediate) { + this.invalidateChildren(newState.handlerInfos, invalidateIndex); + } + + merge(newState.queryParams, this.queryParams || {}); + + return newState; + }, + + invalidateChildren: function(handlerInfos, invalidateIndex) { + for (var i = invalidateIndex, l = handlerInfos.length; i < l; ++i) { + var handlerInfo = handlerInfos[i]; + handlerInfos[i] = handlerInfos[i].getUnresolved(); + } + }, + + getHandlerInfoForDynamicSegment: function(name, handler, names, objects, oldHandlerInfo, targetRouteName, i) { + + var numNames = names.length; + var objectToUse; + if (objects.length > 0) { + + // Use the objects provided for this transition. + objectToUse = objects[objects.length - 1]; + if (isParam(objectToUse)) { + return this.createParamHandlerInfo(name, handler, names, objects, oldHandlerInfo); + } else { + objects.pop(); + } + } else if (oldHandlerInfo && oldHandlerInfo.name === name) { + // Reuse the matching oldHandlerInfo + return oldHandlerInfo; + } else { + if (this.preTransitionState) { + var preTransitionHandlerInfo = this.preTransitionState.handlerInfos[i]; + objectToUse = preTransitionHandlerInfo && preTransitionHandlerInfo.context; + } else { + // Ideally we should throw this error to provide maximal + // information to the user that not enough context objects + // were provided, but this proves too cumbersome in Ember + // in cases where inner template helpers are evaluated + // before parent helpers un-render, in which cases this + // error somewhat prematurely fires. + //throw new Error("Not enough context objects were provided to complete a transition to " + targetRouteName + ". Specifically, the " + name + " route needs an object that can be serialized into its dynamic URL segments [" + names.join(', ') + "]"); + return oldHandlerInfo; + } + } + + return handlerInfoFactory('object', { + name: name, + handler: handler, + context: objectToUse, + names: names + }); + }, + + createParamHandlerInfo: function(name, handler, names, objects, oldHandlerInfo) { + var params = {}; + + // Soak up all the provided string/numbers + var numNames = names.length; + while (numNames--) { + + // Only use old params if the names match with the new handler + var oldParams = (oldHandlerInfo && name === oldHandlerInfo.name && oldHandlerInfo.params) || {}; + + var peek = objects[objects.length - 1]; + var paramName = names[numNames]; + if (isParam(peek)) { + params[paramName] = "" + objects.pop(); + } else { + // If we're here, this means only some of the params + // were string/number params, so try and use a param + // value from a previous handler. + if (oldParams.hasOwnProperty(paramName)) { + params[paramName] = oldParams[paramName]; + } else { + throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route " + name); + } + } + } + + return handlerInfoFactory('param', { + name: name, + handler: handler, + params: params + }); + } + }); + }); +define("router/transition-intent/url-transition-intent", + ["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + var TransitionIntent = __dependency1__["default"]; + var TransitionState = __dependency2__["default"]; + var handlerInfoFactory = __dependency3__["default"]; + var oCreate = __dependency4__.oCreate; + var merge = __dependency4__.merge; + var subclass = __dependency4__.subclass; + + __exports__["default"] = subclass(TransitionIntent, { + url: null, + + initialize: function(props) { + this.url = props.url; + }, + + applyToState: function(oldState, recognizer, getHandler) { + var newState = new TransitionState(); + + var results = recognizer.recognize(this.url), + queryParams = {}, + i, len; + + if (!results) { + throw new UnrecognizedURLError(this.url); + } + + var statesDiffer = false; + + for (i = 0, len = results.length; i < len; ++i) { + var result = results[i]; + var name = result.handler; + var handler = getHandler(name); + + if (handler.inaccessibleByURL) { + throw new UnrecognizedURLError(this.url); + } + + var newHandlerInfo = handlerInfoFactory('param', { + name: name, + handler: handler, + params: result.params + }); + + var oldHandlerInfo = oldState.handlerInfos[i]; + if (statesDiffer || newHandlerInfo.shouldSupercede(oldHandlerInfo)) { + statesDiffer = true; + newState.handlerInfos[i] = newHandlerInfo; + } else { + newState.handlerInfos[i] = oldHandlerInfo; + } + } + + merge(newState.queryParams, results.queryParams); + + return newState; + } + }); + + /** + Promise reject reasons passed to promise rejection + handlers for failed transitions. + */ + function UnrecognizedURLError(message) { + this.message = (message || "UnrecognizedURLError"); + this.name = "UnrecognizedURLError"; + } + }); +define("router/transition-state", + ["./handler-info","./utils","rsvp/promise","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var ResolvedHandlerInfo = __dependency1__.ResolvedHandlerInfo; + var forEach = __dependency2__.forEach; + var promiseLabel = __dependency2__.promiseLabel; + var callHook = __dependency2__.callHook; + var Promise = __dependency3__["default"]; + + function TransitionState(other) { + this.handlerInfos = []; + this.queryParams = {}; + this.params = {}; + } + + TransitionState.prototype = { + handlerInfos: null, + queryParams: null, + params: null, + + promiseLabel: function(label) { + var targetName = ''; + forEach(this.handlerInfos, function(handlerInfo) { + if (targetName !== '') { + targetName += '.'; + } + targetName += handlerInfo.name; + }); + return promiseLabel("'" + targetName + "': " + label); + }, + + resolve: function(shouldContinue, payload) { + var self = this; + // First, calculate params for this state. This is useful + // information to provide to the various route hooks. + var params = this.params; + forEach(this.handlerInfos, function(handlerInfo) { + params[handlerInfo.name] = handlerInfo.params || {}; + }); + + payload = payload || {}; + payload.resolveIndex = 0; + + var currentState = this; + var wasAborted = false; + + // The prelude RSVP.resolve() asyncs us into the promise land. + return Promise.resolve(null, this.promiseLabel("Start transition")) + .then(resolveOneHandlerInfo, null, this.promiseLabel('Resolve handler'))['catch'](handleError, this.promiseLabel('Handle error')); + + function innerShouldContinue() { + return Promise.resolve(shouldContinue(), currentState.promiseLabel("Check if should continue"))['catch'](function(reason) { + // We distinguish between errors that occurred + // during resolution (e.g. beforeModel/model/afterModel), + // and aborts due to a rejecting promise from shouldContinue(). + wasAborted = true; + return Promise.reject(reason); + }, currentState.promiseLabel("Handle abort")); + } + + function handleError(error) { + // This is the only possible + // reject value of TransitionState#resolve + var handlerInfos = currentState.handlerInfos; + var errorHandlerIndex = payload.resolveIndex >= handlerInfos.length ? + handlerInfos.length - 1 : payload.resolveIndex; + return Promise.reject({ + error: error, + handlerWithError: currentState.handlerInfos[errorHandlerIndex].handler, + wasAborted: wasAborted, + state: currentState + }); + } + + function proceed(resolvedHandlerInfo) { + var wasAlreadyResolved = currentState.handlerInfos[payload.resolveIndex].isResolved; + + // Swap the previously unresolved handlerInfo with + // the resolved handlerInfo + currentState.handlerInfos[payload.resolveIndex++] = resolvedHandlerInfo; + + if (!wasAlreadyResolved) { + // Call the redirect hook. The reason we call it here + // vs. afterModel is so that redirects into child + // routes don't re-run the model hooks for this + // already-resolved route. + var handler = resolvedHandlerInfo.handler; + callHook(handler, 'redirect', resolvedHandlerInfo.context, payload); + } + + // Proceed after ensuring that the redirect hook + // didn't abort this transition by transitioning elsewhere. + return innerShouldContinue().then(resolveOneHandlerInfo, null, currentState.promiseLabel('Resolve handler')); + } + + function resolveOneHandlerInfo() { + if (payload.resolveIndex === currentState.handlerInfos.length) { + // This is is the only possible + // fulfill value of TransitionState#resolve + return { + error: null, + state: currentState + }; + } + + var handlerInfo = currentState.handlerInfos[payload.resolveIndex]; + + return handlerInfo.resolve(innerShouldContinue, payload) + .then(proceed, null, currentState.promiseLabel('Proceed')); + } + } + }; + + __exports__["default"] = TransitionState; + }); +define("router/transition", + ["rsvp/promise","./handler-info","./utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var ResolvedHandlerInfo = __dependency2__.ResolvedHandlerInfo; + var trigger = __dependency3__.trigger; + var slice = __dependency3__.slice; + var log = __dependency3__.log; + var promiseLabel = __dependency3__.promiseLabel; + + /** + @private + + A Transition is a thennable (a promise-like object) that represents + an attempt to transition to another route. It can be aborted, either + explicitly via `abort` or by attempting another transition while a + previous one is still underway. An aborted transition can also + be `retry()`d later. + */ + function Transition(router, intent, state, error) { + var transition = this; + this.state = state || router.state; + this.intent = intent; + this.router = router; + this.data = this.intent && this.intent.data || {}; + this.resolvedModels = {}; + this.queryParams = {}; + + if (error) { + this.promise = Promise.reject(error); + return; + } + + if (state) { + this.params = state.params; + this.queryParams = state.queryParams; + this.handlerInfos = state.handlerInfos; + + var len = state.handlerInfos.length; + if (len) { + this.targetName = state.handlerInfos[len-1].name; + } + + for (var i = 0; i < len; ++i) { + var handlerInfo = state.handlerInfos[i]; + + // TODO: this all seems hacky + if (!handlerInfo.isResolved) { break; } + this.pivotHandler = handlerInfo.handler; + } + + this.sequence = Transition.currentSequence++; + this.promise = state.resolve(checkForAbort, this)['catch'](function(result) { + if (result.wasAborted || transition.isAborted) { + return Promise.reject(logAbort(transition)); + } else { + transition.trigger('error', result.error, transition, result.handlerWithError); + transition.abort(); + return Promise.reject(result.error); + } + }, promiseLabel('Handle Abort')); + } else { + this.promise = Promise.resolve(this.state); + this.params = {}; + } + + function checkForAbort() { + if (transition.isAborted) { + return Promise.reject(undefined, promiseLabel("Transition aborted - reject")); + } + } + } + + Transition.currentSequence = 0; + + Transition.prototype = { + targetName: null, + urlMethod: 'update', + intent: null, + params: null, + pivotHandler: null, + resolveIndex: 0, + handlerInfos: null, + resolvedModels: null, + isActive: true, + state: null, + queryParamsOnly: false, + + isTransition: true, + + isExiting: function(handler) { + var handlerInfos = this.handlerInfos; + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + var handlerInfo = handlerInfos[i]; + if (handlerInfo.name === handler || handlerInfo.handler === handler) { + return false; + } + } + return true; + }, + + /** + @public + + The Transition's internal promise. Calling `.then` on this property + is that same as calling `.then` on the Transition object itself, but + this property is exposed for when you want to pass around a + Transition's promise, but not the Transition object itself, since + Transition object can be externally `abort`ed, while the promise + cannot. + */ + promise: null, + + /** + @public + + Custom state can be stored on a Transition's `data` object. + This can be useful for decorating a Transition within an earlier + hook and shared with a later hook. Properties set on `data` will + be copied to new transitions generated by calling `retry` on this + transition. + */ + data: null, + + /** + @public + + A standard promise hook that resolves if the transition + succeeds and rejects if it fails/redirects/aborts. + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @param {Function} onFulfilled + @param {Function} onRejected + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + then: function(onFulfilled, onRejected, label) { + return this.promise.then(onFulfilled, onRejected, label); + }, + + /** + @public + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + "catch": function(onRejection, label) { + return this.promise["catch"](onRejection, label); + }, + + /** + @public + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + "finally": function(callback, label) { + return this.promise["finally"](callback, label); + }, + + /** + @public + + Aborts the Transition. Note you can also implicitly abort a transition + by initiating another transition while a previous one is underway. + */ + abort: function() { + if (this.isAborted) { return this; } + log(this.router, this.sequence, this.targetName + ": transition was aborted"); + this.intent.preTransitionState = this.router.state; + this.isAborted = true; + this.isActive = false; + this.router.activeTransition = null; + return this; + }, + + /** + @public + + Retries a previously-aborted transition (making sure to abort the + transition if it's still active). Returns a new transition that + represents the new attempt to transition. + */ + retry: function() { + // TODO: add tests for merged state retry()s + this.abort(); + return this.router.transitionByIntent(this.intent, false); + }, + + /** + @public + + Sets the URL-changing method to be employed at the end of a + successful transition. By default, a new Transition will just + use `updateURL`, but passing 'replace' to this method will + cause the URL to update using 'replaceWith' instead. Omitting + a parameter will disable the URL change, allowing for transitions + that don't update the URL at completion (this is also used for + handleURL, since the URL has already changed before the + transition took place). + + @param {String} method the type of URL-changing method to use + at the end of a transition. Accepted values are 'replace', + falsy values, or any other non-falsy value (which is + interpreted as an updateURL transition). + + @return {Transition} this transition + */ + method: function(method) { + this.urlMethod = method; + return this; + }, + + /** + @public + + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @param {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled events throw an error + @param {String} name the name of the event to fire + */ + trigger: function (ignoreFailure) { + var args = slice.call(arguments); + if (typeof ignoreFailure === 'boolean') { + args.shift(); + } else { + // Throw errors on unhandled trigger events by default + ignoreFailure = false; + } + trigger(this.router, this.state.handlerInfos.slice(0, this.resolveIndex + 1), ignoreFailure, args); + }, + + /** + @public + + Transitions are aborted and their promises rejected + when redirects occur; this method returns a promise + that will follow any redirects that occur and fulfill + with the value fulfilled by any redirecting transitions + that occur. + + @return {Promise} a promise that fulfills with the same + value that the final redirecting transition fulfills with + */ + followRedirects: function() { + var router = this.router; + return this.promise['catch'](function(reason) { + if (router.activeTransition) { + return router.activeTransition.followRedirects(); + } + return Promise.reject(reason); + }); + }, + + toString: function() { + return "Transition (sequence " + this.sequence + ")"; + }, + + /** + @private + */ + log: function(message) { + log(this.router, this.sequence, message); + } + }; + + // Alias 'trigger' as 'send' + Transition.prototype.send = Transition.prototype.trigger; + + /** + @private + + Logs and returns a TransitionAborted error. + */ + function logAbort(transition) { + log(transition.router, transition.sequence, "detected abort."); + return new TransitionAborted(); + } + + function TransitionAborted(message) { + this.message = (message || "TransitionAborted"); + this.name = "TransitionAborted"; + } + + __exports__.Transition = Transition; + __exports__.logAbort = logAbort; + __exports__.TransitionAborted = TransitionAborted; + }); +define("router/utils", + ["exports"], + function(__exports__) { + "use strict"; + var slice = Array.prototype.slice; + + var _isArray; + if (!Array.isArray) { + _isArray = function (x) { + return Object.prototype.toString.call(x) === "[object Array]"; + }; + } else { + _isArray = Array.isArray; + } + + var isArray = _isArray; + __exports__.isArray = isArray; + function merge(hash, other) { + for (var prop in other) { + if (other.hasOwnProperty(prop)) { hash[prop] = other[prop]; } + } + } + + var oCreate = Object.create || function(proto) { + function F() {} + F.prototype = proto; + return new F(); + }; + __exports__.oCreate = oCreate; + /** + @private + + Extracts query params from the end of an array + **/ + function extractQueryParams(array) { + var len = (array && array.length), head, queryParams; + + if(len && len > 0 && array[len - 1] && array[len - 1].hasOwnProperty('queryParams')) { + queryParams = array[len - 1].queryParams; + head = slice.call(array, 0, len - 1); + return [head, queryParams]; + } else { + return [array, null]; + } + } + + __exports__.extractQueryParams = extractQueryParams;/** + @private + + Coerces query param properties and array elements into strings. + **/ + function coerceQueryParamsToString(queryParams) { + for (var key in queryParams) { + if (typeof queryParams[key] === 'number') { + queryParams[key] = '' + queryParams[key]; + } else if (isArray(queryParams[key])) { + for (var i = 0, l = queryParams[key].length; i < l; i++) { + queryParams[key][i] = '' + queryParams[key][i]; + } + } + } + } + /** + @private + */ + function log(router, sequence, msg) { + if (!router.log) { return; } + + if (arguments.length === 3) { + router.log("Transition #" + sequence + ": " + msg); + } else { + msg = sequence; + router.log(msg); + } + } + + __exports__.log = log;function bind(context, fn) { + var boundArgs = arguments; + return function(value) { + var args = slice.call(boundArgs, 2); + args.push(value); + return fn.apply(context, args); + }; + } + + __exports__.bind = bind;function isParam(object) { + return (typeof object === "string" || object instanceof String || typeof object === "number" || object instanceof Number); + } + + + function forEach(array, callback) { + for (var i=0, l=array.length; i=0; i--) { + var handlerInfo = handlerInfos[i], + handler = handlerInfo.handler; + + if (handler.events && handler.events[name]) { + if (handler.events[name].apply(handler, args) === true) { + eventWasHandled = true; + } else { + return; + } + } + } + + if (!eventWasHandled && !ignoreFailure) { + throw new Error("Nothing handled the event '" + name + "'."); + } + } + + __exports__.trigger = trigger;function getChangelist(oldObject, newObject) { + var key; + var results = { + all: {}, + changed: {}, + removed: {} + }; + + merge(results.all, newObject); + + var didChange = false; + coerceQueryParamsToString(oldObject); + coerceQueryParamsToString(newObject); + + // Calculate removals + for (key in oldObject) { + if (oldObject.hasOwnProperty(key)) { + if (!newObject.hasOwnProperty(key)) { + didChange = true; + results.removed[key] = oldObject[key]; + } + } + } + + // Calculate changes + for (key in newObject) { + if (newObject.hasOwnProperty(key)) { + if (isArray(oldObject[key]) && isArray(newObject[key])) { + if (oldObject[key].length !== newObject[key].length) { + results.changed[key] = newObject[key]; + didChange = true; + } else { + for (var i = 0, l = oldObject[key].length; i < l; i++) { + if (oldObject[key][i] !== newObject[key][i]) { + results.changed[key] = newObject[key]; + didChange = true; + } + } + } + } + else { + if (oldObject[key] !== newObject[key]) { + results.changed[key] = newObject[key]; + didChange = true; + } + } + } + } + + return didChange && results; + } + + __exports__.getChangelist = getChangelist;function promiseLabel(label) { + return 'Router: ' + label; + } + + __exports__.promiseLabel = promiseLabel;function subclass(parentConstructor, proto) { + function C(props) { + parentConstructor.call(this, props || {}); + } + C.prototype = oCreate(parentConstructor.prototype); + merge(C.prototype, proto); + return C; + } + + __exports__.subclass = subclass;function resolveHook(obj, hookName) { + if (!obj) { return; } + var underscored = "_" + hookName; + return obj[underscored] && underscored || + obj[hookName] && hookName; + } + + function callHook(obj, hookName) { + var args = slice.call(arguments, 2); + return applyHook(obj, hookName, args); + } + + function applyHook(obj, _hookName, args) { + var hookName = resolveHook(obj, _hookName); + if (hookName) { + return obj[hookName].apply(obj, args); + } + } + + __exports__.merge = merge; + __exports__.slice = slice; + __exports__.isParam = isParam; + __exports__.coerceQueryParamsToString = coerceQueryParamsToString; + __exports__.callHook = callHook; + __exports__.resolveHook = resolveHook; + __exports__.applyHook = applyHook; + }); +define("router", + ["./router/router","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Router = __dependency1__["default"]; + + __exports__["default"] = Router; + }); + +define("rsvp", + ["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all-settled","./rsvp/race","./rsvp/hash","./rsvp/hash-settled","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/filter","./rsvp/asap","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var EventTarget = __dependency2__["default"]; + var denodeify = __dependency3__["default"]; + var all = __dependency4__["default"]; + var allSettled = __dependency5__["default"]; + var race = __dependency6__["default"]; + var hash = __dependency7__["default"]; + var hashSettled = __dependency8__["default"]; + var rethrow = __dependency9__["default"]; + var defer = __dependency10__["default"]; + var config = __dependency11__.config; + var configure = __dependency11__.configure; + var map = __dependency12__["default"]; + var resolve = __dependency13__["default"]; + var reject = __dependency14__["default"]; + var filter = __dependency15__["default"]; + var asap = __dependency16__["default"]; + + config.async = asap; // default async is asap; + var cast = resolve; + function async(callback, arg) { + config.async(callback, arg); + } + + function on() { + config.on.apply(config, arguments); + } + + function off() { + config.off.apply(config, arguments); + } + + // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` + if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { + var callbacks = window['__PROMISE_INSTRUMENTATION__']; + configure('instrument', true); + for (var eventName in callbacks) { + if (callbacks.hasOwnProperty(eventName)) { + on(eventName, callbacks[eventName]); + } + } + } + + __exports__.cast = cast; + __exports__.Promise = Promise; + __exports__.EventTarget = EventTarget; + __exports__.all = all; + __exports__.allSettled = allSettled; + __exports__.race = race; + __exports__.hash = hash; + __exports__.hashSettled = hashSettled; + __exports__.rethrow = rethrow; + __exports__.defer = defer; + __exports__.denodeify = denodeify; + __exports__.configure = configure; + __exports__.on = on; + __exports__.off = off; + __exports__.resolve = resolve; + __exports__.reject = reject; + __exports__.async = async; + __exports__.map = map; + __exports__.filter = filter; + }); +define("rsvp.umd", + ["./rsvp"], + function(__dependency1__) { + "use strict"; + var Promise = __dependency1__.Promise; + var allSettled = __dependency1__.allSettled; + var hash = __dependency1__.hash; + var hashSettled = __dependency1__.hashSettled; + var denodeify = __dependency1__.denodeify; + var on = __dependency1__.on; + var off = __dependency1__.off; + var map = __dependency1__.map; + var filter = __dependency1__.filter; + var resolve = __dependency1__.resolve; + var reject = __dependency1__.reject; + var rethrow = __dependency1__.rethrow; + var all = __dependency1__.all; + var defer = __dependency1__.defer; + var EventTarget = __dependency1__.EventTarget; + var configure = __dependency1__.configure; + var race = __dependency1__.race; + var async = __dependency1__.async; + + var RSVP = { + 'race': race, + 'Promise': Promise, + 'allSettled': allSettled, + 'hash': hash, + 'hashSettled': hashSettled, + 'denodeify': denodeify, + 'on': on, + 'off': off, + 'map': map, + 'filter': filter, + 'resolve': resolve, + 'reject': reject, + 'all': all, + 'rethrow': rethrow, + 'defer': defer, + 'EventTarget': EventTarget, + 'configure': configure, + 'async': async + }; + + /* global define:true module:true window: true */ + if (typeof define === 'function' && define.amd) { + define(function() { return RSVP; }); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = RSVP; + } else if (typeof this !== 'undefined') { + this['RSVP'] = RSVP; + } + }); +define("rsvp/-internal", + ["./utils","./instrument","./config","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var objectOrFunction = __dependency1__.objectOrFunction; + var isFunction = __dependency1__.isFunction; + + var instrument = __dependency2__["default"]; + + var config = __dependency3__.config; + + function noop() {} + + var PENDING = void 0; + var FULFILLED = 1; + var REJECTED = 2; + + var GET_THEN_ERROR = new ErrorObject(); + + function getThen(promise) { + try { + return promise.then; + } catch(error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } + } + + function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch(e) { + return e; + } + } + + function handleForeignThenable(promise, thenable, then) { + config.async(function(promise) { + var sealed = false; + var error = tryThen(then, thenable, function(value) { + if (sealed) { return; } + sealed = true; + if (thenable !== value) { + resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function(reason) { + if (sealed) { return; } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); + } + }, promise); + } + + function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (promise._state === REJECTED) { + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function(value) { + if (thenable !== value) { + resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function(reason) { + reject(promise, reason); + }); + } + } + + function handleMaybeThenable(promise, maybeThenable) { + if (maybeThenable.constructor === promise.constructor) { + handleOwnThenable(promise, maybeThenable); + } else { + var then = getThen(maybeThenable); + + if (then === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + } else if (then === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then)) { + handleForeignThenable(promise, maybeThenable, then); + } else { + fulfill(promise, maybeThenable); + } + } + } + + function resolve(promise, value) { + if (promise === value) { + fulfill(promise, value); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value); + } else { + fulfill(promise, value); + } + } + + function publishRejection(promise) { + if (promise._onerror) { + promise._onerror(promise._result); + } + + publish(promise); + } + + function fulfill(promise, value) { + if (promise._state !== PENDING) { return; } + + promise._result = value; + promise._state = FULFILLED; + + if (promise._subscribers.length === 0) { + if (config.instrument) { + instrument('fulfilled', promise); + } + } else { + config.async(publish, promise); + } + } + + function reject(promise, reason) { + if (promise._state !== PENDING) { return; } + promise._state = REJECTED; + promise._result = reason; + + config.async(publishRejection, promise); + } + + function subscribe(parent, child, onFulfillment, onRejection) { + var subscribers = parent._subscribers; + var length = subscribers.length; + + parent._onerror = null; + + subscribers[length] = child; + subscribers[length + FULFILLED] = onFulfillment; + subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + config.async(publish, parent); + } + } + + function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; + + if (config.instrument) { + instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); + } + + if (subscribers.length === 0) { return; } + + var child, callback, detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); + } + } + + promise._subscribers.length = 0; + } + + function ErrorObject() { + this.error = null; + } + + var TRY_CATCH_ERROR = new ErrorObject(); + + function tryCatch(callback, detail) { + try { + return callback(detail); + } catch(e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } + } + + function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value, error, succeeded, failed; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value = null; + } else { + succeeded = true; + } + + if (promise === value) { + reject(promise, new TypeError('A promises callback cannot return that same promise.')); + return; + } + + } else { + value = detail; + succeeded = true; + } + + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } + } + + function initializePromise(promise, resolver) { + try { + resolver(function resolvePromise(value){ + resolve(promise, value); + }, function rejectPromise(reason) { + reject(promise, reason); + }); + } catch(e) { + reject(promise, e); + } + } + + __exports__.noop = noop; + __exports__.resolve = resolve; + __exports__.reject = reject; + __exports__.fulfill = fulfill; + __exports__.subscribe = subscribe; + __exports__.publish = publish; + __exports__.publishRejection = publishRejection; + __exports__.initializePromise = initializePromise; + __exports__.invokeCallback = invokeCallback; + __exports__.FULFILLED = FULFILLED; + __exports__.REJECTED = REJECTED; + __exports__.PENDING = PENDING; + }); +define("rsvp/all-settled", + ["./enumerator","./promise","./utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var Enumerator = __dependency1__["default"]; + var makeSettledResult = __dependency1__.makeSettledResult; + var Promise = __dependency2__["default"]; + var o_create = __dependency3__.o_create; + + function AllSettled(Constructor, entries, label) { + this._superConstructor(Constructor, entries, false /* don't abort on reject */, label); + } + + AllSettled.prototype = o_create(Enumerator.prototype); + AllSettled.prototype._superConstructor = Enumerator; + AllSettled.prototype._makeResult = makeSettledResult; + AllSettled.prototype._validationError = function() { + return new Error('allSettled must be called with an array'); + }; + + /** + `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + a fail-fast method, it waits until all the promises have returned and + shows you all the results. This is useful if you want to handle multiple + promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled. The return promise is fulfilled with an array of the states of + the promises passed into the `promises` array argument. + + Each state object will either indicate fulfillment or rejection, and + provide the corresponding value or reason. The states will take one of + the following formats: + + ```javascript + { state: 'fulfilled', value: value } + or + { state: 'rejected', reason: reason } + ``` + + Example: + + ```javascript + var promise1 = RSVP.Promise.resolve(1); + var promise2 = RSVP.Promise.reject(new Error('2')); + var promise3 = RSVP.Promise.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.allSettled(promises).then(function(array){ + // array == [ + // { state: 'fulfilled', value: 1 }, + // { state: 'rejected', reason: Error }, + // { state: 'rejected', reason: Error } + // ] + // Note that for the second item, reason.message will be '2', and for the + // third item, reason.message will be '3'. + }, function(error) { + // Not run. (This block would only be called if allSettled had failed, + // for instance if passed an incorrect argument type.) + }); + ``` + + @method allSettled + @static + @for RSVP + @param {Array} promises + @param {String} label - optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with an array of the settled + states of the constituent promises. + */ + + __exports__["default"] = function allSettled(entries, label) { + return new AllSettled(Promise, entries, label).promise; + } + }); +define("rsvp/all", + ["./promise","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + + /** + This is a convenient alias for `RSVP.Promise.all`. + + @method all + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ + __exports__["default"] = function all(array, label) { + return Promise.all(array, label); + } + }); +define("rsvp/asap", + ["exports"], + function(__exports__) { + "use strict"; + var len = 0; + + __exports__["default"] = function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 1, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + scheduleFlush(); + } + } + + var browserGlobal = (typeof window !== 'undefined') ? window : {}; + var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; + + // test for web worker but not in IE10 + var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + + // node + function useNextTick() { + return function() { + process.nextTick(flush); + }; + } + + function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function() { + node.data = (iterations = ++iterations % 2); + }; + } + + // web worker + function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; + } + + function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; + } + + var queue = new Array(1000); + function flush() { + for (var i = 0; i < len; i+=2) { + var callback = queue[i]; + var arg = queue[i+1]; + + callback(arg); + + queue[i] = undefined; + queue[i+1] = undefined; + } + + len = 0; + } + + var scheduleFlush; + + // Decide what async method to use to triggering processing of queued callbacks: + if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { + scheduleFlush = useNextTick(); + } else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); + } else if (isWorker) { + scheduleFlush = useMessageChannel(); + } else { + scheduleFlush = useSetTimeout(); + } + }); +define("rsvp/config", + ["./events","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var EventTarget = __dependency1__["default"]; + + var config = { + instrument: false + }; + + EventTarget.mixin(config); + + function configure(name, value) { + if (name === 'onerror') { + // handle for legacy users that expect the actual + // error to be passed to their function added via + // `RSVP.configure('onerror', someFunctionHere);` + config.on('error', value); + return; + } + + if (arguments.length === 2) { + config[name] = value; + } else { + return config[name]; + } + } + + __exports__.config = config; + __exports__.configure = configure; + }); +define("rsvp/defer", + ["./promise","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + + /** + `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. + `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s + interface. New code should use the `RSVP.Promise` constructor instead. + + The object returned from `RSVP.defer` is a plain object with three properties: + + * promise - an `RSVP.Promise`. + * reject - a function that causes the `promise` property on this object to + become rejected + * resolve - a function that causes the `promise` property on this object to + become fulfilled. + + Example: + + ```javascript + var deferred = RSVP.defer(); + + deferred.resolve("Success!"); + + defered.promise.then(function(value){ + // value here is "Success!" + }); + ``` + + @method defer + @static + @for RSVP + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Object} + */ + + __exports__["default"] = function defer(label) { + var deferred = { }; + + deferred.promise = new Promise(function(resolve, reject) { + deferred.resolve = resolve; + deferred.reject = reject; + }, label); + + return deferred; + } + }); +define("rsvp/enumerator", + ["./utils","./-internal","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var isArray = __dependency1__.isArray; + var isMaybeThenable = __dependency1__.isMaybeThenable; + + var noop = __dependency2__.noop; + var reject = __dependency2__.reject; + var fulfill = __dependency2__.fulfill; + var subscribe = __dependency2__.subscribe; + var FULFILLED = __dependency2__.FULFILLED; + var REJECTED = __dependency2__.REJECTED; + var PENDING = __dependency2__.PENDING; + + function makeSettledResult(state, position, value) { + if (state === FULFILLED) { + return { + state: 'fulfilled', + value: value + }; + } else { + return { + state: 'rejected', + reason: value + }; + } + } + + __exports__.makeSettledResult = makeSettledResult;function Enumerator(Constructor, input, abortOnReject, label) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop, label); + this._abortOnReject = abortOnReject; + + if (this._validateInput(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; + + this._init(); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + reject(this.promise, this._validationError()); + } + } + + Enumerator.prototype._validateInput = function(input) { + return isArray(input); + }; + + Enumerator.prototype._validationError = function() { + return new Error('Array Methods must be provided an Array'); + }; + + Enumerator.prototype._init = function() { + this._result = new Array(this.length); + }; + + __exports__["default"] = Enumerator; + + Enumerator.prototype._enumerate = function() { + var length = this.length; + var promise = this.promise; + var input = this._input; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + this._eachEntry(input[i], i); + } + }; + + Enumerator.prototype._eachEntry = function(entry, i) { + var c = this._instanceConstructor; + if (isMaybeThenable(entry)) { + if (entry.constructor === c && entry._state !== PENDING) { + entry._onerror = null; + this._settledAt(entry._state, i, entry._result); + } else { + this._willSettleAt(c.resolve(entry), i); + } + } else { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); + } + }; + + Enumerator.prototype._settledAt = function(state, i, value) { + var promise = this.promise; + + if (promise._state === PENDING) { + this._remaining--; + + if (this._abortOnReject && state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = this._makeResult(state, i, value); + } + } + + if (this._remaining === 0) { + fulfill(promise, this._result); + } + }; + + Enumerator.prototype._makeResult = function(state, i, value) { + return value; + }; + + Enumerator.prototype._willSettleAt = function(promise, i) { + var enumerator = this; + + subscribe(promise, undefined, function(value) { + enumerator._settledAt(FULFILLED, i, value); + }, function(reason) { + enumerator._settledAt(REJECTED, i, reason); + }); + }; + }); +define("rsvp/events", + ["exports"], + function(__exports__) { + "use strict"; + function indexOf(callbacks, callback) { + for (var i=0, l=callbacks.length; i 1; + }; + + RSVP.filter(promises, filterFn).then(function(result){ + // result is [ 2, 3 ] + }); + ``` + + If any of the `promises` given to `RSVP.filter` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var filterFn = function(item){ + return item > 1; + }; + + RSVP.filter(promises, filterFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` + + `RSVP.filter` will also wait for any promises returned from `filterFn`. + For instance, you may want to fetch a list of users then return a subset + of those users based on some asynchronous operation: + + ```javascript + + var alice = { name: 'alice' }; + var bob = { name: 'bob' }; + var users = [ alice, bob ]; + + var promises = users.map(function(user){ + return RSVP.resolve(user); + }); + + var filterFn = function(user){ + // Here, Alice has permissions to create a blog post, but Bob does not. + return getPrivilegesForUser(user).then(function(privs){ + return privs.can_create_blog_post === true; + }); + }; + RSVP.filter(promises, filterFn).then(function(users){ + // true, because the server told us only Alice can create a blog post. + users.length === 1; + // false, because Alice is the only user present in `users` + users[0] === bob; + }); + ``` + + @method filter + @static + @for RSVP + @param {Array} promises + @param {Function} filterFn - function to be called on each resolved value to + filter the final results. + @param {String} label optional string describing the promise. Useful for + tooling. + @return {Promise} + */ + __exports__["default"] = function filter(promises, filterFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(filterFn)) { + throw new TypeError("You must pass a function as filter's second argument."); + } + + var length = values.length; + var filtered = new Array(length); + + for (var i = 0; i < length; i++) { + filtered[i] = filterFn(values[i]); + } + + return Promise.all(filtered, label).then(function(filtered) { + var results = new Array(length); + var newLength = 0; + + for (var i = 0; i < length; i++) { + if (filtered[i]) { + results[newLength] = values[i]; + newLength++; + } + } + + results.length = newLength; + + return results; + }); + }); + } + }); +define("rsvp/hash-settled", + ["./promise","./enumerator","./promise-hash","./utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var makeSettledResult = __dependency2__.makeSettledResult; + var PromiseHash = __dependency3__["default"]; + var Enumerator = __dependency2__["default"]; + var o_create = __dependency4__.o_create; + + function HashSettled(Constructor, object, label) { + this._superConstructor(Constructor, object, false, label); + } + + HashSettled.prototype = o_create(PromiseHash.prototype); + HashSettled.prototype._superConstructor = Enumerator; + HashSettled.prototype._makeResult = makeSettledResult; + + HashSettled.prototype._validationError = function() { + return new Error('hashSettled must be called with an object'); + }; + + /** + `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + instead of an array for its `promises` argument. + + Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + but like `RSVP.allSettled`, `hashSettled` waits until all the + constituent promises have returned and then shows you all the results + with their states and values/reasons. This is useful if you want to + handle multiple promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled, or rejected if the passed parameters are invalid. + + The returned promise is fulfilled with a hash that has the same key names as + the `promises` object argument. If any of the values in the object are not + promises, they will be copied over to the fulfilled object and marked with state + 'fulfilled'. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + yourPromise: RSVP.Promise.resolve(2), + theirPromise: RSVP.Promise.resolve(3), + notAPromise: 4 + }; + + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // yourPromise: { state: 'fulfilled', value: 2 }, + // theirPromise: { state: 'fulfilled', value: 3 }, + // notAPromise: { state: 'fulfilled', value: 4 } + // } + }); + ``` + + If any of the `promises` given to `RSVP.hash` are rejected, the state will + be set to 'rejected' and the reason for rejection provided. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + rejectedPromise: RSVP.Promise.reject(new Error('rejection')), + anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), + }; + + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // rejectedPromise: { state: 'rejected', reason: Error }, + // anotherRejectedPromise: { state: 'rejected', reason: Error }, + // } + // Note that for rejectedPromise, reason.message == 'rejection', + // and for anotherRejectedPromise, reason.message == 'more rejection'. + }); + ``` + + An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype + chains. + + Example: + + ```javascript + function MyConstructor(){ + this.example = RSVP.Promise.resolve('Example'); + } + + MyConstructor.prototype = { + protoProperty: RSVP.Promise.resolve('Proto Property') + }; + + var myObject = new MyConstructor(); + + RSVP.hashSettled(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: { state: 'fulfilled', value: 'Example' } + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` + + @method hashSettled + @for RSVP + @param {Object} promises + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when when all properties of `promises` + have been settled. + @static + */ + __exports__["default"] = function hashSettled(object, label) { + return new HashSettled(Promise, object, label).promise; + } + }); +define("rsvp/hash", + ["./promise","./promise-hash","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var PromiseHash = __dependency2__["default"]; + + /** + `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array + for its `promises` argument. + + Returns a promise that is fulfilled when all the given promises have been + fulfilled, or rejected if any of them become rejected. The returned promise + is fulfilled with a hash that has the same key names as the `promises` object + argument. If any of the values in the object are not promises, they will + simply be copied over to the fulfilled object. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + yourPromise: RSVP.resolve(2), + theirPromise: RSVP.resolve(3), + notAPromise: 4 + }; + + RSVP.hash(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: 1, + // yourPromise: 2, + // theirPromise: 3, + // notAPromise: 4 + // } + }); + ```` + + If any of the `promises` given to `RSVP.hash` are rejected, the first promise + that is rejected will be given as the reason to the rejection handler. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + rejectedPromise: RSVP.reject(new Error('rejectedPromise')), + anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), + }; + + RSVP.hash(promises).then(function(hash){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === 'rejectedPromise' + }); + ``` + + An important note: `RSVP.hash` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hash` will NOT preserve prototype + chains. + + Example: + + ```javascript + function MyConstructor(){ + this.example = RSVP.resolve('Example'); + } + + MyConstructor.prototype = { + protoProperty: RSVP.resolve('Proto Property') + }; + + var myObject = new MyConstructor(); + + RSVP.hash(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: 'Example' + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` + + @method hash + @static + @for RSVP + @param {Object} promises + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all properties of `promises` + have been fulfilled, or rejected if any of them become rejected. + */ + __exports__["default"] = function hash(object, label) { + return new PromiseHash(Promise, object, label).promise; + } + }); +define("rsvp/instrument", + ["./config","./utils","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var config = __dependency1__.config; + var now = __dependency2__.now; + + var queue = []; + + __exports__["default"] = function instrument(eventName, promise, child) { + if (1 === queue.push({ + name: eventName, + payload: { + guid: promise._guidKey + promise._id, + eventName: eventName, + detail: promise._result, + childGuid: child && promise._guidKey + child._id, + label: promise._label, + timeStamp: now(), + stack: new Error(promise._label).stack + }})) { + + setTimeout(function() { + var entry; + for (var i = 0; i < queue.length; i++) { + entry = queue[i]; + config.trigger(entry.name, entry.payload); + } + queue.length = 0; + }, 50); + } + } + }); +define("rsvp/map", + ["./promise","./utils","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var isFunction = __dependency2__.isFunction; + + /** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. + + For example: + + ```javascript + + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; + }; + + RSVP.map(promises, mapFn).then(function(result){ + // result is [ 2, 3, 4 ] + }); + ``` + + If any of the `promises` given to `RSVP.map` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; + }; + + RSVP.map(promises, mapFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` + + `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, + say you want to get all comments from a set of blog posts, but you need + the blog posts first because they contain a url to those comments. + + ```javscript + + var mapFn = function(blogPost){ + // getComments does some ajax and returns an RSVP.Promise that is fulfilled + // with some comments data + return getComments(blogPost.comments_url); + }; + + // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled + // with some blog post data + RSVP.map(getBlogPosts(), mapFn).then(function(comments){ + // comments is the result of asking the server for the comments + // of all blog posts returned from getBlogPosts() + }); + ``` + + @method map + @static + @for RSVP + @param {Array} promises + @param {Function} mapFn function to be called on each fulfilled promise. + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with the result of calling + `mapFn` on each fulfilled promise or value when they become fulfilled. + The promise will be rejected if any of the given `promises` become rejected. + @static + */ + __exports__["default"] = function map(promises, mapFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(mapFn)) { + throw new TypeError("You must pass a function as map's second argument."); + } + + var length = values.length; + var results = new Array(length); + + for (var i = 0; i < length; i++) { + results[i] = mapFn(values[i]); + } + + return Promise.all(results, label); + }); + } + }); +define("rsvp/node", + ["./promise","./-internal","./utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + var noop = __dependency2__.noop; + var resolve = __dependency2__.resolve; + var reject = __dependency2__.reject; + var isArray = __dependency3__.isArray; + + function Result() { + this.value = undefined; + } + + var ERROR = new Result(); + var GET_THEN_ERROR = new Result(); + + function getThen(obj) { + try { + return obj.then; + } catch(error) { + ERROR.value= error; + return ERROR; + } + } + + + function tryApply(f, s, a) { + try { + f.apply(s, a); + } catch(error) { + ERROR.value = error; + return ERROR; + } + } + + function makeObject(_, argumentNames) { + var obj = {}; + var name; + var i; + var length = _.length; + var args = new Array(length); + + for (var x = 0; x < length; x++) { + args[x] = _[x]; + } + + for (i = 0; i < argumentNames.length; i++) { + name = argumentNames[i]; + obj[name] = args[i + 1]; + } + + return obj; + } + + function arrayResult(_) { + var length = _.length; + var args = new Array(length - 1); + + for (var i = 1; i < length; i++) { + args[i - 1] = _[i]; + } + + return args; + } + + function wrapThenable(then, promise) { + return { + then: function(onFulFillment, onRejection) { + return then.call(promise, onFulFillment, onRejection); + } + }; + } + + /** + `RSVP.denodeify` takes a 'node-style' function and returns a function that + will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + browser when you'd prefer to use promises over using callbacks. For example, + `denodeify` transforms the following: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) return handleError(err); + handleData(data); + }); + ``` + + into: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + + readFile('myfile.txt').then(handleData, handleError); + ``` + + If the node function has multiple success parameters, then `denodeify` + just returns the first one: + + ```javascript + var request = RSVP.denodeify(require('request')); + + request('http://example.com').then(function(res) { + // ... + }); + ``` + + However, if you need all success parameters, setting `denodeify`'s + second parameter to `true` causes it to return all success parameters + as an array: + + ```javascript + var request = RSVP.denodeify(require('request'), true); + + request('http://example.com').then(function(result) { + // result[0] -> res + // result[1] -> body + }); + ``` + + Or if you pass it an array with names it returns the parameters as a hash: + + ```javascript + var request = RSVP.denodeify(require('request'), ['res', 'body']); + + request('http://example.com').then(function(result) { + // result.res + // result.body + }); + ``` + + Sometimes you need to retain the `this`: + + ```javascript + var app = require('express')(); + var render = RSVP.denodeify(app.render.bind(app)); + ``` + + The denodified function inherits from the original function. It works in all + environments, except IE 10 and below. Consequently all properties of the original + function are available to you. However, any properties you change on the + denodeified function won't be changed on the original function. Example: + + ```javascript + var request = RSVP.denodeify(require('request')), + cookieJar = request.jar(); // <- Inheritance is used here + + request('http://example.com', {jar: cookieJar}).then(function(res) { + // cookieJar.cookies holds now the cookies returned by example.com + }); + ``` + + Using `denodeify` makes it easier to compose asynchronous operations instead + of using callbacks. For example, instead of: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) { ... } // Handle error + fs.writeFile('myfile2.txt', data, function(err){ + if (err) { ... } // Handle error + console.log('done') + }); + }); + ``` + + you can chain the operations together using `then` from the returned promise: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + var writeFile = RSVP.denodeify(fs.writeFile); + + readFile('myfile.txt').then(function(data){ + return writeFile('myfile2.txt', data); + }).then(function(){ + console.log('done') + }).catch(function(error){ + // Handle error + }); + ``` + + @method denodeify + @static + @for RSVP + @param {Function} nodeFunc a 'node-style' function that takes a callback as + its last argument. The callback expects an error to be passed as its first + argument (if an error occurred, otherwise null), and the value from the + operation as its second argument ('function(err, value){ }'). + @param {Boolean|Array} argumentNames An optional paramter that if set + to `true` causes the promise to fulfill with the callback's success arguments + as an array. This is useful if the node function has multiple success + paramters. If you set this paramter to an array with names, the promise will + fulfill with a hash with these names as keys and the success parameters as + values. + @return {Function} a function that wraps `nodeFunc` to return an + `RSVP.Promise` + @static + */ + __exports__["default"] = function denodeify(nodeFunc, options) { + var fn = function() { + var self = this; + var l = arguments.length; + var args = new Array(l + 1); + var arg; + var promiseInput = false; + + for (var i = 0; i < l; ++i) { + arg = arguments[i]; + + if (!promiseInput) { + // TODO: clean this up + promiseInput = needsPromiseInput(arg); + if (promiseInput === GET_THEN_ERROR) { + var p = new Promise(noop); + reject(p, GET_THEN_ERROR.value); + return p; + } else if (promiseInput && promiseInput !== true) { + arg = wrapThenable(promiseInput, arg); + } + } + args[i] = arg; + } + + var promise = new Promise(noop); + + args[l] = function(err, val) { + if (err) + reject(promise, err); + else if (options === undefined) + resolve(promise, val); + else if (options === true) + resolve(promise, arrayResult(arguments)); + else if (isArray(options)) + resolve(promise, makeObject(arguments, options)); + else + resolve(promise, val); + }; + + if (promiseInput) { + return handlePromiseInput(promise, args, nodeFunc, self); + } else { + return handleValueInput(promise, args, nodeFunc, self); + } + }; + + fn.__proto__ = nodeFunc; + + return fn; + } + + function handleValueInput(promise, args, nodeFunc, self) { + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + } + + function handlePromiseInput(promise, args, nodeFunc, self){ + return Promise.all(args).then(function(args){ + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + }); + } + + function needsPromiseInput(arg) { + if (arg && typeof arg === 'object') { + if (arg.constructor === Promise) { + return true; + } else { + return getThen(arg); + } + } else { + return false; + } + } + }); +define("rsvp/promise-hash", + ["./enumerator","./-internal","./utils","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __exports__) { + "use strict"; + var Enumerator = __dependency1__["default"]; + var PENDING = __dependency2__.PENDING; + var o_create = __dependency3__.o_create; + + function PromiseHash(Constructor, object, label) { + this._superConstructor(Constructor, object, true, label); + } + + __exports__["default"] = PromiseHash; + + PromiseHash.prototype = o_create(Enumerator.prototype); + PromiseHash.prototype._superConstructor = Enumerator; + PromiseHash.prototype._init = function() { + this._result = {}; + }; + + PromiseHash.prototype._validateInput = function(input) { + return input && typeof input === 'object'; + }; + + PromiseHash.prototype._validationError = function() { + return new Error('Promise.hash must be called with an object'); + }; + + PromiseHash.prototype._enumerate = function() { + var promise = this.promise; + var input = this._input; + var results = []; + + for (var key in input) { + if (promise._state === PENDING && input.hasOwnProperty(key)) { + results.push({ + position: key, + entry: input[key] + }); + } + } + + var length = results.length; + this._remaining = length; + var result; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + result = results[i]; + this._eachEntry(result.entry, result.position); + } + }; + }); +define("rsvp/promise", + ["./config","./instrument","./utils","./-internal","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) { + "use strict"; + var config = __dependency1__.config; + var instrument = __dependency2__["default"]; + + var isFunction = __dependency3__.isFunction; + var now = __dependency3__.now; + + var noop = __dependency4__.noop; + var subscribe = __dependency4__.subscribe; + var initializePromise = __dependency4__.initializePromise; + var invokeCallback = __dependency4__.invokeCallback; + var FULFILLED = __dependency4__.FULFILLED; + var REJECTED = __dependency4__.REJECTED; + + var all = __dependency5__["default"]; + var race = __dependency6__["default"]; + var Resolve = __dependency7__["default"]; + var Reject = __dependency8__["default"]; + + var guidKey = 'rsvp_' + now() + '-'; + var counter = 0; + + function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); + } + + function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); + } + __exports__["default"] = Promise; + /** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise’s eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + var promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + var xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } + }; + }); + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class RSVP.Promise + @param {function} resolver + @param {String} label optional string for labeling the promise. + Useful for tooling. + @constructor + */ + function Promise(resolver, label) { + this._id = counter++; + this._label = label; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + if (config.instrument) { + instrument('created', this); + } + + if (noop !== resolver) { + if (!isFunction(resolver)) { + needsResolver(); + } + + if (!(this instanceof Promise)) { + needsNew(); + } + + initializePromise(this, resolver); + } + } + + Promise.cast = Resolve; // deprecated + Promise.all = all; + Promise.race = race; + Promise.resolve = Resolve; + Promise.reject = Reject; + + Promise.prototype = { + constructor: Promise, + + _guidKey: guidKey, + + _onerror: function (reason) { + config.trigger('error', reason); + }, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + then: function(onFulfillment, onRejection, label) { + var parent = this; + var state = parent._state; + + if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { + if (config.instrument) { + instrument('chained', this, this); + } + return this; + } + + parent._onerror = null; + + var child = new this.constructor(noop, label); + var result = parent._result; + + if (config.instrument) { + instrument('chained', parent, child); + } + + if (state) { + var callback = arguments[state - 1]; + config.async(function(){ + invokeCallback(state, child, callback, result); + }); + } else { + subscribe(parent, child, onFulfillment, onRejection); + } + + return child; + }, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + 'catch': function(onRejection, label) { + return this.then(null, onRejection, label); + }, + + /** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves + + Synchronous example: + + ```js + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); + } + + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value + } + ``` + + Asynchronous example: + + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not + }); + ``` + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + 'finally': function(callback, label) { + var constructor = this.constructor; + + return this.then(function(value) { + return constructor.resolve(callback()).then(function(){ + return value; + }); + }, function(reason) { + return constructor.resolve(callback()).then(function(){ + throw reason; + }); + }, label); + } + }; + }); +define("rsvp/promise/all", + ["../enumerator","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Enumerator = __dependency1__["default"]; + + /** + `RSVP.Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `RSVP.all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error("2")); + var promise3 = RSVP.reject(new Error("3")); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static + */ + __exports__["default"] = function all(entries, label) { + return new Enumerator(this, entries, true /* abort on reject */, label).promise; + } + }); +define("rsvp/promise/race", + ["../utils","../-internal","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var isArray = __dependency1__.isArray; + + var noop = __dependency2__.noop; + var resolve = __dependency2__.resolve; + var reject = __dependency2__.reject; + var subscribe = __dependency2__.subscribe; + var PENDING = __dependency2__.PENDING; + + /** + `RSVP.Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `RSVP.Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} promises array of promises to observe + @param {String} label optional string for describing the promise returned. + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. + */ + __exports__["default"] = function race(entries, label) { + /*jshint validthis:true */ + var Constructor = this; + + var promise = new Constructor(noop, label); + + if (!isArray(entries)) { + reject(promise, new TypeError('You must pass an array to race.')); + return promise; + } + + var length = entries.length; + + function onFulfillment(value) { + resolve(promise, value); + } + + function onRejection(reason) { + reject(promise, reason); + } + + for (var i = 0; promise._state === PENDING && i < length; i++) { + subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); + } + + return promise; + } + }); +define("rsvp/promise/reject", + ["../-internal","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var noop = __dependency1__.noop; + var _reject = __dependency1__.reject; + + /** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {Any} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. + */ + __exports__["default"] = function reject(reason, label) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop, label); + _reject(promise, reason); + return promise; + } + }); +define("rsvp/promise/resolve", + ["../-internal","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var noop = __dependency1__.noop; + var _resolve = __dependency1__.resolve; + + /** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + __exports__["default"] = function resolve(object, label) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } + + var promise = new Constructor(noop, label); + _resolve(promise, object); + return promise; + } + }); +define("rsvp/race", + ["./promise","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + + /** + This is a convenient alias for `RSVP.Promise.race`. + + @method race + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ + __exports__["default"] = function race(array, label) { + return Promise.race(array, label); + } + }); +define("rsvp/reject", + ["./promise","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + + /** + This is a convenient alias for `RSVP.Promise.reject`. + + @method reject + @static + @for RSVP + @param {Any} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. + */ + __exports__["default"] = function reject(reason, label) { + return Promise.reject(reason, label); + } + }); +define("rsvp/resolve", + ["./promise","exports"], + function(__dependency1__, __exports__) { + "use strict"; + var Promise = __dependency1__["default"]; + + /** + This is a convenient alias for `RSVP.Promise.resolve`. + + @method resolve + @static + @for RSVP + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + __exports__["default"] = function resolve(value, label) { + return Promise.resolve(value, label); + } + }); +define("rsvp/rethrow", + ["exports"], + function(__exports__) { + "use strict"; + /** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + + ```javascript + function throws(){ + throw new Error('Whoops!'); + } + + var promise = new RSVP.Promise(function(resolve, reject){ + throws(); + }); + + promise.catch(RSVP.rethrow).then(function(){ + // Code here doesn't run because the promise became rejected due to an + // error! + }, function (err){ + // handle the error here + }); + ``` + + The 'Whoops' error will be thrown on the next turn of the event loop + and you can watch for it in your console. You can also handle it using a + rejection handler given to `.then` or `.catch` on the returned promise. + + @method rethrow + @static + @for RSVP + @param {Error} reason reason the promise became rejected. + @throws Error + @static + */ + __exports__["default"] = function rethrow(reason) { + setTimeout(function() { + throw reason; + }); + throw reason; + } + }); +define("rsvp/utils", + ["exports"], + function(__exports__) { + "use strict"; + function objectOrFunction(x) { + return typeof x === 'function' || (typeof x === 'object' && x !== null); + } + + __exports__.objectOrFunction = objectOrFunction;function isFunction(x) { + return typeof x === 'function'; + } + + __exports__.isFunction = isFunction;function isMaybeThenable(x) { + return typeof x === 'object' && x !== null; + } + + __exports__.isMaybeThenable = isMaybeThenable;var _isArray; + if (!Array.isArray) { + _isArray = function (x) { + return Object.prototype.toString.call(x) === '[object Array]'; + }; + } else { + _isArray = Array.isArray; + } + + var isArray = _isArray; + __exports__.isArray = isArray; + // Date.now is not available in browsers < IE9 + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility + var now = Date.now || function() { return new Date().getTime(); }; + __exports__.now = now; + function F() { } + + var o_create = (Object.create || function (o) { + if (arguments.length > 1) { + throw new Error('Second argument not supported'); + } + if (typeof o !== 'object') { + throw new TypeError('Argument must be an object'); + } + F.prototype = o; + return new F(); + }); + __exports__.o_create = o_create; + }); +requireModule("ember"); + +})(); \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/js/foo.js b/handling-spring-static-resources/src/main/webapp/js/foo.js new file mode 100644 index 000000000000..0172bf4e9604 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/foo.js @@ -0,0 +1,3 @@ +function testing() { + alert("Testing"); +} \ No newline at end of file diff --git a/handling-spring-static-resources/src/main/webapp/js/handlebars-3133af2.js b/handling-spring-static-resources/src/main/webapp/js/handlebars-3133af2.js new file mode 100644 index 000000000000..f826bbfd3879 --- /dev/null +++ b/handling-spring-static-resources/src/main/webapp/js/handlebars-3133af2.js @@ -0,0 +1,3079 @@ +/*! + + handlebars v2.0.0 + +Copyright (C) 2011-2014 by Yehuda Katz + +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 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. + +@license +*/ +/* exported Handlebars */ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + root.Handlebars = root.Handlebars || factory(); + } +}(this, function () { +// handlebars/safe-string.js +var __module4__ = (function() { + "use strict"; + var __exports__; + // Build out our basic SafeString type + function SafeString(string) { + this.string = string; + } + + SafeString.prototype.toString = function() { + return "" + this.string; + }; + + __exports__ = SafeString; + return __exports__; +})(); + +// handlebars/utils.js +var __module3__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + /*jshint -W004 */ + var SafeString = __dependency1__; + + var escape = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + function escapeChar(chr) { + return escape[chr]; + } + + function extend(obj /* , ...source */) { + for (var i = 1; i < arguments.length; i++) { + for (var key in arguments[i]) { + if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { + obj[key] = arguments[i][key]; + } + } + } + + return obj; + } + + __exports__.extend = extend;var toString = Object.prototype.toString; + __exports__.toString = toString; + // Sourced from lodash + // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt + var isFunction = function(value) { + return typeof value === 'function'; + }; + // fallback for older versions of Chrome and Safari + /* istanbul ignore next */ + if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; + } + var isFunction; + __exports__.isFunction = isFunction; + /* istanbul ignore next */ + var isArray = Array.isArray || function(value) { + return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; + }; + __exports__.isArray = isArray; + + function escapeExpression(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof SafeString) { + return string.toString(); + } else if (string == null) { + return ""; + } else if (!string) { + return string + ''; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = "" + string; + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + } + + __exports__.escapeExpression = escapeExpression;function isEmpty(value) { + if (!value && value !== 0) { + return true; + } else if (isArray(value) && value.length === 0) { + return true; + } else { + return false; + } + } + + __exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) { + return (contextPath ? contextPath + '.' : '') + id; + } + + __exports__.appendContextPath = appendContextPath; + return __exports__; +})(__module4__); + +// handlebars/exception.js +var __module5__ = (function() { + "use strict"; + var __exports__; + + var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + + function Exception(message, node) { + var line; + if (node && node.firstLine) { + line = node.firstLine; + + message += ' - ' + line + ':' + node.firstColumn; + } + + var tmp = Error.prototype.constructor.call(this, message); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } + + if (line) { + this.lineNumber = line; + this.column = node.firstColumn; + } + } + + Exception.prototype = new Error(); + + __exports__ = Exception; + return __exports__; +})(); + +// handlebars/base.js +var __module2__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var Utils = __dependency1__; + var Exception = __dependency2__; + + var VERSION = "2.0.0"; + __exports__.VERSION = VERSION;var COMPILER_REVISION = 6; + __exports__.COMPILER_REVISION = COMPILER_REVISION; + var REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '== 1.x.x', + 5: '== 2.0.0-alpha.x', + 6: '>= 2.0.0-beta.1' + }; + __exports__.REVISION_CHANGES = REVISION_CHANGES; + var isArray = Utils.isArray, + isFunction = Utils.isFunction, + toString = Utils.toString, + objectType = '[object Object]'; + + function HandlebarsEnvironment(helpers, partials) { + this.helpers = helpers || {}; + this.partials = partials || {}; + + registerDefaultHelpers(this); + } + + __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = { + constructor: HandlebarsEnvironment, + + logger: logger, + log: log, + + registerHelper: function(name, fn) { + if (toString.call(name) === objectType) { + if (fn) { throw new Exception('Arg not supported with multiple helpers'); } + Utils.extend(this.helpers, name); + } else { + this.helpers[name] = fn; + } + }, + unregisterHelper: function(name) { + delete this.helpers[name]; + }, + + registerPartial: function(name, partial) { + if (toString.call(name) === objectType) { + Utils.extend(this.partials, name); + } else { + this.partials[name] = partial; + } + }, + unregisterPartial: function(name) { + delete this.partials[name]; + } + }; + + function registerDefaultHelpers(instance) { + instance.registerHelper('helperMissing', function(/* [args, ]options */) { + if(arguments.length === 1) { + // A missing field in a {{foo}} constuct. + return undefined; + } else { + // Someone is actually trying to call something, blow up. + throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'"); + } + }); + + instance.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse, + fn = options.fn; + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if (isArray(context)) { + if(context.length > 0) { + if (options.ids) { + options.ids = [options.name]; + } + + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + if (options.data && options.ids) { + var data = createFrame(options.data); + data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name); + options = {data: data}; + } + + return fn(context, options); + } + }); + + instance.registerHelper('each', function(context, options) { + if (!options) { + throw new Exception('Must pass iterator to #each'); + } + + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + var contextPath; + if (options.data && options.ids) { + contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.'; + } + + if (isFunction(context)) { context = context.call(this); } + + if (options.data) { + data = createFrame(options.data); + } + + if(context && typeof context === 'object') { + if (isArray(context)) { + for(var j = context.length; i 0) { + throw new Exception("Invalid path: " + original, this); + } else if (part === "..") { + depth++; + depthString += '../'; + } else { + this.isScoped = true; + } + } else { + dig.push(part); + } + } + + this.original = original; + this.parts = dig; + this.string = dig.join('.'); + this.depth = depth; + this.idName = depthString + this.string; + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; + + this.stringModeValue = this.string; + }, + + PartialNameNode: function(name, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "PARTIAL_NAME"; + this.name = name.original; + }, + + DataNode: function(id, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "DATA"; + this.id = id; + this.stringModeValue = id.stringModeValue; + this.idName = '@' + id.stringModeValue; + }, + + StringNode: function(string, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "STRING"; + this.original = + this.string = + this.stringModeValue = string; + }, + + NumberNode: function(number, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "NUMBER"; + this.original = + this.number = number; + this.stringModeValue = Number(number); + }, + + BooleanNode: function(bool, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "BOOLEAN"; + this.bool = bool; + this.stringModeValue = bool === "true"; + }, + + CommentNode: function(comment, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "comment"; + this.comment = comment; + + this.strip = { + inlineStandalone: true + }; + } + }; + + + // Must be exported as an object rather than the root of the module as the jison lexer + // most modify the object to operate properly. + __exports__ = AST; + return __exports__; +})(__module5__); + +// handlebars/compiler/parser.js +var __module9__ = (function() { + "use strict"; + var __exports__; + /* jshint ignore:start */ + /* istanbul ignore next */ + /* Jison generated parser */ + var handlebars = (function(){ + var parser = {trace: function trace() { }, + yy: {}, + symbols_: {"error":2,"root":3,"program":4,"EOF":5,"program_repetition0":6,"statement":7,"mustache":8,"block":9,"rawBlock":10,"partial":11,"CONTENT":12,"COMMENT":13,"openRawBlock":14,"END_RAW_BLOCK":15,"OPEN_RAW_BLOCK":16,"sexpr":17,"CLOSE_RAW_BLOCK":18,"openBlock":19,"block_option0":20,"closeBlock":21,"openInverse":22,"block_option1":23,"OPEN_BLOCK":24,"CLOSE":25,"OPEN_INVERSE":26,"inverseAndProgram":27,"INVERSE":28,"OPEN_ENDBLOCK":29,"path":30,"OPEN":31,"OPEN_UNESCAPED":32,"CLOSE_UNESCAPED":33,"OPEN_PARTIAL":34,"partialName":35,"param":36,"partial_option0":37,"partial_option1":38,"sexpr_repetition0":39,"sexpr_option0":40,"dataName":41,"STRING":42,"NUMBER":43,"BOOLEAN":44,"OPEN_SEXPR":45,"CLOSE_SEXPR":46,"hash":47,"hash_repetition_plus0":48,"hashSegment":49,"ID":50,"EQUALS":51,"DATA":52,"pathSegments":53,"SEP":54,"$accept":0,"$end":1}, + terminals_: {2:"error",5:"EOF",12:"CONTENT",13:"COMMENT",15:"END_RAW_BLOCK",16:"OPEN_RAW_BLOCK",18:"CLOSE_RAW_BLOCK",24:"OPEN_BLOCK",25:"CLOSE",26:"OPEN_INVERSE",28:"INVERSE",29:"OPEN_ENDBLOCK",31:"OPEN",32:"OPEN_UNESCAPED",33:"CLOSE_UNESCAPED",34:"OPEN_PARTIAL",42:"STRING",43:"NUMBER",44:"BOOLEAN",45:"OPEN_SEXPR",46:"CLOSE_SEXPR",50:"ID",51:"EQUALS",52:"DATA",54:"SEP"}, + productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[10,3],[14,3],[9,4],[9,4],[19,3],[22,3],[27,2],[21,3],[8,3],[8,3],[11,5],[11,4],[17,3],[17,1],[36,1],[36,1],[36,1],[36,1],[36,1],[36,3],[47,1],[49,3],[35,1],[35,1],[35,1],[41,2],[30,1],[53,3],[53,1],[6,0],[6,2],[20,0],[20,1],[23,0],[23,1],[37,0],[37,1],[38,0],[38,1],[39,0],[39,2],[40,0],[40,1],[48,1],[48,2]], + performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { + + var $0 = $$.length - 1; + switch (yystate) { + case 1: yy.prepareProgram($$[$0-1].statements, true); return $$[$0-1]; + break; + case 2:this.$ = new yy.ProgramNode(yy.prepareProgram($$[$0]), {}, this._$); + break; + case 3:this.$ = $$[$0]; + break; + case 4:this.$ = $$[$0]; + break; + case 5:this.$ = $$[$0]; + break; + case 6:this.$ = $$[$0]; + break; + case 7:this.$ = new yy.ContentNode($$[$0], this._$); + break; + case 8:this.$ = new yy.CommentNode($$[$0], this._$); + break; + case 9:this.$ = new yy.RawBlockNode($$[$0-2], $$[$0-1], $$[$0], this._$); + break; + case 10:this.$ = new yy.MustacheNode($$[$0-1], null, '', '', this._$); + break; + case 11:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], false, this._$); + break; + case 12:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], true, this._$); + break; + case 13:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 14:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 15:this.$ = { strip: yy.stripFlags($$[$0-1], $$[$0-1]), program: $$[$0] }; + break; + case 16:this.$ = {path: $$[$0-1], strip: yy.stripFlags($$[$0-2], $$[$0])}; + break; + case 17:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 18:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 19:this.$ = new yy.PartialNode($$[$0-3], $$[$0-2], $$[$0-1], yy.stripFlags($$[$0-4], $$[$0]), this._$); + break; + case 20:this.$ = new yy.PartialNode($$[$0-2], undefined, $$[$0-1], yy.stripFlags($$[$0-3], $$[$0]), this._$); + break; + case 21:this.$ = new yy.SexprNode([$$[$0-2]].concat($$[$0-1]), $$[$0], this._$); + break; + case 22:this.$ = new yy.SexprNode([$$[$0]], null, this._$); + break; + case 23:this.$ = $$[$0]; + break; + case 24:this.$ = new yy.StringNode($$[$0], this._$); + break; + case 25:this.$ = new yy.NumberNode($$[$0], this._$); + break; + case 26:this.$ = new yy.BooleanNode($$[$0], this._$); + break; + case 27:this.$ = $$[$0]; + break; + case 28:$$[$0-1].isHelper = true; this.$ = $$[$0-1]; + break; + case 29:this.$ = new yy.HashNode($$[$0], this._$); + break; + case 30:this.$ = [$$[$0-2], $$[$0]]; + break; + case 31:this.$ = new yy.PartialNameNode($$[$0], this._$); + break; + case 32:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0], this._$), this._$); + break; + case 33:this.$ = new yy.PartialNameNode(new yy.NumberNode($$[$0], this._$)); + break; + case 34:this.$ = new yy.DataNode($$[$0], this._$); + break; + case 35:this.$ = new yy.IdNode($$[$0], this._$); + break; + case 36: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2]; + break; + case 37:this.$ = [{part: $$[$0]}]; + break; + case 38:this.$ = []; + break; + case 39:$$[$0-1].push($$[$0]); + break; + case 48:this.$ = []; + break; + case 49:$$[$0-1].push($$[$0]); + break; + case 52:this.$ = [$$[$0]]; + break; + case 53:$$[$0-1].push($$[$0]); + break; + } + }, + table: [{3:1,4:2,5:[2,38],6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],31:[2,38],32:[2,38],34:[2,38]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:[1,10],13:[1,11],14:16,16:[1,20],19:14,22:15,24:[1,18],26:[1,19],28:[2,2],29:[2,2],31:[1,12],32:[1,13],34:[1,17]},{1:[2,1]},{5:[2,39],12:[2,39],13:[2,39],16:[2,39],24:[2,39],26:[2,39],28:[2,39],29:[2,39],31:[2,39],32:[2,39],34:[2,39]},{5:[2,3],12:[2,3],13:[2,3],16:[2,3],24:[2,3],26:[2,3],28:[2,3],29:[2,3],31:[2,3],32:[2,3],34:[2,3]},{5:[2,4],12:[2,4],13:[2,4],16:[2,4],24:[2,4],26:[2,4],28:[2,4],29:[2,4],31:[2,4],32:[2,4],34:[2,4]},{5:[2,5],12:[2,5],13:[2,5],16:[2,5],24:[2,5],26:[2,5],28:[2,5],29:[2,5],31:[2,5],32:[2,5],34:[2,5]},{5:[2,6],12:[2,6],13:[2,6],16:[2,6],24:[2,6],26:[2,6],28:[2,6],29:[2,6],31:[2,6],32:[2,6],34:[2,6]},{5:[2,7],12:[2,7],13:[2,7],16:[2,7],24:[2,7],26:[2,7],28:[2,7],29:[2,7],31:[2,7],32:[2,7],34:[2,7]},{5:[2,8],12:[2,8],13:[2,8],16:[2,8],24:[2,8],26:[2,8],28:[2,8],29:[2,8],31:[2,8],32:[2,8],34:[2,8]},{17:21,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:27,30:22,41:23,50:[1,26],52:[1,25],53:24},{4:28,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{4:29,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{12:[1,30]},{30:32,35:31,42:[1,33],43:[1,34],50:[1,26],53:24},{17:35,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:36,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:37,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[1,38]},{18:[2,48],25:[2,48],33:[2,48],39:39,42:[2,48],43:[2,48],44:[2,48],45:[2,48],46:[2,48],50:[2,48],52:[2,48]},{18:[2,22],25:[2,22],33:[2,22],46:[2,22]},{18:[2,35],25:[2,35],33:[2,35],42:[2,35],43:[2,35],44:[2,35],45:[2,35],46:[2,35],50:[2,35],52:[2,35],54:[1,40]},{30:41,50:[1,26],53:24},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],52:[2,37],54:[2,37]},{33:[1,42]},{20:43,27:44,28:[1,45],29:[2,40]},{23:46,27:47,28:[1,45],29:[2,42]},{15:[1,48]},{25:[2,46],30:51,36:49,38:50,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],47:57,48:58,49:60,50:[1,59],52:[1,25],53:24},{25:[2,31],42:[2,31],43:[2,31],44:[2,31],45:[2,31],50:[2,31],52:[2,31]},{25:[2,32],42:[2,32],43:[2,32],44:[2,32],45:[2,32],50:[2,32],52:[2,32]},{25:[2,33],42:[2,33],43:[2,33],44:[2,33],45:[2,33],50:[2,33],52:[2,33]},{25:[1,61]},{25:[1,62]},{18:[1,63]},{5:[2,17],12:[2,17],13:[2,17],16:[2,17],24:[2,17],26:[2,17],28:[2,17],29:[2,17],31:[2,17],32:[2,17],34:[2,17]},{18:[2,50],25:[2,50],30:51,33:[2,50],36:65,40:64,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],46:[2,50],47:66,48:58,49:60,50:[1,59],52:[1,25],53:24},{50:[1,67]},{18:[2,34],25:[2,34],33:[2,34],42:[2,34],43:[2,34],44:[2,34],45:[2,34],46:[2,34],50:[2,34],52:[2,34]},{5:[2,18],12:[2,18],13:[2,18],16:[2,18],24:[2,18],26:[2,18],28:[2,18],29:[2,18],31:[2,18],32:[2,18],34:[2,18]},{21:68,29:[1,69]},{29:[2,41]},{4:70,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{21:71,29:[1,69]},{29:[2,43]},{5:[2,9],12:[2,9],13:[2,9],16:[2,9],24:[2,9],26:[2,9],28:[2,9],29:[2,9],31:[2,9],32:[2,9],34:[2,9]},{25:[2,44],37:72,47:73,48:58,49:60,50:[1,74]},{25:[1,75]},{18:[2,23],25:[2,23],33:[2,23],42:[2,23],43:[2,23],44:[2,23],45:[2,23],46:[2,23],50:[2,23],52:[2,23]},{18:[2,24],25:[2,24],33:[2,24],42:[2,24],43:[2,24],44:[2,24],45:[2,24],46:[2,24],50:[2,24],52:[2,24]},{18:[2,25],25:[2,25],33:[2,25],42:[2,25],43:[2,25],44:[2,25],45:[2,25],46:[2,25],50:[2,25],52:[2,25]},{18:[2,26],25:[2,26],33:[2,26],42:[2,26],43:[2,26],44:[2,26],45:[2,26],46:[2,26],50:[2,26],52:[2,26]},{18:[2,27],25:[2,27],33:[2,27],42:[2,27],43:[2,27],44:[2,27],45:[2,27],46:[2,27],50:[2,27],52:[2,27]},{17:76,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[2,47]},{18:[2,29],25:[2,29],33:[2,29],46:[2,29],49:77,50:[1,74]},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],51:[1,78],52:[2,37],54:[2,37]},{18:[2,52],25:[2,52],33:[2,52],46:[2,52],50:[2,52]},{12:[2,13],13:[2,13],16:[2,13],24:[2,13],26:[2,13],28:[2,13],29:[2,13],31:[2,13],32:[2,13],34:[2,13]},{12:[2,14],13:[2,14],16:[2,14],24:[2,14],26:[2,14],28:[2,14],29:[2,14],31:[2,14],32:[2,14],34:[2,14]},{12:[2,10]},{18:[2,21],25:[2,21],33:[2,21],46:[2,21]},{18:[2,49],25:[2,49],33:[2,49],42:[2,49],43:[2,49],44:[2,49],45:[2,49],46:[2,49],50:[2,49],52:[2,49]},{18:[2,51],25:[2,51],33:[2,51],46:[2,51]},{18:[2,36],25:[2,36],33:[2,36],42:[2,36],43:[2,36],44:[2,36],45:[2,36],46:[2,36],50:[2,36],52:[2,36],54:[2,36]},{5:[2,11],12:[2,11],13:[2,11],16:[2,11],24:[2,11],26:[2,11],28:[2,11],29:[2,11],31:[2,11],32:[2,11],34:[2,11]},{30:79,50:[1,26],53:24},{29:[2,15]},{5:[2,12],12:[2,12],13:[2,12],16:[2,12],24:[2,12],26:[2,12],28:[2,12],29:[2,12],31:[2,12],32:[2,12],34:[2,12]},{25:[1,80]},{25:[2,45]},{51:[1,78]},{5:[2,20],12:[2,20],13:[2,20],16:[2,20],24:[2,20],26:[2,20],28:[2,20],29:[2,20],31:[2,20],32:[2,20],34:[2,20]},{46:[1,81]},{18:[2,53],25:[2,53],33:[2,53],46:[2,53],50:[2,53]},{30:51,36:82,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],50:[1,26],52:[1,25],53:24},{25:[1,83]},{5:[2,19],12:[2,19],13:[2,19],16:[2,19],24:[2,19],26:[2,19],28:[2,19],29:[2,19],31:[2,19],32:[2,19],34:[2,19]},{18:[2,28],25:[2,28],33:[2,28],42:[2,28],43:[2,28],44:[2,28],45:[2,28],46:[2,28],50:[2,28],52:[2,28]},{18:[2,30],25:[2,30],33:[2,30],46:[2,30],50:[2,30]},{5:[2,16],12:[2,16],13:[2,16],16:[2,16],24:[2,16],26:[2,16],28:[2,16],29:[2,16],31:[2,16],32:[2,16],34:[2,16]}], + defaultActions: {4:[2,1],44:[2,41],47:[2,43],57:[2,47],63:[2,10],70:[2,15],73:[2,45]}, + parseError: function parseError(str, hash) { + throw new Error(str); + }, + parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == "undefined") + this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === "function") + this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== "number") { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + if (!recovering) { + expected = []; + for (p in table[state]) + if (this.terminals_[p] && p > 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + /* Jison generated lexer */ + var lexer = (function(){ + var lexer = ({EOF:1, + parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + setInput:function (input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; + if (this.options.ranges) this.yylloc.range = [0,0]; + this.offset = 0; + return this; + }, + input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, + unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length-len-1); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length-1); + this.matched = this.matched.substr(0, this.matched.length-1); + + if (lines.length-1) this.yylineno -= lines.length-1; + var r = this.yylloc.range; + + this.yylloc = {first_line: this.yylloc.first_line, + last_line: this.yylineno+1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, + more:function () { + this._more = true; + return this; + }, + less:function (n) { + this.unput(this.match.slice(n)); + }, + pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); + }, + showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c+"^"; + }, + next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, + match, + tempMatch, + index, + col, + lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i=0;i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = {first_line: this.yylloc.last_line, + last_line: this.yylineno+1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); + if (this.done && this._input) this.done = false; + if (token) return token; + else return; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + {text: "", token: null, line: this.yylineno}); + } + }, + lex:function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, + begin:function begin(condition) { + this.conditionStack.push(condition); + }, + popState:function popState() { + return this.conditionStack.pop(); + }, + _currentRules:function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; + }, + topState:function () { + return this.conditionStack[this.conditionStack.length-2]; + }, + pushState:function begin(condition) { + this.begin(condition); + }}); + lexer.options = {}; + lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + + + function strip(start, end) { + return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end); + } + + + var YYSTATE=YY_START + switch($avoiding_name_collisions) { + case 0: + if(yy_.yytext.slice(-2) === "\\\\") { + strip(0,1); + this.begin("mu"); + } else if(yy_.yytext.slice(-1) === "\\") { + strip(0,1); + this.begin("emu"); + } else { + this.begin("mu"); + } + if(yy_.yytext) return 12; + + break; + case 1:return 12; + break; + case 2: + this.popState(); + return 12; + + break; + case 3: + yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9); + this.popState(); + return 15; + + break; + case 4: return 12; + break; + case 5:strip(0,4); this.popState(); return 13; + break; + case 6:return 45; + break; + case 7:return 46; + break; + case 8: return 16; + break; + case 9: + this.popState(); + this.begin('raw'); + return 18; + + break; + case 10:return 34; + break; + case 11:return 24; + break; + case 12:return 29; + break; + case 13:this.popState(); return 28; + break; + case 14:this.popState(); return 28; + break; + case 15:return 26; + break; + case 16:return 26; + break; + case 17:return 32; + break; + case 18:return 31; + break; + case 19:this.popState(); this.begin('com'); + break; + case 20:strip(3,5); this.popState(); return 13; + break; + case 21:return 31; + break; + case 22:return 51; + break; + case 23:return 50; + break; + case 24:return 50; + break; + case 25:return 54; + break; + case 26:// ignore whitespace + break; + case 27:this.popState(); return 33; + break; + case 28:this.popState(); return 25; + break; + case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 42; + break; + case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 42; + break; + case 31:return 52; + break; + case 32:return 44; + break; + case 33:return 44; + break; + case 34:return 43; + break; + case 35:return 50; + break; + case 36:yy_.yytext = strip(1,2); return 50; + break; + case 37:return 'INVALID'; + break; + case 38:return 5; + break; + } + }; + lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; + lexer.conditions = {"mu":{"rules":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,38],"inclusive":true}}; + return lexer;})() + parser.lexer = lexer; + function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; + return new Parser; + })();__exports__ = handlebars; + /* jshint ignore:end */ + return __exports__; +})(); + +// handlebars/compiler/helpers.js +var __module10__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + var Exception = __dependency1__; + + function stripFlags(open, close) { + return { + left: open.charAt(2) === '~', + right: close.charAt(close.length-3) === '~' + }; + } + + __exports__.stripFlags = stripFlags; + function prepareBlock(mustache, program, inverseAndProgram, close, inverted, locInfo) { + /*jshint -W040 */ + if (mustache.sexpr.id.original !== close.path.original) { + throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + close.path.original, mustache); + } + + var inverse = inverseAndProgram && inverseAndProgram.program; + + var strip = { + left: mustache.strip.left, + right: close.strip.right, + + // Determine the standalone candiacy. Basically flag our content as being possibly standalone + // so our parent can determine if we actually are standalone + openStandalone: isNextWhitespace(program.statements), + closeStandalone: isPrevWhitespace((inverse || program).statements) + }; + + if (mustache.strip.right) { + omitRight(program.statements, null, true); + } + + if (inverse) { + var inverseStrip = inverseAndProgram.strip; + + if (inverseStrip.left) { + omitLeft(program.statements, null, true); + } + if (inverseStrip.right) { + omitRight(inverse.statements, null, true); + } + if (close.strip.left) { + omitLeft(inverse.statements, null, true); + } + + // Find standalone else statments + if (isPrevWhitespace(program.statements) + && isNextWhitespace(inverse.statements)) { + + omitLeft(program.statements); + omitRight(inverse.statements); + } + } else { + if (close.strip.left) { + omitLeft(program.statements, null, true); + } + } + + if (inverted) { + return new this.BlockNode(mustache, inverse, program, strip, locInfo); + } else { + return new this.BlockNode(mustache, program, inverse, strip, locInfo); + } + } + + __exports__.prepareBlock = prepareBlock; + function prepareProgram(statements, isRoot) { + for (var i = 0, l = statements.length; i < l; i++) { + var current = statements[i], + strip = current.strip; + + if (!strip) { + continue; + } + + var _isPrevWhitespace = isPrevWhitespace(statements, i, isRoot, current.type === 'partial'), + _isNextWhitespace = isNextWhitespace(statements, i, isRoot), + + openStandalone = strip.openStandalone && _isPrevWhitespace, + closeStandalone = strip.closeStandalone && _isNextWhitespace, + inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace; + + if (strip.right) { + omitRight(statements, i, true); + } + if (strip.left) { + omitLeft(statements, i, true); + } + + if (inlineStandalone) { + omitRight(statements, i); + + if (omitLeft(statements, i)) { + // If we are on a standalone node, save the indent info for partials + if (current.type === 'partial') { + current.indent = (/([ \t]+$)/).exec(statements[i-1].original) ? RegExp.$1 : ''; + } + } + } + if (openStandalone) { + omitRight((current.program || current.inverse).statements); + + // Strip out the previous content node if it's whitespace only + omitLeft(statements, i); + } + if (closeStandalone) { + // Always strip the next node + omitRight(statements, i); + + omitLeft((current.inverse || current.program).statements); + } + } + + return statements; + } + + __exports__.prepareProgram = prepareProgram;function isPrevWhitespace(statements, i, isRoot) { + if (i === undefined) { + i = statements.length; + } + + // Nodes that end with newlines are considered whitespace (but are special + // cased for strip operations) + var prev = statements[i-1], + sibling = statements[i-2]; + if (!prev) { + return isRoot; + } + + if (prev.type === 'content') { + return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original); + } + } + function isNextWhitespace(statements, i, isRoot) { + if (i === undefined) { + i = -1; + } + + var next = statements[i+1], + sibling = statements[i+2]; + if (!next) { + return isRoot; + } + + if (next.type === 'content') { + return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original); + } + } + + // Marks the node to the right of the position as omitted. + // I.e. {{foo}}' ' will mark the ' ' node as omitted. + // + // If i is undefined, then the first child will be marked as such. + // + // If mulitple is truthy then all whitespace will be stripped out until non-whitespace + // content is met. + function omitRight(statements, i, multiple) { + var current = statements[i == null ? 0 : i + 1]; + if (!current || current.type !== 'content' || (!multiple && current.rightStripped)) { + return; + } + + var original = current.string; + current.string = current.string.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), ''); + current.rightStripped = current.string !== original; + } + + // Marks the node to the left of the position as omitted. + // I.e. ' '{{foo}} will mark the ' ' node as omitted. + // + // If i is undefined then the last child will be marked as such. + // + // If mulitple is truthy then all whitespace will be stripped out until non-whitespace + // content is met. + function omitLeft(statements, i, multiple) { + var current = statements[i == null ? statements.length - 1 : i - 1]; + if (!current || current.type !== 'content' || (!multiple && current.leftStripped)) { + return; + } + + // We omit the last node if it's whitespace only and not preceeded by a non-content node. + var original = current.string; + current.string = current.string.replace(multiple ? (/\s+$/) : (/[ \t]+$/), ''); + current.leftStripped = current.string !== original; + return current.leftStripped; + } + return __exports__; +})(__module5__); + +// handlebars/compiler/base.js +var __module8__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) { + "use strict"; + var __exports__ = {}; + var parser = __dependency1__; + var AST = __dependency2__; + var Helpers = __dependency3__; + var extend = __dependency4__.extend; + + __exports__.parser = parser; + + var yy = {}; + extend(yy, Helpers, AST); + + function parse(input) { + // Just return if an already-compile AST was passed in. + if (input.constructor === AST.ProgramNode) { return input; } + + parser.yy = yy; + + return parser.parse(input); + } + + __exports__.parse = parse; + return __exports__; +})(__module9__, __module7__, __module10__, __module3__); + +// handlebars/compiler/compiler.js +var __module11__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var Exception = __dependency1__; + var isArray = __dependency2__.isArray; + + var slice = [].slice; + + function Compiler() {} + + __exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a + // function in a context. This is necessary for mustache compatibility, which + // requires that context functions in blocks are evaluated by blockHelperMissing, + // and then proceed as if the resulting value was provided to blockHelperMissing. + + Compiler.prototype = { + compiler: Compiler, + + equals: function(other) { + var len = this.opcodes.length; + if (other.opcodes.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + var opcode = this.opcodes[i], + otherOpcode = other.opcodes[i]; + if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) { + return false; + } + } + + // We know that length is the same between the two arrays because they are directly tied + // to the opcode behavior above. + len = this.children.length; + for (i = 0; i < len; i++) { + if (!this.children[i].equals(other.children[i])) { + return false; + } + } + + return true; + }, + + guid: 0, + + compile: function(program, options) { + this.opcodes = []; + this.children = []; + this.depths = {list: []}; + this.options = options; + this.stringParams = options.stringParams; + this.trackIds = options.trackIds; + + // These changes will propagate to the other compiler components + var knownHelpers = this.options.knownHelpers; + this.options.knownHelpers = { + 'helperMissing': true, + 'blockHelperMissing': true, + 'each': true, + 'if': true, + 'unless': true, + 'with': true, + 'log': true, + 'lookup': true + }; + if (knownHelpers) { + for (var name in knownHelpers) { + this.options.knownHelpers[name] = knownHelpers[name]; + } + } + + return this.accept(program); + }, + + accept: function(node) { + return this[node.type](node); + }, + + program: function(program) { + var statements = program.statements; + + for(var i=0, l=statements.length; i 0) { + varDeclarations += ", " + locals.join(", "); + } + + // Generate minimizer alias mappings + for (var alias in this.aliases) { + if (this.aliases.hasOwnProperty(alias)) { + varDeclarations += ', ' + alias + '=' + this.aliases[alias]; + } + } + + var params = ["depth0", "helpers", "partials", "data"]; + + if (this.useDepths) { + params.push('depths'); + } + + // Perform a second pass over the output to merge content when possible + var source = this.mergeSource(varDeclarations); + + if (asObject) { + params.push(source); + + return Function.apply(this, params); + } else { + return 'function(' + params.join(',') + ') {\n ' + source + '}'; + } + }, + mergeSource: function(varDeclarations) { + var source = '', + buffer, + appendOnly = !this.forceBuffer, + appendFirst; + + for (var i = 0, len = this.source.length; i < len; i++) { + var line = this.source[i]; + if (line.appendToBuffer) { + if (buffer) { + buffer = buffer + '\n + ' + line.content; + } else { + buffer = line.content; + } + } else { + if (buffer) { + if (!source) { + appendFirst = true; + source = buffer + ';\n '; + } else { + source += 'buffer += ' + buffer + ';\n '; + } + buffer = undefined; + } + source += line + '\n '; + + if (!this.environment.isSimple) { + appendOnly = false; + } + } + } + + if (appendOnly) { + if (buffer || !source) { + source += 'return ' + (buffer || '""') + ';\n'; + } + } else { + varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer()); + if (buffer) { + source += 'return buffer + ' + buffer + ';\n'; + } else { + source += 'return buffer;\n'; + } + } + + if (varDeclarations) { + source = 'var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n ') + source; + } + + return source; + }, + + // [blockValue] + // + // On stack, before: hash, inverse, program, value + // On stack, after: return value of blockHelperMissing + // + // The purpose of this opcode is to take a block of the form + // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and + // replace it on the stack with the result of properly + // invoking blockHelperMissing. + blockValue: function(name) { + this.aliases.blockHelperMissing = 'helpers.blockHelperMissing'; + + var params = [this.contextName(0)]; + this.setupParams(name, 0, params); + + var blockName = this.popStack(); + params.splice(1, 0, blockName); + + this.push('blockHelperMissing.call(' + params.join(', ') + ')'); + }, + + // [ambiguousBlockValue] + // + // On stack, before: hash, inverse, program, value + // Compiler value, before: lastHelper=value of last found helper, if any + // On stack, after, if no lastHelper: same as [blockValue] + // On stack, after, if lastHelper: value + ambiguousBlockValue: function() { + this.aliases.blockHelperMissing = 'helpers.blockHelperMissing'; + + // We're being a bit cheeky and reusing the options value from the prior exec + var params = [this.contextName(0)]; + this.setupParams('', 0, params, true); + + this.flushInline(); + + var current = this.topStack(); + params.splice(1, 0, current); + + this.pushSource("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }"); + }, + + // [appendContent] + // + // On stack, before: ... + // On stack, after: ... + // + // Appends the string value of `content` to the current buffer + appendContent: function(content) { + if (this.pendingContent) { + content = this.pendingContent + content; + } + + this.pendingContent = content; + }, + + // [append] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Coerces `value` to a String and appends it to the current buffer. + // + // If `value` is truthy, or 0, it is coerced into a string and appended + // Otherwise, the empty string is appended + append: function() { + // Force anything that is inlined onto the stack so we don't have duplication + // when we examine local + this.flushInline(); + var local = this.popStack(); + this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }'); + if (this.environment.isSimple) { + this.pushSource("else { " + this.appendToBuffer("''") + " }"); + } + }, + + // [appendEscaped] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Escape `value` and append it to the buffer + appendEscaped: function() { + this.aliases.escapeExpression = 'this.escapeExpression'; + + this.pushSource(this.appendToBuffer("escapeExpression(" + this.popStack() + ")")); + }, + + // [getContext] + // + // On stack, before: ... + // On stack, after: ... + // Compiler value, after: lastContext=depth + // + // Set the value of the `lastContext` compiler value to the depth + getContext: function(depth) { + this.lastContext = depth; + }, + + // [pushContext] + // + // On stack, before: ... + // On stack, after: currentContext, ... + // + // Pushes the value of the current context onto the stack. + pushContext: function() { + this.pushStackLiteral(this.contextName(this.lastContext)); + }, + + // [lookupOnContext] + // + // On stack, before: ... + // On stack, after: currentContext[name], ... + // + // Looks up the value of `name` on the current context and pushes + // it onto the stack. + lookupOnContext: function(parts, falsy, scoped) { + /*jshint -W083 */ + var i = 0, + len = parts.length; + + if (!scoped && this.options.compat && !this.lastContext) { + // The depthed query is expected to handle the undefined logic for the root level that + // is implemented below, so we evaluate that directly in compat mode + this.push(this.depthedLookup(parts[i++])); + } else { + this.pushContext(); + } + + for (; i < len; i++) { + this.replaceStack(function(current) { + var lookup = this.nameLookup(current, parts[i], 'context'); + // We want to ensure that zero and false are handled properly if the context (falsy flag) + // needs to have the special handling for these values. + if (!falsy) { + return ' != null ? ' + lookup + ' : ' + current; + } else { + // Otherwise we can use generic falsy handling + return ' && ' + lookup; + } + }); + } + }, + + // [lookupData] + // + // On stack, before: ... + // On stack, after: data, ... + // + // Push the data lookup operator + lookupData: function(depth, parts) { + /*jshint -W083 */ + if (!depth) { + this.pushStackLiteral('data'); + } else { + this.pushStackLiteral('this.data(data, ' + depth + ')'); + } + + var len = parts.length; + for (var i = 0; i < len; i++) { + this.replaceStack(function(current) { + return ' && ' + this.nameLookup(current, parts[i], 'data'); + }); + } + }, + + // [resolvePossibleLambda] + // + // On stack, before: value, ... + // On stack, after: resolved value, ... + // + // If the `value` is a lambda, replace it on the stack by + // the return value of the lambda + resolvePossibleLambda: function() { + this.aliases.lambda = 'this.lambda'; + + this.push('lambda(' + this.popStack() + ', ' + this.contextName(0) + ')'); + }, + + // [pushStringParam] + // + // On stack, before: ... + // On stack, after: string, currentContext, ... + // + // This opcode is designed for use in string mode, which + // provides the string value of a parameter along with its + // depth rather than resolving it immediately. + pushStringParam: function(string, type) { + this.pushContext(); + this.pushString(type); + + // If it's a subexpression, the string result + // will be pushed after this opcode. + if (type !== 'sexpr') { + if (typeof string === 'string') { + this.pushString(string); + } else { + this.pushStackLiteral(string); + } + } + }, + + emptyHash: function() { + this.pushStackLiteral('{}'); + + if (this.trackIds) { + this.push('{}'); // hashIds + } + if (this.stringParams) { + this.push('{}'); // hashContexts + this.push('{}'); // hashTypes + } + }, + pushHash: function() { + if (this.hash) { + this.hashes.push(this.hash); + } + this.hash = {values: [], types: [], contexts: [], ids: []}; + }, + popHash: function() { + var hash = this.hash; + this.hash = this.hashes.pop(); + + if (this.trackIds) { + this.push('{' + hash.ids.join(',') + '}'); + } + if (this.stringParams) { + this.push('{' + hash.contexts.join(',') + '}'); + this.push('{' + hash.types.join(',') + '}'); + } + + this.push('{\n ' + hash.values.join(',\n ') + '\n }'); + }, + + // [pushString] + // + // On stack, before: ... + // On stack, after: quotedString(string), ... + // + // Push a quoted version of `string` onto the stack + pushString: function(string) { + this.pushStackLiteral(this.quotedString(string)); + }, + + // [push] + // + // On stack, before: ... + // On stack, after: expr, ... + // + // Push an expression onto the stack + push: function(expr) { + this.inlineStack.push(expr); + return expr; + }, + + // [pushLiteral] + // + // On stack, before: ... + // On stack, after: value, ... + // + // Pushes a value onto the stack. This operation prevents + // the compiler from creating a temporary variable to hold + // it. + pushLiteral: function(value) { + this.pushStackLiteral(value); + }, + + // [pushProgram] + // + // On stack, before: ... + // On stack, after: program(guid), ... + // + // Push a program expression onto the stack. This takes + // a compile-time guid and converts it into a runtime-accessible + // expression. + pushProgram: function(guid) { + if (guid != null) { + this.pushStackLiteral(this.programExpression(guid)); + } else { + this.pushStackLiteral(null); + } + }, + + // [invokeHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // Pops off the helper's parameters, invokes the helper, + // and pushes the helper's return value onto the stack. + // + // If the helper is not found, `helperMissing` is called. + invokeHelper: function(paramSize, name, isSimple) { + this.aliases.helperMissing = 'helpers.helperMissing'; + + var nonHelper = this.popStack(); + var helper = this.setupHelper(paramSize, name); + + var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing'; + this.push('((' + lookup + ').call(' + helper.callParams + '))'); + }, + + // [invokeKnownHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // This operation is used when the helper is known to exist, + // so a `helperMissing` fallback is not required. + invokeKnownHelper: function(paramSize, name) { + var helper = this.setupHelper(paramSize, name); + this.push(helper.name + ".call(" + helper.callParams + ")"); + }, + + // [invokeAmbiguous] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of disambiguation + // + // This operation is used when an expression like `{{foo}}` + // is provided, but we don't know at compile-time whether it + // is a helper or a path. + // + // This operation emits more code than the other options, + // and can be avoided by passing the `knownHelpers` and + // `knownHelpersOnly` flags at compile-time. + invokeAmbiguous: function(name, helperCall) { + this.aliases.functionType = '"function"'; + this.aliases.helperMissing = 'helpers.helperMissing'; + this.useRegister('helper'); + + var nonHelper = this.popStack(); + + this.emptyHash(); + var helper = this.setupHelper(0, name, helperCall); + + var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper'); + + this.push( + '((helper = (helper = ' + helperName + ' || ' + nonHelper + ') != null ? helper : helperMissing' + + (helper.paramsInit ? '),(' + helper.paramsInit : '') + '),' + + '(typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper))'); + }, + + // [invokePartial] + // + // On stack, before: context, ... + // On stack after: result of partial invocation + // + // This operation pops off a context, invokes a partial with that context, + // and pushes the result of the invocation back. + invokePartial: function(name, indent) { + var params = [this.nameLookup('partials', name, 'partial'), "'" + indent + "'", "'" + name + "'", this.popStack(), this.popStack(), "helpers", "partials"]; + + if (this.options.data) { + params.push("data"); + } else if (this.options.compat) { + params.push('undefined'); + } + if (this.options.compat) { + params.push('depths'); + } + + this.push("this.invokePartial(" + params.join(", ") + ")"); + }, + + // [assignToHash] + // + // On stack, before: value, ..., hash, ... + // On stack, after: ..., hash, ... + // + // Pops a value off the stack and assigns it to the current hash + assignToHash: function(key) { + var value = this.popStack(), + context, + type, + id; + + if (this.trackIds) { + id = this.popStack(); + } + if (this.stringParams) { + type = this.popStack(); + context = this.popStack(); + } + + var hash = this.hash; + if (context) { + hash.contexts.push("'" + key + "': " + context); + } + if (type) { + hash.types.push("'" + key + "': " + type); + } + if (id) { + hash.ids.push("'" + key + "': " + id); + } + hash.values.push("'" + key + "': (" + value + ")"); + }, + + pushId: function(type, name) { + if (type === 'ID' || type === 'DATA') { + this.pushString(name); + } else if (type === 'sexpr') { + this.pushStackLiteral('true'); + } else { + this.pushStackLiteral('null'); + } + }, + + // HELPERS + + compiler: JavaScriptCompiler, + + compileChildren: function(environment, options) { + var children = environment.children, child, compiler; + + for(var i=0, l=children.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } + return this.topStackName(); + }, + topStackName: function() { + return "stack" + this.stackSlot; + }, + flushInline: function() { + var inlineStack = this.inlineStack; + if (inlineStack.length) { + this.inlineStack = []; + for (var i = 0, len = inlineStack.length; i < len; i++) { + var entry = inlineStack[i]; + if (entry instanceof Literal) { + this.compileStack.push(entry); + } else { + this.pushStack(entry); + } + } + } + }, + isInline: function() { + return this.inlineStack.length; + }, + + popStack: function(wrapped) { + var inline = this.isInline(), + item = (inline ? this.inlineStack : this.compileStack).pop(); + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + if (!inline) { + /* istanbul ignore next */ + if (!this.stackSlot) { + throw new Exception('Invalid stack pop'); + } + this.stackSlot--; + } + return item; + } + }, + + topStack: function() { + var stack = (this.isInline() ? this.inlineStack : this.compileStack), + item = stack[stack.length - 1]; + + if (item instanceof Literal) { + return item.value; + } else { + return item; + } + }, + + contextName: function(context) { + if (this.useDepths && context) { + return 'depths[' + context + ']'; + } else { + return 'depth' + context; + } + }, + + quotedString: function(str) { + return '"' + str + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2029/g, '\\u2029') + '"'; + }, + + objectLiteral: function(obj) { + var pairs = []; + + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + pairs.push(this.quotedString(key) + ':' + obj[key]); + } + } + + return '{' + pairs.join(',') + '}'; + }, + + setupHelper: function(paramSize, name, blockHelper) { + var params = [], + paramsInit = this.setupParams(name, paramSize, params, blockHelper); + var foundHelper = this.nameLookup('helpers', name, 'helper'); + + return { + params: params, + paramsInit: paramsInit, + name: foundHelper, + callParams: [this.contextName(0)].concat(params).join(", ") + }; + }, + + setupOptions: function(helper, paramSize, params) { + var options = {}, contexts = [], types = [], ids = [], param, inverse, program; + + options.name = this.quotedString(helper); + options.hash = this.popStack(); + + if (this.trackIds) { + options.hashIds = this.popStack(); + } + if (this.stringParams) { + options.hashTypes = this.popStack(); + options.hashContexts = this.popStack(); + } + + inverse = this.popStack(); + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + if (!program) { + program = 'this.noop'; + } + + if (!inverse) { + inverse = 'this.noop'; + } + + options.fn = program; + options.inverse = inverse; + } + + // The parameters go on to the stack in order (making sure that they are evaluated in order) + // so we need to pop them off the stack in reverse order + var i = paramSize; + while (i--) { + param = this.popStack(); + params[i] = param; + + if (this.trackIds) { + ids[i] = this.popStack(); + } + if (this.stringParams) { + types[i] = this.popStack(); + contexts[i] = this.popStack(); + } + } + + if (this.trackIds) { + options.ids = "[" + ids.join(",") + "]"; + } + if (this.stringParams) { + options.types = "[" + types.join(",") + "]"; + options.contexts = "[" + contexts.join(",") + "]"; + } + + if (this.options.data) { + options.data = "data"; + } + + return options; + }, + + // the params and contexts arguments are passed in arrays + // to fill in + setupParams: function(helperName, paramSize, params, useRegister) { + var options = this.objectLiteral(this.setupOptions(helperName, paramSize, params)); + + if (useRegister) { + this.useRegister('options'); + params.push('options'); + return 'options=' + options; + } else { + params.push(options); + return ''; + } + } + }; + + var reservedWords = ( + "break else new var" + + " case finally return void" + + " catch for switch while" + + " continue function this with" + + " default if throw" + + " delete in try" + + " do instanceof typeof" + + " abstract enum int short" + + " boolean export interface static" + + " byte extends long super" + + " char final native synchronized" + + " class float package throws" + + " const goto private transient" + + " debugger implements protected volatile" + + " double import public let yield" + ).split(" "); + + var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; + + for(var i=0, l=reservedWords.length; ia?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
    ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; +if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
    a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:k.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m(""); +} + +// attach event listeners for initialization +w3c_slidy.set_up(); + +// hide the slides as soon as body element is available +// to reduce annoying screen mess before the onload event +setTimeout(w3c_slidy.hide_slides, 50); + diff --git a/core-java/src/test/resources/docbook-xsl/slides/slidy/scripts/slidy.js.gz b/core-java/src/test/resources/docbook-xsl/slides/slidy/scripts/slidy.js.gz new file mode 100755 index 0000000000000000000000000000000000000000..b1c58e4c9010ebe70ac57183d944ddc2b21efe33 GIT binary patch literal 12874 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/.htaccess b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/.htaccess new file mode 100755 index 000000000000..d395348aeea7 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/.htaccess @@ -0,0 +1,28 @@ +Options +MultiViews +LanguagePriority en +AddLanguage pt-br .pt-br + + + +ForceType 'text/html; charset=utf-8' + + + + + +ForceType 'application/xhtml+xml; charset=utf-8' + + + + + +ForceType 'text/css; charset=utf-8' + + + + + +ForceType 'text/javascript; charset=utf-8' + + +mkdir diff --git a/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/slidy.css b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/slidy.css new file mode 100755 index 000000000000..0197e64d0f37 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/slidy.css @@ -0,0 +1,405 @@ +/* slidy.css + + Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software +*/ +body +{ + margin: 0 0 0 0; + padding: 0 0 0 0; + width: 100%; + height: 100%; + color: black; + background-color: white; + font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif; + font-size: 14pt; +} + +div.toolbar { + position: fixed; z-index: 200; + top: auto; bottom: 0; left: 0; right: 0; + height: 1.2em; text-align: right; + padding-left: 1em; + padding-right: 1em; + font-size: 60%; + color: red; + background-color: rgb(240,240,240); + border-top: solid 1px rgb(180,180,180); +} + +div.toolbar span.copyright { + color: black; + margin-left: 0.5em; +} + +div.initial_prompt { + position: absolute; + z-index: 1000; + bottom: 1.2em; + width: 100%; + background-color: rgb(200,200,200); + opacity: 0.35; + background-color: rgb(200,200,200, 0.35); + cursor: pointer; +} + +div.initial_prompt p.help { + text-align: center; +} + +div.initial_prompt p.close { + text-align: right; + font-style: italic; +} + +div.slidy_toc { + position: absolute; + z-index: 300; + width: 60%; + max-width: 30em; + height: 30em; + overflow: auto; + top: auto; + right: auto; + left: 4em; + bottom: 4em; + padding: 1em; + background: rgb(240,240,240); + border-style: solid; + border-width: 2px; + font-size: 60%; +} + +div.slidy_toc .toc_heading { + text-align: center; + width: 100%; + margin: 0; + margin-bottom: 1em; + border-bottom-style: solid; + border-bottom-color: rgb(180,180,180); + border-bottom-width: 1px; +} + +div.slide { + z-index: 20; + margin: 0 0 0 0; + padding-top: 0; + padding-bottom: 0; + padding-left: 20px; + padding-right: 20px; + border-width: 0; + clear: both; + top: 0; + bottom: 0; + left: 0; + right: 0; + line-height: 120%; + background-color: transparent; +} + +div.background { + display: none; +} + +div.handout { + margin-left: 20px; + margin-right: 20px; +} + +div.slide.titlepage { + text-align: center; +} + +div.slide.titlepage h1 { + padding-top: 10%; + margin-right: 0; +} + +div.slide h1 { + padding-left: 0; + padding-right: 20pt; + padding-top: 4pt; + padding-bottom: 4pt; + margin-top: 0; + margin-left: 0; + margin-right: 60pt; + margin-bottom: 0.5em; + display: block; + font-size: 160%; + line-height: 1.2em; + background: transparent; +} + +div.toc { + position: absolute; + top: auto; + bottom: 4em; + left: 4em; + right: auto; + width: 60%; + max-width: 30em; + height: 30em; + border: solid thin black; + padding: 1em; + background: rgb(240,240,240); + color: black; + z-index: 300; + overflow: auto; + display: block; + visibility: visible; +} + +div.toc-heading { + width: 100%; + border-bottom: solid 1px rgb(180,180,180); + margin-bottom: 1em; + text-align: center; +} + +img { + image-rendering: optimize-quality; +} + +pre { + font-size: 80%; + font-weight: bold; + line-height: 120%; + padding-top: 0.2em; + padding-bottom: 0.2em; + padding-left: 1em; + padding-right: 1em; + border-style: solid; + border-left-width: 1em; + border-top-width: thin; + border-right-width: thin; + border-bottom-width: thin; + border-color: #95ABD0; + color: #00428C; + background-color: #E4E5E7; +} + +li pre { margin-left: 0; } + +blockquote { font-style: italic } + +img { background-color: transparent } + +p.copyright { font-size: smaller } + +.center { text-align: center } +.footnote { font-size: smaller; margin-left: 2em; } + +a img { border-width: 0; border-style: none } + +a:visited { color: navy } +a:link { color: navy } +a:hover { color: red; text-decoration: underline } +a:active { color: red; text-decoration: underline } + +a {text-decoration: none} +.navbar a:link {color: white} +.navbar a:visited {color: yellow} +.navbar a:active {color: red} +.navbar a:hover {color: red} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + +div dt +{ + margin-left: 0; + margin-top: 1em; + margin-bottom: 0.5em; + font-weight: bold; +} +div dd +{ + margin-left: 2em; + margin-bottom: 0.5em; +} + + +p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table { + margin-left: 1em; + margin-right: 1em; +} + +p.subhead { font-weight: bold; margin-top: 2em; } + +.smaller { font-size: smaller } +.bigger { font-size: 130% } + +td,th { padding: 0.2em } + +ul { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ol { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } + +ul li { + list-style: square; + margin: 0.1em 0em 0.6em 0; + padding: 0 0 0 0; + line-height: 140%; +} + +ol li { + margin: 0.1em 0em 0.6em 1.5em; + padding: 0 0 0 0px; + line-height: 140%; + list-style-type: decimal; +} + +li ul li { + font-size: 85%; + font-style: italic; + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} +li li ul li { + font-size: 85%; + font-style: normal; + list-style-type: circle; + background: transparent; + padding: 0 0 0 0; +} +li li li ul li { + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} + +li ol li { + list-style-type: decimal; +} + + +li li ol li { + list-style-type: decimal; +} + +/* + setting class="outline on ol or ul makes it behave as an + ouline list where blocklevel content in li elements is + hidden by default and can be expanded or collapsed with + mouse click. Set class="expand" on li to override default +*/ + +ol.outline li:hover { cursor: pointer } +ol.outline li.nofold:hover { cursor: default } + +ul.outline li:hover { cursor: pointer } +ul.outline li.nofold:hover { cursor: default } + +ol.outline { list-style:decimal; } +ol.outline ol { list-style-type:lower-alpha } + +ol.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em; +} +ol.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em; +} + +ul.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em; +} +ul.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em; +} + +/* for slides with class "title" in table of contents */ +a.titleslide { font-weight: bold; font-style: italic } + +/* + hide images for work around for save as bug + where browsers fail to save images used by CSS +*/ +img.hidden { display: none; visibility: hidden } +div.initial_prompt { display: none; visibility: hidden } + + div.slide { + visibility: visible; + position: inherit; + } + div.handout { + border-top-style: solid; + border-top-width: thin; + border-top-color: black; + } + +@media screen { + .hidden { display: none; visibility: visible } + + div.slide.hidden { display: block; visibility: visible } + div.handout.hidden { display: block; visibility: visible } + div.background { display: none; visibility: hidden } + body.single_slide div.initial_prompt { display: block; visibility: visible } + body.single_slide div.background { display: block; visibility: visible } + body.single_slide div.background.hidden { display: none; visibility: hidden } + body.single_slide .invisible { visibility: hidden } + body.single_slide .hidden { display: none; visibility: hidden } + body.single_slide div.slide { position: absolute } + body.single_slide div.handout { display: none; visibility: hidden } +} + +@media print { + .hidden { display: block; visibility: visible } + + div.slide pre { font-size: 60%; padding-left: 0.5em; } + div.toolbar { display: none; visibility: hidden; } + div.slidy_toc { display: none; visibility: hidden; } + div.background { display: none; visibility: hidden; } + div.slide { page-break-before: always } + /* :first-child isn't reliable for print media */ + div.slide.first-slide { page-break-before: avoid } +} + diff --git a/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/w3c-blue.css b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/w3c-blue.css new file mode 100755 index 000000000000..6c4ff4f85d6a --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/slidy/styles/w3c-blue.css @@ -0,0 +1,497 @@ +/* w3c-blue.css + + Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software +*/ +body +{ + margin: 0 0 0 0; + padding: 0 0 0 0; + width: 100%; + height: 100%; + color: black; + background-color: white; + font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif; + font-size: 14pt; +} + +div.slide.titlepage { + text-align: center; +} + +div.slide.titlepage h1 { + padding-top: 40%; +} + +div.slide { + z-index: 20; + margin: 0 0 0 0; + padding: 0; + border-width: 0; + top: 0; + bottom: 0; + left: 0; + right: 0; + line-height: 120%; + background-color: transparent; +} + +div.background { + z-index: 1; + position: absolute; + vertical-align: bottom; + left: 0; + right: 0; + top: 0; + bottom: auto; + height: 4.1em; + padding: 0 0 0 0.2em; + margin: 0 0 0 0; + border-width: 0; + background-color: #728ec2; +} + +div.background img { + height: 4em; +} + +/* this rule is hidden from IE which doesn't support + selector */ +div.slide + div[class].slide { page-break-before: always;} + +div.slide h1 { + padding-left: 3em; + padding-right: 3em; + padding-top: 0.1em; + margin-bottom: 0.8em; + margin-top: -0.05em; + margin-left: 0; + margin-right: 0; + min-height: 2.3em; + color: white; + height: 2.2em; + font-size: 160%; + line-height: 1.1em; +} + +div.slide h1 a { + color: white; + text-decoration: none; +} + +div.slide h1 a:link { + color: white; + text-decoration: none; +} + +div.slide h1 a:visited { + color: white; + text-decoration: none; +} + +div.slide h1 a:hover { + color: white; + text-decoration: underline; +} + +div.slide h1 a:active { + color: red; + text-decoration: underline; +} + +#head-icon { + margin-top: 0.5em; + margin-bottom: 0; + margin-left: 0; + margin-right: 1em; + background: #728ec2; + border-width: 0; + height: 3em; + max-width: 3em; + z-index: 2; + float: left; +} + +#head-logo { + margin: 0; + margin-top: 0.25em; + padding-top: 0.25em; + padding-bottom: 0.2em; + padding-left: 0; + padding-right: 0; + height: 3.2em; + width: 4.8em; + float: right; + z-index: 2; + background: #728ec2; +} + +#head-logo-fallback { + margin: 0; + padding: 0; + margin-top: -0.8em; + width: 4.8em; + float: right; + z-index: 2; +} + +/* the next two classes support vertical and horizontal centering */ +div.vbox { + float: left; + height: 40%; + width: 50%; + margin-top: -240px; +} +div.hbox { + width:60%; + margin-top: 0; + margin-left:auto; + margin-right:auto; + height: 60%; + border:1px solid silver; + background:#F0F0F0; + overflow:auto; + text-align:left; + clear:both; +} + +/* styling for named background */ +div.background.slanty { + z-index: 2; + bottom: 0; + height: 100%; + background: transparent; +} + +div.background.slanty img { margin-top: 4em; width: 100%; height: 80% } + +/* the following makes the pre background translucent */ +/* opacity is a CSS3 property but supported by Mozilla family */ +/* filter is an IE specific feature that also requires width */ +div.slide.slanty pre { + width: 93%; /* needed for IE filter to work */ + opacity: .8; + filter: alpha(opacity=80); +} + +img.withBorder { + border: 2px solid #c60; + padding: 4px; +} + +li pre { margin-left: 0; } + +@media print { pre { font-size: 60% } } + +blockquote { font-style: italic } + +img { background-color: transparent } + +p.copyright { font-size: smaller } + +.center { text-align: center } +.footnote { font-size: smaller; margin-left: 2em; } + +a img { border-width: 0; border-style: none } + +a:visited { color: navy } +a:link { color: navy } +a:hover { color: red; text-decoration: underline } +a:active { color: red; text-decoration: underline } + +a {text-decoration: none} +.navbar a:link {color: white} +.navbar a:visited {color: yellow} +.navbar a:active {color: red} +.navbar a:hover {color: red} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + +div dt +{ + margin-left: 0; + margin-top: 1em; + margin-bottom: 0.5em; + font-weight: bold; +} +div dd +{ + margin-left: 2em; + margin-bottom: 0.5em; +} + + +p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table { + margin-left: 1em; + margin-right: 1em; +} + +p.subhead { font-weight: bold; margin-top: 2em; } + +div.cover p.explanation { + font-style: italic; + margin-top: 3em; +} + + +.smaller { font-size: smaller } + +td,th { padding: 0.2em } + +ul { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ol { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + + +ul li { + list-style: none; + margin: 0.1em 0em 0.6em 0; + padding: 0 0 0 40px; + background: transparent url(../graphics/bullet.png) no-repeat 5px 0.3em; + line-height: 140%; +} + +/* workaround IE's failure to support background on li for print media */ +@media print { ul li { list-style: disc; padding-left: 0; background: none; } } + +ol li { + margin: 0.1em 0em 0.6em 1.5em; + padding: 0 0 0 0px; + line-height: 140%; +} + +li li { + font-size: 85%; + font-style: italic; + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} +li li li { + font-size: 85%; + font-style: normal; + list-style-type: circle; + background: transparent; + padding: 0 0 0 0; +} +li li li li { + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} + +/* rectangular blue bullet + unfold/nofold/fold widget */ + +/* + setting class="outline on ol or ul makes it behave as an + ouline list where blocklevel content in li elements is + hidden by default and can be expanded or collapsed with + mouse click. Set class="expand" on li to override default +*/ + +ol.outline li:hover { cursor: pointer } +ol.outline li.nofold:hover { cursor: default } + +ul.outline li:hover { cursor: pointer } +ul.outline li.nofold:hover { cursor: default } + +ol.outline { list-style:decimal; } +ol.outline ol { list-style-type:lower-alpha } + +ol.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.3em; +} +ol.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.3em; +} + +ul.outline li.nofold { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-nofold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.unfolded { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-fold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.folded { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-unfold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.unfolded:hover { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-fold.gif) no-repeat 5px 0.3em; +} +ul.outline li.folded:hover { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-unfold.gif) no-repeat 5px 0.3em; +} + +li ul.outline li.nofold { + padding: 0 0 0 21px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.unfolded { + padding: 0 0 0 21px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.folded { + padding: 0 0 0 21px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.unfolded:hover { + padding: 0 0 0 21px; + background: transparent url(../graphics/fold.gif) no-repeat 5px 0.3em; +} +li ul.outline li.folded:hover { + padding: 0 0 0 21px; + background: transparent url(../graphics/unfold.gif) no-repeat 5px 0.3em; +} + +img { + image-rendering: optimize-quality; +} + +img.withBorder { + border: 2px solid #c60; + padding: 4px; +} + +div.header { + position: absolute; + z-index: 2; + left: 0; + right: 0; + top: 0; + bottom: auto; + height: 2.95em; + width: 100%; + padding: 0 0 0 0; + margin: 0 0 0 0; + border-width: 0; + border-style: solid; + background-color: #005A9C; + border-bottom-width: thick; + border-bottom-color: #95ABD0; +} + +div.footer { + position: absolute; + z-index: 80; + left: 0; + right: 0; + top: auto; + bottom: 0; + height: 3.5em; + margin: 0; + font-size: 80%; + font-weight: bold; + padding-left: 1em; + padding-right: 0; + padding-top: 0.3em; + padding-bottom: 0; + color: #003366; + background-color: #95ABD0; +} + +/* this is a hack to hide property from IE6 and below */ +div[class="footer"] { + position: fixed; +} + +#hidden-bullet { + visibility: hidden; + display: none; +} + +div.slide.cover { + color: white; + background-color: #728ec2; + padding-top: 0; + padding-right: 0; + padding-left: 3em; + height: 100%; +} + +div.slide.cover h1 { + margin: 0; + padding: 0.5em; + color: white; + height: auto; +} + +div.slide.cover h2 { + color: white; +} + +div.slide.cover a { + color: white; +} + +div.slide.cover a:visited { color: white } +div.slide.cover a:link { color: white } +div.slide.cover a:hover { color: yellow; text-decoration: underline } +div.slide.cover a:active { color: yellow; text-decoration: underline } + +div.slide.cover a:hover, div.slide.cover a:active { + color: yellow; text-decoration: underline; +} + +div.slide.cover img.cover { + margin: 0 0 0 0; + float: right; + padding-bottom: 4em; + width: 50%; + overflow: hidden; +} + +div.slide.cover a:hover, div.slide.cover a:active { + color: yellow; text-decoration: underline; +} + +/* for Bert as an ardent user of the old W3C slidemaker tool */ + +div.comment { display: none; visibility: hidden } + +@media print { + div.slide h1 { background: transparent; color: black } + div.slide.cover { background: transparent; color: black } + div.slide.cover h1 { background: transparent; color: black } + div.comment { display: block; visibility: visible } +} diff --git a/core-java/src/test/resources/docbook-xsl/slides/tools/dbs3-upgrade.xsl b/core-java/src/test/resources/docbook-xsl/slides/tools/dbs3-upgrade.xsl new file mode 100644 index 000000000000..e757c9781379 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/tools/dbs3-upgrade.xsl @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xml b/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xml new file mode 100644 index 000000000000..1bc7c2ecffbe --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xml @@ -0,0 +1,824 @@ + + + +Slides XHTML Parameter Reference + +$Id$ + + + + Kövesdán + Gábor + + + + 2012 + Gábor Kövesdán + + + This is reference documentation for all user-configurable + parameters in the DocBook XSL Slides XHTML stylesheet. + Note that the Slides stylesheet for XHTML output is a + customization layer of the DocBook XSL XHTML stylesheet. + Therefore, in addition to the slides-specific parameters + listed in this section, you can also use a number of + XHTML stylesheet + parameters to control Slides XHTML output. + + + + XHTML: General Params + + + +disable.collapsible +boolean + + +disable.collapsible +Specifies whether collapsible rendering is enabled + + + + + <xsl:param name="disable.collapsible">0</xsl:param> + + + +Description + +This parameter specifies whether elements marked as + collapsible are generated as such in the output document. + + + + + + +disable.incremental +boolean + + +disable.incremental +Specifies whether incremental rendering is enabled + + + + + <xsl:param name="disable.incremental">0</xsl:param> + + + +Description + +This parameter specifies whether elements marked as + incremental are generated as such in the output document. + + + + + + +generate.copyright +boolean + + +generate.copyright +Specifies whether copyright is generated + + + + + <xsl:param name="generate.copyright">1</xsl:param> + + + +Description + +This parameter specifies whether the copyright info is generated + in the footer area. + + + + + + +generate.foilgroup.numbered.toc +boolean + + +generate.foilgroup.numbered.toc +Specifies whether foilgroups have a numbered TOC + + + + + <xsl:param name="generate.foilgroup.numbered.toc">1</xsl:param> + + + +Description + +If TOC generation is turned on, this parameter specifies + whether foilgroups have a numbered TOC. If disabled, TOC items + will be bulleted, not numbered. + + + + + + +generate.foilgroup.toc +boolean + + +generate.foilgroup.toc +Specifies whether foilgroups have a TOC + + + + + <xsl:param name="generate.foilgroup.toc">1</xsl:param> + + + +Description + +This parameter specifies whether foilgroups will + contain a table of contents of the included foils. + + + + + + +generate.handoutnotes +boolean + + +generate.handoutnotes +Specifies whether handoutnotes are generated + + + + + <xsl:param name="generate.handoutnotes">0</xsl:param> + + + +Description + +This parameter specifies whether handoutnotes shall + be generated to the output. + + + + + + +generate.pubdate +boolean + + +generate.pubdate +Specifies whether the pubdate is generated + + + + + <xsl:param name="generate.pubdate">1</xsl:param> + + + +Description + +This parameter specifies whether the publication date is generated + in the footer area. + + + + + + +generate.speakernotes +boolean + + +generate.speakernotes +Specifies whether speakernotes are generated + + + + + <xsl:param name="generate.speakernotes">0</xsl:param> + + + +Description + +This parameter specifies whether speakernotes shall + be generated to the output. + + + + + + +generate.titlepage +boolean + + +generate.titlepage +Specifies whether titlepage is generated + + + + + <xsl:param name="generate.titlepage">1</xsl:param> + + + +Description + +This parameter specifies whether titlepage is generated + for the presentation. + + + + + + +mml.embedding.mode +list +inline +object +image +link +iframe +embed + + +mml.embedding.mode +Specifies how inline MathML is processed + + + + + <xsl:param name="mml.embedding.mode">inline</xsl:param> + + + +Description + +This parameter specifies how inline MathML formulas + are embedded into the output document. + + + + inline + + Content is copied over inline with its namespace. + + + + object + + Content is extracted into an externel file and referenced + by an object element. + + + + image + + Content is extracted into an externel file and referenced + by an img element. + + + + link + + Content is extracted into an externel file and referenced + by an a element. + + + + iframe + + Content is extracted into an externel file and referenced + by an iframe element. + + + + embed + + Content is extracted into an externel file and referenced + by an embed element. + + + + + + + + + +svg.embedding.mode +list +inline +object +image +link +iframe +embed + + +svg.embedding.mode +Specifies how inline SVG is processed + + + + + <xsl:param name="svg.embedding.mode">object</xsl:param> + + + +Description + +This parameter specifies how inline SVG graphics + are embedded into the output document. + + + + inline + + Content is copied over inline with its namespace. + + + + object + + Content is extracted into an externel file and referenced + by an object element. + + + + image + + Content is extracted into an externel file and referenced + by an img element. + + + + link + + Content is extracted into an externel file and referenced + by an a element. + + + + iframe + + Content is extracted into an externel file and referenced + by an iframe element. + + + + embed + + Content is extracted into an externel file and referenced + by an embed element. + + + + + + + + + +user.css +filename + + +user.css +Specifies the path to user-supplied CSS + + + + + <xsl:param name="user.css">user.css</xsl:param> + + + +Description + +This parameter specifies the path from where the + CSS styling is read. This file can be used to + add additional styling to the slides. + + + + + + +wrap.slidecontent +boolean + + +wrap.slidecontent +Specifies whether the foil content is wrapped into a div + + + + + <xsl:param name="wrap.slidecontent">0</xsl:param> + + + +Description + +This parameter specifies whether the foil content is wrapped into + a div so that additional styling can be applied. + + + + + + + + XHTML: S5 Params + + + +s5.controls +boolean + + +s5.controls +Specifies whether S5 controls are visible + + + + + <xsl:param name="s5.controls">0</xsl:param> + + + +Description + +This parameter specifies whether S5 navigation controls are + visible by default. + + + + + + +s5.defaultview +list +slideshow +outline + + +s5.defaultview +Specifies the default S5 view + + + + + <xsl:param name="s5.defaultview">slideshow</xsl:param> + + + +Description + +This parameter specifies, which is the default view + in the generated S5 presentation. + + + + + + +s5.opera.css +filename + + +s5.opera.css +Specifies the name of the S5 Opera-specific CSS file + + + + + <xsl:param name="s5.opera.css">opera.css</xsl:param> + + + +Description + +This parameter specifies the name of the S5 Opera-specific + CSS file. + + + + + + +s5.outline.css +filename + + +s5.outline.css +Specifies the name of the S5 outline CSS file + + + + + <xsl:param name="s5.outline.css">outline.css</xsl:param> + + + +Description + +This parameter specifies the name of the S5 outline CSS file. + + + + + + +s5.path.prefix +uri + + +s5.path.prefix +Specifies the path to S5 files + + + + + <xsl:param name="s5.path.prefix">files/s5/ui/default/</xsl:param> + + + +Description + +This parameter specifies the path where S5 CSS and + JavaScript files reside. All the CSS and JavaScript paths + will be generated relative to this directory. + + + + + + +s5.print.css +filename + + +s5.print.css +Specifies the name of the S5 print CSS file + + + + + <xsl:param name="s5.print.css">print.css</xsl:param> + + + +Description + +This parameter specifies the name of the S5 print CSS file. + + + + + + +s5.slides.css +filename + + +s5.slides.css +Specifies the name of the S5 slides CSS file + + + + + <xsl:param name="s5.slides.css">slides.css</xsl:param> + + + +Description + +This parameter specifies the name of the S5 slides CSS file. + + + + + + +s5.slides.js +filename + + +s5.slides.js +Specifies the name of the S5 slides JavaScript file + + + + + <xsl:param name="s5.slides.js">slides.js</xsl:param> + + + +Description + +This parameter specifies the name of the S5 slides JavaScript + file. + + + + + + + + XHTML: Slidy Params + + + +slidy.duration +integer + + +slidy.duration +Specifies the duration of the presentation + + + + + <xsl:param name="slidy.duration">0</xsl:param> + + + +Description + +This parameter specifies the duration of the presentation + in minutes. A JavaScript clock will count down to help the + speaker in not running out of time. Can be disabled if set to 0. + + + + + + +slidy.path.prefix +uri + + +slidy.path.prefix +Specifies the path to Slidy files + + + + + <xsl:param name="slidy.path.prefix">files/slidy/</xsl:param> + + + +Description + +This parameter specifies the path where Slidy CSS and + JavaScript files reside. All the CSS and JavaScript paths + will be generated relative to this directory. + + + + + + +slidy.slidy.css +filename + + +slidy.slidy.css +Specifies the name of the main Slidy CSS file + + + + + <xsl:param name="slidy.slidy.css">styles/slidy.css</xsl:param> + + + +Description + +This parameter specifies the name of the main Slidy CSS file. + + + + + + +slidy.slidy.js +filename + + +slidy.slidy.js +Specifies the name of the Slidy JavaScript file + + + + + <xsl:param name="slidy.slidy.js">scripts/slidy.js</xsl:param> + + + +Description + +This parameter specifies the name of the Slidy JavaScript file. + + + + + + +slidy.user.css +filename + + +slidy.user.css +Specifies the name of the Slidy user CSS file + + + + + <xsl:param name="slidy.user.css">styles/w3c-blue.css</xsl:param> + + + +Description + +This parameter specifies the name of the Slidy user CSS file. + + + + + + + +The Stylesheet + +The param.xsl stylesheet is just a wrapper +around all these parameters. + + + +<!-- This file is generated from param.xweb --> + +<xsl:stylesheet exclude-result-prefixes="src" version="1.0"> + +<!-- ******************************************************************** + $Id: param.xweb 6633 2007-02-21 18:33:33Z xmldoc $ + ******************************************************************** + + This file is part of the DocBook Slides Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<src:fragref linkend="disable.collapsible.frag"></src:fragref> +<src:fragref linkend="disable.incremental.frag"></src:fragref> +<src:fragref linkend="generate.copyright.frag"></src:fragref> +<src:fragref linkend="generate.foilgroup.numbered.toc.frag"></src:fragref> +<src:fragref linkend="generate.foilgroup.toc.frag"></src:fragref> +<src:fragref linkend="generate.handoutnotes.frag"></src:fragref> +<src:fragref linkend="generate.pubdate.frag"></src:fragref> +<src:fragref linkend="generate.speakernotes.frag"></src:fragref> +<src:fragref linkend="generate.titlepage.frag"></src:fragref> +<src:fragref linkend="mml.embedding.mode.frag"></src:fragref> +<src:fragref linkend="svg.embedding.mode.frag"></src:fragref> +<src:fragref linkend="user.css.frag"></src:fragref> +<src:fragref linkend="wrap.slidecontent.frag"></src:fragref> + +<src:fragref linkend="s5.controls.frag"></src:fragref> +<src:fragref linkend="s5.defaultview.frag"></src:fragref> +<src:fragref linkend="s5.opera.css.frag"></src:fragref> +<src:fragref linkend="s5.outline.css.frag"></src:fragref> +<src:fragref linkend="s5.path.prefix.frag"></src:fragref> +<src:fragref linkend="s5.print.css.frag"></src:fragref> +<src:fragref linkend="s5.slides.css.frag"></src:fragref> +<src:fragref linkend="s5.slides.js.frag"></src:fragref> + +<src:fragref linkend="slidy.duration.frag"></src:fragref> +<src:fragref linkend="slidy.path.prefix.frag"></src:fragref> +<src:fragref linkend="slidy.slidy.css.frag"></src:fragref> +<src:fragref linkend="slidy.slidy.js.frag"></src:fragref> +<src:fragref linkend="slidy.user.css.frag"></src:fragref> + +</xsl:stylesheet> + + + + diff --git a/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xsl b/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xsl new file mode 100644 index 000000000000..6bd0e5cf8efd --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/xhtml/param.xsl @@ -0,0 +1,71 @@ + + + + + + + 0 + + 0 + + 1 + + 1 + + 1 + + 0 + + 1 + + 0 + + 1 + + inline + + object + + user.css + + 0 + + + 0 + + slideshow + + opera.css + + outline.css + + files/s5/ui/default/ + + print.css + + slides.css + + slides.js + + + 0 + + files/slidy/ + + styles/slidy.css + + scripts/slidy.js + + styles/w3c-blue.css + + + + diff --git a/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xml b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xml new file mode 100644 index 000000000000..fb6569d7b8e1 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xml @@ -0,0 +1,26 @@ + + + + + + <subtitle/> + <corpauthor/> + <authorgroup/> + <author/> + </t:titlepage-content> + + <t:titlepage-content t:side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before t:side="recto"> + </t:titlepage-before> + + <t:titlepage-before t:side="verso"> + </t:titlepage-before> +</t:titlepage> +</t:templates> diff --git a/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xsl b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xsl new file mode 100644 index 000000000000..3af53f4208d8 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain-titlepage.xsl @@ -0,0 +1,140 @@ +<?xml version="1.0"?> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" version="1.0" exclude-result-prefixes="exsl"> + +<!-- This stylesheet was created by template/titlepage.xsl--> + +<xsl:template name="slides.titlepage.recto"> + <xsl:choose> + <xsl:when test="slidesinfo/title"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="slidesinfo/title"/> + </xsl:when> + <xsl:when test="docinfo/title"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="docinfo/title"/> + </xsl:when> + <xsl:when test="info/title"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="info/title"/> + </xsl:when> + <xsl:when test="title"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="title"/> + </xsl:when> + </xsl:choose> + + <xsl:choose> + <xsl:when test="slidesinfo/subtitle"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="slidesinfo/subtitle"/> + </xsl:when> + <xsl:when test="docinfo/subtitle"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="docinfo/subtitle"/> + </xsl:when> + <xsl:when test="info/subtitle"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="info/subtitle"/> + </xsl:when> + <xsl:when test="subtitle"> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="subtitle"/> + </xsl:when> + </xsl:choose> + + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="slidesinfo/corpauthor"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="docinfo/corpauthor"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="info/corpauthor"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="slidesinfo/authorgroup"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="docinfo/authorgroup"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="info/authorgroup"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="slidesinfo/author"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="docinfo/author"/> + <xsl:apply-templates mode="slides.titlepage.recto.auto.mode" select="info/author"/> +</xsl:template> + +<xsl:template name="slides.titlepage.verso"> +</xsl:template> + +<xsl:template name="slides.titlepage.separator"> +</xsl:template> + +<xsl:template name="slides.titlepage.before.recto"> +</xsl:template> + +<xsl:template name="slides.titlepage.before.verso"> +</xsl:template> + +<xsl:template name="slides.titlepage"> + <div class="slide cover title"> + <xsl:variable name="recto.content"> + <xsl:call-template name="slides.titlepage.before.recto"/> + <xsl:call-template name="slides.titlepage.recto"/> + </xsl:variable> + <xsl:variable name="recto.elements.count"> + <xsl:choose> + <xsl:when test="function-available('exsl:node-set')"><xsl:value-of select="count(exsl:node-set($recto.content)/*)"/></xsl:when> + <xsl:when test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')"> + <!--Xalan quirk--><xsl:value-of select="count(exsl:node-set($recto.content)/*)"/></xsl:when> + <xsl:otherwise>1</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:if test="(normalize-space($recto.content) != '') or ($recto.elements.count > 0)"> + <div><xsl:copy-of select="$recto.content"/></div> + </xsl:if> + <xsl:variable name="verso.content"> + <xsl:call-template name="slides.titlepage.before.verso"/> + <xsl:call-template name="slides.titlepage.verso"/> + </xsl:variable> + <xsl:variable name="verso.elements.count"> + <xsl:choose> + <xsl:when test="function-available('exsl:node-set')"><xsl:value-of select="count(exsl:node-set($verso.content)/*)"/></xsl:when> + <xsl:when test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')"> + <!--Xalan quirk--><xsl:value-of select="count(exsl:node-set($verso.content)/*)"/></xsl:when> + <xsl:otherwise>1</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:if test="(normalize-space($verso.content) != '') or ($verso.elements.count > 0)"> + <div><xsl:copy-of select="$verso.content"/></div> + </xsl:if> + <xsl:call-template name="slides.titlepage.separator"/> + </div> +</xsl:template> + +<xsl:template match="*" mode="slides.titlepage.recto.mode"> + <!-- if an element isn't found in this mode, --> + <!-- try the generic titlepage.mode --> + <xsl:apply-templates select="." mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="*" mode="slides.titlepage.verso.mode"> + <!-- if an element isn't found in this mode, --> + <!-- try the generic titlepage.mode --> + <xsl:apply-templates select="." mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="title" mode="slides.titlepage.recto.auto.mode"> +<div xsl:use-attribute-sets="slides.titlepage.recto.style"> +<xsl:apply-templates select="." mode="slides.titlepage.recto.mode"/> +</div> +</xsl:template> + +<xsl:template match="subtitle" mode="slides.titlepage.recto.auto.mode"> +<div xsl:use-attribute-sets="slides.titlepage.recto.style"> +<xsl:apply-templates select="." mode="slides.titlepage.recto.mode"/> +</div> +</xsl:template> + +<xsl:template match="corpauthor" mode="slides.titlepage.recto.auto.mode"> +<div xsl:use-attribute-sets="slides.titlepage.recto.style"> +<xsl:apply-templates select="." mode="slides.titlepage.recto.mode"/> +</div> +</xsl:template> + +<xsl:template match="authorgroup" mode="slides.titlepage.recto.auto.mode"> +<div xsl:use-attribute-sets="slides.titlepage.recto.style"> +<xsl:apply-templates select="." mode="slides.titlepage.recto.mode"/> +</div> +</xsl:template> + +<xsl:template match="author" mode="slides.titlepage.recto.auto.mode"> +<div xsl:use-attribute-sets="slides.titlepage.recto.style"> +<xsl:apply-templates select="." mode="slides.titlepage.recto.mode"/> +</div> +</xsl:template> + +</xsl:stylesheet> + diff --git a/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain.xsl b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain.xsl new file mode 100644 index 000000000000..05d5e5122bd8 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/slides/xhtml/plain.xsl @@ -0,0 +1,535 @@ +<?xml version="1.0" encoding="ASCII"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:db="http://docbook.org/ns/docbook" + xmlns:dbs="http://docbook.org/ns/docbook-slides" + xmlns:exsl="http://exslt.org/common" + exclude-result-prefixes="dbs db xlink" + extension-element-prefixes="exsl" + version="1.0"> + +<xsl:import href="../../xhtml/chunk.xsl"/> +<xsl:import href="../common/common.xsl"/> +<xsl:import href="plain-titlepage.xsl"/> +<xsl:import href="param.xsl"/> + +<xsl:param name="local.l10n.xml" select="document('')"/> +<i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0"> + <l:l10n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" language="en"> + <l:gentext key="Foilgroup" text="Foil Group"/> + <l:gentext key="Foil" text="Foil"/> + <l:gentext key="Speakernotes" text="Speaker Notes"/> + <l:gentext key="Handoutnotes" text="Handout Notes"/> + <l:gentext key="SVGImage" text="SVG image"/> + <l:gentext key="MathMLFormula" text="MathML formula"/> + + <l:context name="title"> + <l:gentext key="foil" text="Foil %n %t"/> + <l:gentext key="foilgroup" text="Foil %n %t"/> + </l:context> + </l:l10n> +</i18n> + +<!-- Overrides from DocBook XSL --> +<xsl:template name="process.qanda.toc"/> + +<!-- Main content starts here --> + +<xsl:template name="xhtml.head"> + <meta name="generator" content="DocBook Slides Stylesheets V{$VERSION}"/> + <link rel="stylesheet" href="{$user.css}" type="text/css"/> +</xsl:template> + +<xsl:template name="slideshow.head"/> + +<xsl:template name="slideshow.content"> + <div class="presentation"> + <xsl:if test="$generate.titlepage != 0"> + <xsl:apply-templates select="/dbs:slides" mode="titlepage"/> + </xsl:if> + + <xsl:apply-templates select="/dbs:slides/dbs:foil|dbs:slides/dbs:foilgroup"/> + </div> +</xsl:template> + +<xsl:template match="/dbs:slides" mode="titlepage"> + <xsl:call-template name="slides.titlepage"/> +</xsl:template> + +<xsl:template name="slide.notes"> + <xsl:if test="($generate.speakernotes != 0) and ./dbs:speakernotes"> + <div class="notes"> + <h2 class="notes"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Speakernotes'"/> + </xsl:call-template> + </h2> + + <xsl:apply-templates select="dbs:speakernotes" mode="notes.mode"/> + </div> + </xsl:if> + + <xsl:if test="($generate.handoutnotes != 0) and ./dbs:handoutnotes"> + <div class="handout"> + <h2 class="handout"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Handoutnotes'"/> + </xsl:call-template> + </h2> + + <xsl:apply-templates select="dbs:handoutnotes" mode="notes.mode"/> + </div> + </xsl:if> +</xsl:template> + +<xsl:template match="/"> + <html> + <xsl:if test="/dbs:slides/@xml:lang"> + <xsl:attribute name="xml:lang"> + <xsl:value-of select="/dbs:slides/@xml:lang"/> + </xsl:attribute> + </xsl:if> + + <head> + <title> + <xsl:call-template name="get.title"> + <xsl:with-param name="ctx" select="/dbs:slides"/> + </xsl:call-template> + + + + + + + + + + + + + + + + + + + +
      + +
    1. +
      +
    +
    + + +
      + +
    • +
      +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + +
    +
    + + + + +
    + + +
    + + +
    + + + +
    + + + + +
    + +
    +
    + + + + +
    + + + + +
    +
    + + + + + + +
    + +
    +
    + + +
    + +
    +
    + + + + + + + 1 + + + + 1 + + + + 1 + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + + + + + +

    +
    +
    + + +

    +
    + + +

    + + +

    +
    +
    + + + + + mailto: + + + <> + + + + + + + + + + + + + + + + + + +
      + +
    +
    + + +
      + +
    +
    + + + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inline + + + + + + + + + + + + + + + + + + + + + + + + + + + + {$mimeType} object + + + + + + + + + + + + ':"");a._keyEvent=!1;return G},_generateMonthYearHeader:function(a,b,c,d,e,g,p,n){var q=this._get(a,"changeMonth"),o=this._get(a,"changeYear"),w=this._get(a,"showMonthAfterYear"),r='
    ',u="";if(g||!q)u+=''+p[b]+"";else{for(var p=d&&d.getFullYear()==c,s=e&&e.getFullYear()==c,u=u+('"}w||(r+=u+(g||!q||!o?" ":""));if(!a.yearshtml)if(a.yearshtml="",g||!o)r+=''+c+"";else{var n=this._get(a,"yearRange").split(":"),z=(new Date).getFullYear(),p=function(a){a= +a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?z+parseInt(a,10):parseInt(a,10);return isNaN(a)?z:a},b=p(n[0]),n=Math.max(b,p(n[1]||"")),b=d?Math.max(b,d.getFullYear()):b,n=e?Math.min(n,e.getFullYear()):n;for(a.yearshtml+='";r+=a.yearshtml;a.yearshtml=null}r+=this._get(a,"yearSuffix");w&&(r+=(g||!q||!o?" ":"")+u);return r+"
    "},_adjustInstDate:function(a,b,c){var d=a.drawYear+("Y"==c?b:0),e=a.drawMonth+("M"==c?b:0),b=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+("D"==c?b:0),d=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,b)));a.selectedDay=d.getDate();a.drawMonth=a.selectedMonth=d.getMonth();a.drawYear=a.selectedYear=d.getFullYear();("M"==c|| +"Y"==c)&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),c=c&&bd?d:c},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return null==a?[1,1]:"number"==typeof a?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a, +b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),c=this._daylightSavingAdjust(new Date(c,d+(0>b?b:e[0]*e[1]),1));0>b&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<= +d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff"),b="string"!=typeof b?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);b=b?"object"==typeof b?b:this._daylightSavingAdjust(new Date(d, +c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});b.fn.datepicker=function(a){if(!this.length)return this;b.datepicker.initialized||(b(document).mousedown(b.datepicker._checkExternalClick).find("body").append(b.datepicker.dpDiv),b.datepicker.initialized=!0);var c=Array.prototype.slice.call(arguments,1);return"string"==typeof a&&("isDisabled"==a||"getDate"==a||"widget"==a)||"option"== +a&&2==arguments.length&&"string"==typeof arguments[1]?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this[0]].concat(c)):this.each(function(){typeof a=="string"?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this].concat(c)):b.datepicker._attachDatepicker(this,a)})};b.datepicker=new c;b.datepicker.initialized=!1;b.datepicker.uuid=(new Date).getTime();b.datepicker.version="1.8.14";window["DP_jQuery_"+h]=b})(jQuery); +(function(b,a){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("
    ").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"); +this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(b){if(b===a)return this._value();this._setOption("value",b);return this},_setOption:function(a,d){"value"===a&&(this.options.value=d,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete"));b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;"number"!==typeof a&&(a=0);return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100* +this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change"));this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.14"})})(jQuery); +jQuery.effects||function(b,a){function c(a){var c;return a&&a.constructor==Array&&3==a.length?a:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(a))?[2.55*parseFloat(c[1]),2.55*parseFloat(c[2]),2.55*parseFloat(c[3])]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))?[parseInt(c[1],16),parseInt(c[2], +16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(a))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:/rgba\(0, 0, 0, 0\)/.exec(a)?i.transparent:i[b.trim(a).toLowerCase()]}function d(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]])for(var e=a.length;e--;)c=a[e],"string"==typeof a[c]&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c]);else for(c in a)"string"=== +typeof a[c]&&(b[c]=a[c]);return b}function g(a){var c,d;for(c in a)d=a[c],(null==d||b.isFunction(d)||c in k||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete a[c];return a}function h(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function e(a,c,d,e){"object"==typeof a&&(e=c,d=null,c=a,a=c.effect);b.isFunction(c)&&(e=c,d=null,c={});if("number"==typeof c||b.fx.speeds[c])e=d,d=c,c={};b.isFunction(d)&&(e=d,d=null);c=c||{};d=d||c.duration;d=b.fx.off?0:"number"==typeof d? +d:d in b.fx.speeds?b.fx.speeds[d]:b.fx.speeds._default;e=e||c.complete;return[a,c,d,e]}function f(a){return!a||("number"===typeof a||b.fx.speeds[a])||"string"===typeof a&&!b.effects[a]?!0:!1}b.effects={};b.each("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor borderColor color outlineColor".split(" "),function(a,d){b.fx.step[d]=function(a){if(!a.colorInit){var e;e=a.elem;var f=d,g;do{g=b.curCSS(e,f);if(g!=""&&g!="transparent"||b.nodeName(e,"body"))break;f="backgroundColor"}while(e= +e.parentNode);e=c(g);a.start=e;a.end=c(a.end);a.colorInit=true}a.elem.style[d]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var i={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139], +darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255], +maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},j=["add","remove","toggle"],k={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};b.effects.animateClass=function(a,c,e,f){b.isFunction(e)&&(f=e,e=null);return this.queue(function(){var i=b(this),o=i.attr("style")|| +" ",k=g(d.call(this)),r,u=i.attr("class");b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});r=g(d.call(this));i.attr("class",u);i.animate(h(k,r),{queue:false,duration:c,easing:e,complete:function(){b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});if(typeof i.attr("style")=="object"){i.attr("style").cssText="";i.attr("style").cssText=o}else i.attr("style",o);f&&f.apply(this,arguments);b.dequeue(this)}})})};b.fn.extend({_addClass:b.fn.addClass,addClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this, +[{add:a},c,d,e]):this._addClass(a)},_removeClass:b.fn.removeClass,removeClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this,[{remove:a},c,d,e]):this._removeClass(a)},_toggleClass:b.fn.toggleClass,toggleClass:function(c,d,e,f,g){return"boolean"==typeof d||d===a?e?b.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):b.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(a,c,d,e,f){return b.effects.animateClass.apply(this,[{add:c, +remove:a},d,e,f])}});b.extend(b.effects,{version:"1.8.14",save:function(a,b){for(var c=0;c").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});a.wrap(d);d=a.parent();"static"==a.css("position")?(d.css({position:"relative"}),a.css({position:"relative"})): +(b.extend(c,{position:a.css("position"),zIndex:a.css("z-index")}),b.each(["top","left","bottom","right"],function(b,d){c[d]=a.css(d);isNaN(parseInt(c[d],10))&&(c[d]="auto")}),a.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"}));return d.css(c).show()},removeWrapper:function(a){return a.parent().is(".ui-effects-wrapper")?a.parent().replaceWith(a):a},setTransition:function(a,c,d,e){e=e||{};b.each(c,function(b,c){unit=a.cssUnit(c);0(b/=e/2)?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},easeInCubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeOutCubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeInOutCubic:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},easeInQuart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c}, +easeOutQuart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeInOutQuart:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b+c:-d/2*((b-=2)*b*b*b-2)+c},easeInQuint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeOutQuint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeInOutQuint:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c},easeInSine:function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c},easeOutSine:function(a,b,c,d,e){return d*Math.sin(b/ +e*(Math.PI/2))+c},easeInOutSine:function(a,b,c,d,e){return-d/2*(Math.cos(Math.PI*b/e)-1)+c},easeInExpo:function(a,b,c,d,e){return 0==b?c:d*Math.pow(2,10*(b/e-1))+c},easeOutExpo:function(a,b,c,d,e){return b==e?c+d:d*(-Math.pow(2,-10*b/e)+1)+c},easeInOutExpo:function(a,b,c,d,e){return 0==b?c:b==e?c+d:1>(b/=e/2)?d/2*Math.pow(2,10*(b-1))+c:d/2*(-Math.pow(2,-10*--b)+2)+c},easeInCirc:function(a,b,c,d,e){return-d*(Math.sqrt(1-(b/=e)*b)-1)+c},easeOutCirc:function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)* +b)+c},easeInOutCirc:function(a,b,c,d,e){return 1>(b/=e/2)?-d/2*(Math.sqrt(1-b*b)-1)+c:d/2*(Math.sqrt(1-(b-=2)*b)+1)+c},easeInElastic:function(a,b,c,d,e){var a=1.70158,f=0,g=d;if(0==b)return c;if(1==(b/=e))return c+d;f||(f=0.3*e);gb?-0.5*g*Math.pow(2,10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+c:0.5*g*Math.pow(2,-10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+d+c},easeInBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return e*(c/=f)*c*((g+1)*c-g)+d},easeOutBack:function(b,c,d,e, +f,g){g==a&&(g=1.70158);return e*((c=c/f-1)*c*((g+1)*c+g)+1)+d},easeInOutBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return 1>(c/=f/2)?e/2*c*c*(((g*=1.525)+1)*c-g)+d:e/2*((c-=2)*c*(((g*=1.525)+1)*c+g)+2)+d},easeInBounce:function(a,c,d,e,f){return e-b.easing.easeOutBounce(a,f-c,0,e,f)+d},easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:b<2/2.75?d*(7.5625*(b-=1.5/2.75)*b+0.75)+c:b<2.5/2.75?d*(7.5625*(b-=2.25/2.75)*b+0.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+0.984375)+c},easeInOutBounce:function(a, +c,d,e,f){return c").css({position:"absolute",visibility:"visible",left:-j*(e/d),top:-i*(f/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:e/d,height:f/c,left:h.left+j*(e/d)+("show"==a.options.mode?(j-Math.floor(d/2))*(e/d):0),top:h.top+i*(f/c)+("show"==a.options.mode?(i-Math.floor(c/2))*(f/c):0),opacity:"show"==a.options.mode?0:1}).animate({left:h.left+j*(e/d)+("show"==a.options.mode?0:(j-Math.floor(d/2))*(e/d)),top:h.top+ +i*(f/c)+("show"==a.options.mode?0:(i-Math.floor(c/2))*(f/c)),opacity:"show"==a.options.mode?1:0},a.duration||500);setTimeout(function(){"show"==a.options.mode?g.css({visibility:"visible"}):g.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(g[0]);g.dequeue();b("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery); +(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.fold=function(a){return this.queue(function(){var c=b(this),d=["position","top","bottom","left","right"],g=b.effects.setMode(c,a.options.mode||"hide"),h=a.options.size||15,e=!!a.options.horizFirst,f=a.duration?a.duration/2:b.fx.speeds._default/2;b.effects.save(c,d);c.show();var i=b.effects.createWrapper(c).css({overflow:"hidden"}),j="show"==g!=e,k=j?["width","height"]:["height","width"],j=j?[i.width(),i.height()]:[i.height(),i.width()],l=/([0-9]+)%/.exec(h);l&&(h=parseInt(l[1], +10)/100*j["hide"==g?0:1]);"show"==g&&i.css(e?{height:0,width:h}:{height:h,width:0});e={};l={};e[k[0]]="show"==g?j[0]:h;l[k[1]]="show"==g?j[1]:0;i.animate(e,f,a.options.easing).animate(l,f,a.options.easing,function(){"hide"==g&&c.hide();b.effects.restore(c,d);b.effects.removeWrapper(c);a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +(function(b){b.effects.highlight=function(a){return this.queue(function(){var c=b(this),d=["backgroundImage","backgroundColor","opacity"],g=b.effects.setMode(c,a.options.mode||"show"),h={backgroundColor:c.css("backgroundColor")};"hide"==g&&(h.opacity=0);b.effects.save(c,d);c.show().css({backgroundImage:"none",backgroundColor:a.options.color||"#ffff99"}).animate(h,{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){g=="hide"&&c.hide();b.effects.restore(c,d);g=="show"&&!b.support.opacity&& +this.style.removeAttribute("filter");a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.pulsate=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"show");times=2*(a.options.times||5)-1;duration=a.duration?a.duration/2:b.fx.speeds._default/2;isVisible=c.is(":visible");animateTo=0;isVisible||(c.css("opacity",0).show(),animateTo=1);("hide"==d&&isVisible||"show"==d&&!isVisible)&×--;for(d=0;d').appendTo(document.body).addClass(a.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(d,a.duration,a.options.easing,function(){h.remove();a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +/* + * jQuery Highlight plugin + * Based on highlight v3 by Johann Burkard + * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html + * Copyright (c) 2009 Bartek Szopka http://bartaz.github.com/sandbox.js/jquery.highlight.html + * Licensed under MIT license. + */ +jQuery.extend({highlight:function(a,c,b,e){if(a.nodeType===3){if(c=a.data.match(c)){b=document.createElement(b||"span");b.className=e||"highlight";a=a.splitText(c.index);a.splitText(c[0].length);e=a.cloneNode(true);b.appendChild(e);a.parentNode.replaceChild(b,a);return 1}}else if(a.nodeType===1&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&!(a.tagName===b.toUpperCase()&&a.className===e))for(var d=0;d').appendTo("body"); + var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight }; + $c.remove(); + window.scrollbarWidth = d.width; + window.scrollbarHeight = d.height; + return dim.match(/^(width|height)$/) ? d[dim] : d; + } + + + /** + * Returns hash container 'display' and 'visibility' + * + * @see $.swap() - swaps CSS, runs callback, resets CSS + */ +, showInvisibly: function ($E, force) { + if (!$E) return {}; + if (!$E.jquery) $E = $($E); + var CSS = { + display: $E.css('display') + , visibility: $E.css('visibility') + }; + if (force || CSS.display === "none") { // only if not *already hidden* + $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured + return CSS; + } + else return {}; + } + + /** + * Returns data for setting size of an element (container or a pane). + * + * @see _create(), onWindowResize() for container, plus others for pane + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc + */ +, getElementDimensions: function ($E) { + var + d = {} // dimensions hash + , x = d.css = {} // CSS hash + , i = {} // TEMP insets + , b, p // TEMP border, padding + , N = $.layout.cssNum + , off = $E.offset() + ; + d.offsetLeft = off.left; + d.offsetTop = off.top; + + $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge + b = x["border" + e] = $.layout.borderWidth($E, e); + p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e); + i[e] = b + p; // total offset of content from outer side + d["inset"+ e] = p; + }); + + d.offsetWidth = $E.innerWidth(); // offsetWidth is used in calc when doing manual resize + d.offsetHeight = $E.innerHeight(); // ditto + d.outerWidth = $E.outerWidth(); + d.outerHeight = $E.outerHeight(); + d.innerWidth = max(0, d.outerWidth - i.Left - i.Right); + d.innerHeight = max(0, d.outerHeight - i.Top - i.Bottom); + + x.width = $E.width(); + x.height = $E.height(); + x.top = N($E,"top",true); + x.bottom = N($E,"bottom",true); + x.left = N($E,"left",true); + x.right = N($E,"right",true); + + //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0; + + return d; + } + +, getElementCSS: function ($E, list) { + var + CSS = {} + , style = $E[0].style + , props = list.split(",") + , sides = "Top,Bottom,Left,Right".split(",") + , attrs = "Color,Style,Width".split(",") + , p, s, a, i, j, k + ; + for (i=0; i < props.length; i++) { + p = props[i]; + if (p.match(/(border|padding|margin)$/)) + for (j=0; j < 4; j++) { + s = sides[j]; + if (p === "border") + for (k=0; k < 3; k++) { + a = attrs[k]; + CSS[p+s+a] = style[p+s+a]; + } + else + CSS[p+s] = style[p+s]; + } + else + CSS[p] = style[p]; + }; + return CSS + } + + /** + * Return the innerWidth for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerWidth of the elem by subtracting padding and borders + */ +, cssWidth: function ($E, outerWidth) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerWidth <= 0) return 0; + + if (!$.support.boxModel) return outerWidth; + + // strip border and padding from outerWidth to get CSS Width + var W = outerWidth + - b($E, "Left") + - b($E, "Right") + - n($E, "paddingLeft") + - n($E, "paddingRight") + ; + + return max(0,W); + } + + /** + * Return the innerHeight for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerHeight of the elem by subtracting padding and borders + */ +, cssHeight: function ($E, outerHeight) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerHeight <= 0) return 0; + + if (!$.support.boxModel) return outerHeight; + + // strip border and padding from outerHeight to get CSS Height + var H = outerHeight + - b($E, "Top") + - b($E, "Bottom") + - n($E, "paddingTop") + - n($E, "paddingBottom") + ; + + return max(0,H); + } + + /** + * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist + * + * @see Called by many methods + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {string} prop The name of the CSS property, eg: top, width, etc. + * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0 + * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width) + */ +, cssNum: function ($E, prop, allowAuto) { + if (!$E.jquery) $E = $($E); + var CSS = $.layout.showInvisibly($E) + , p = $.curCSS($E[0], prop, true) + , v = allowAuto && p=="auto" ? p : (parseInt(p, 10) || 0); + $E.css( CSS ); // RESET + return v; + } + +, borderWidth: function (el, side) { + if (el.jquery) el = el[0]; + var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left + return $.curCSS(el, b+"Style", true) === "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0); + } + + /** + * Mouse-tracking utility - FUTURE REFERENCE + * + * init: if (!window.mouse) { + * window.mouse = { x: 0, y: 0 }; + * $(document).mousemove( $.layout.trackMouse ); + * } + * + * @param {Object} evt + * +, trackMouse: function (evt) { + window.mouse = { x: evt.clientX, y: evt.clientY }; + } + */ + + /** + * SUBROUTINE for preventPrematureSlideClose option + * + * @param {Object} evt + * @param {Object=} el + */ +, isMouseOverElem: function (evt, el) { + var + $E = $(el || this) + , d = $E.offset() + , T = d.top + , L = d.left + , R = L + $E.outerWidth() + , B = T + $E.outerHeight() + , x = evt.pageX // evt.clientX ? + , y = evt.pageY // evt.clientY ? + ; + // if X & Y are < 0, probably means is over an open SELECT + return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B)); + } + + /** + * Message/Logging Utility + * + * @example $.layout.msg("My message"); // log text + * @example $.layout.msg("My message", true); // alert text + * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title + * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR- + * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data + * + * @param {(Object|string)} info String message OR Hash/Array + * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped + * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped + * @param {Object=} [debutOpts={}] Extra options for debug output + */ +, msg: function (info, popup, debugTitle, debugOpts) { + if ($.isPlainObject(info) && window.debugData) { + if (typeof popup === "string") { + debugOpts = debugTitle; + debugTitle = popup; + } + else if (typeof debugTitle === "object") { + debugOpts = debugTitle; + debugTitle = null; + } + var t = debugTitle || "log( )" + , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts); + if (popup === true || o.display) + debugData( info, t, o ); + else if (window.console) + console.log(debugData( info, t, o )); + } + else if (popup) + alert(info); + else if (window.console) + console.log(info); + else { + var id = "#layoutLogger" + , $l = $(id); + if (!$l.length) + $l = createLog(); + $l.children("ul").append('
  • '+ info.replace(/\/g,">") +'
  • '); + } + + function createLog () { + var pos = $.support.fixedPosition ? 'fixed' : 'absolute' + , $e = $('
    ' + + '
    ' + + 'XLayout console.log
    ' + + '
      ' + + '
      ' + ).appendTo("body"); + $e.css('left', $(window).width() - $e.outerWidth() - 5) + if ($.ui.draggable) $e.draggable({ handle: ':first-child' }); + return $e; + }; + } + +}; + +var lang = $.layout.language; // alias used in defaults... + +// DEFAULT OPTIONS - CHANGE IF DESIRED +$.layout.defaults = { +/* + * LAYOUT & LAYOUT-CONTAINER OPTIONS + * - none of these options are applicable to individual panes + */ + name: "" // Not required, but useful for buttons and used for the state-cookie +, containerSelector: "" // ONLY used when specifying a childOptions - to find container-element that is NOT directly-nested +, containerClass: "ui-layout-container" // layout-container element +, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark) +, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event +, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky +, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized +, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific +, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific +, onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements +, onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized +, onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload +, onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload +, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them +, initPanes: true // false = DO NOT initialize the panes onLoad - will init later +, showErrorMessages: true // enables fatal error messages to warn developers of common errors +, showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code! +// Changing this zIndex value will cause other zIndex values to automatically change +, zIndex: null // the PANE zIndex - resizers and masks will be +1 +// DO NOT CHANGE the zIndex values below unless you clearly understand their relationships +, zIndexes: { // set _default_ z-index values here... + pane_normal: 0 // normal z-index for panes + , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing + , resizer_normal: 2 // normal z-index for resizer-bars + , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open' + , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer + , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged' + } +/* + * PANE DEFAULT SETTINGS + * - settings under the 'panes' key become the default settings for *all panes* + * - ALL pane-options can also be set specifically for each panes, which will override these 'default values' + */ +, panes: { // default options for 'all panes' - will be overridden by 'per-pane settings' + applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity + , closable: true // pane can open & close + , resizable: true // when open, pane can be resized + , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out + , initClosed: false // true = init pane as 'closed' + , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing + // SELECTORS + //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane + , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane! + , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content' + , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector) + // GENERIC ROOT-CLASSES - for auto-generated classNames + , paneClass: "ui-layout-pane" // Layout Pane + , resizerClass: "ui-layout-resizer" // Resizer Bar + , togglerClass: "ui-layout-toggler" // Toggler Button + , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin' + // ELEMENT SIZE & SPACING + //, size: 100 // MUST be pane-specific -initial size of pane + , minSize: 0 // when manually resizing a pane + , maxSize: 0 // ditto, 0 = no limit + , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open' + , spacing_closed: 6 // ditto - when pane is 'closed' + , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides + , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden' + , togglerAlign_open: "center" // top/left, bottom/right, center, OR... + , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right + , togglerTip_open: lang.Close // Toggler tool-tip (title) + , togglerTip_closed: lang.Open // ditto + , togglerContent_open: "" // text or HTML to put INSIDE the toggler + , togglerContent_closed: "" // ditto + // RESIZING OPTIONS + , resizerDblClickToggle: true // + , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes + , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed + , resizerDragOpacity: 1 // option for ui.draggable + //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar + , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES + , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask + , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes + , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20] + , livePaneResizing: false // true = LIVE Resizing as resizer is dragged + , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged + , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance + // TIPS & MESSAGES - also see lang object + , noRoomToOpenTip: lang.noRoomToOpenTip + , resizerTip: lang.Resize // Resizer tool-tip (title) + , sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed + , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding' + , slideTrigger_open: "click" // click, dblclick, mouseenter + , slideTrigger_close: "mouseleave"// click, mouseleave + , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open + , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!) + , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show? + , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening + , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + // HOT-KEYS & MISC + , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver + , enableCursorHotkey: true // enabled 'cursor' hotkeys + //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character + , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT' + // PANE ANIMATION + // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed + , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size' + , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration + , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 } + , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation + , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called + /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set: + fxName_open: "slide" // 'Open' pane animation + fnName_close: "slide" // 'Close' pane animation + fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true + fxSpeed_open: null + fxSpeed_close: null + fxSpeed_size: null + fxSettings_open: {} + fxSettings_close: {} + fxSettings_size: {} + */ + // CHILD/NESTED LAYOUTS + , childOptions: null // Layout-options for nested/child layout - even {} is valid as options + , initChildLayout: true // true = child layout will be created as soon as _this_ layout completes initialization + , destroyChildLayout: true // true = destroy child-layout if this pane is destroyed + , resizeChildLayout: true // true = trigger child-layout.resizeAll() when this pane is resized + // PANE CALLBACKS + , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes + , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true + , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start + , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end + , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start + , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end + , onopen_start: null // CALLBACK when pane STARTS to Open + , onopen_end: null // CALLBACK when pane ENDS being Opened + , onclose_start: null // CALLBACK when pane STARTS to Close + , onclose_end: null // CALLBACK when pane ENDS being Closed + , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON*** + , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON*** + , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS + , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS + , onswap_start: null // CALLBACK when pane STARTS to Swap + , onswap_end: null // CALLBACK when pane ENDS being Swapped + , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized + , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized + } +/* + * PANE-SPECIFIC SETTINGS + * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes' + * - all options under the 'panes' key can also be set specifically for any pane + * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane + */ +, north: { + paneSelector: ".ui-layout-north" + , size: "auto" // eg: "auto", "30%", .30, 200 + , resizerCursor: "n-resize" // custom = url(myCursor.cur) + , customHotkey: "" // EITHER a charCode (43) OR a character ("o") + } +, south: { + paneSelector: ".ui-layout-south" + , size: "auto" + , resizerCursor: "s-resize" + , customHotkey: "" + } +, east: { + paneSelector: ".ui-layout-east" + , size: 200 + , resizerCursor: "e-resize" + , customHotkey: "" + } +, west: { + paneSelector: ".ui-layout-west" + , size: 200 + , resizerCursor: "w-resize" + , customHotkey: "" + } +, center: { + paneSelector: ".ui-layout-center" + , minWidth: 0 + , minHeight: 0 + } +}; + +$.layout.optionsMap = { + // layout/global options - NOT pane-options + layout: ("stateManagement,effects,zIndexes," + + "name,zIndex,scrollToBookmarkOnLoad,showErrorMessages," + + "resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay," + + "onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons").split(",") +// borderPanes: [ ALL options that are NOT specified as 'layout' ] + // default.panes options that apply to the center-pane (most options apply _only_ to border-panes) +, center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad," + + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing," + + "childOptions,initChildLayout,resizeChildLayout,destroyChildLayout," + + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",") + // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key +, noDefault: ("paneSelector,resizerCursor,customHotkey").split(",") +}; + +/** + * Processes options passed in converts flat-format data into subkey (JSON) format + * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName + * Plugins may also call this method so they can transform their own data + * + * @param {!Object} hash Data/options passed by user - may be a single level or nested levels + * @return {Object} Returns hash of minWidth & minHeight + */ +$.layout.transformData = function (hash) { + var json = { panes: {}, center: {} } // init return object + , data, branch, optKey, keys, key, val, i, c; + + if (typeof hash !== "object") return json; // no options passed + + // convert all 'flat-keys' to 'sub-key' format + for (optKey in hash) { + branch = json; + data = $.layout.optionsMap.layout; + val = hash[ optKey ]; + keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration + c = keys.length - 1; + // convert underscore-delimited to subkeys + for (i=0; i <= c; i++) { + key = keys[i]; + if (i === c) + branch[key] = val; + else if (!branch[key]) + branch[key] = {}; // create the subkey + // recurse to sub-key for next loop - if not done + branch = branch[key]; + } + } + + return json; +} + +// INTERNAL CONFIG DATA - DO NOT CHANGE THIS! +$.layout.backwardCompatibility = { + // data used by renameOldOptions() + map: { + // OLD Option Name: NEW Option Name + applyDefaultStyles: "applyDemoStyles" + , resizeNestedLayout: "resizeChildLayout" + , resizeWhileDragging: "livePaneResizing" + , resizeContentWhileDragging: "liveContentResizing" + , triggerEventsWhileDragging: "triggerEventsDuringLiveResize" + , maskIframesOnResize: "maskContents" + , useStateCookie: "stateManagement.enabled" + , "cookie.autoLoad": "stateManagement.autoLoad" + , "cookie.autoSave": "stateManagement.autoSave" + , "cookie.keys": "stateManagement.stateKeys" + , "cookie.name": "stateManagement.cookie.name" + , "cookie.domain": "stateManagement.cookie.domain" + , "cookie.path": "stateManagement.cookie.path" + , "cookie.expires": "stateManagement.cookie.expires" + , "cookie.secure": "stateManagement.cookie.secure" + } + /** + * @param {Object} opts + */ +, renameOptions: function (opts) { + var map = $.layout.backwardCompatibility.map + , oldData, newData, value + ; + for (var itemPath in map) { + oldData = getBranch( itemPath ); + value = oldData.branch[ oldData.key ] + if (value !== undefined) { + newData = getBranch( map[itemPath], true ) + newData.branch[ newData.key ] = value; + delete oldData.branch[ oldData.key ]; + } + } + + /** + * @param {string} path + * @param {boolean=} [create=false] Create path if does not exist + */ + function getBranch (path, create) { + var a = path.split(".") // split keys into array + , c = a.length - 1 + , D = { branch: opts, key: a[c] } // init branch at top & set key (last item) + , i = 0, k, undef; + for (; i 0) { + if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + // make hidden, then visible to 'refresh' display after animation + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerHeight + * @param {boolean=} [autoHide=false] + */ +, setOuterHeight = function (el, outerHeight, autoHide) { + var $E = el, h; + if (isStr(el)) $E = $Ps[el]; // west + else if (!el.jquery) $E = $(el); + h = cssH($E, outerHeight); + $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent + if (h > 0 && $E.innerWidth() > 0) { + if (autoHide && $E.data('autoHidden')) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerSize + * @param {boolean=} [autoHide=false] + */ +, setOuterSize = function (el, outerSize, autoHide) { + if (_c[pane].dir=="horz") // pane = north or south + setOuterHeight(el, outerSize, autoHide); + else // pane = east or west + setOuterWidth(el, outerSize, autoHide); + } + + + /** + * Converts any 'size' params to a pixel/integer size, if not already + * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated + * + /** + * @param {string} pane + * @param {(string|number)=} size + * @param {string=} [dir] + * @return {number} + */ +, _parseSize = function (pane, size, dir) { + if (!dir) dir = _c[pane].dir; + + if (isStr(size) && size.match(/%/)) + size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal + + if (size === 0) + return 0; + else if (size >= 1) + return parseInt(size, 10); + + var o = options, avail = 0; + if (dir=="horz") // north or south or center.minHeight + avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0); + else if (dir=="vert") // east or west or center.minWidth + avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0); + + if (size === -1) // -1 == 100% + return avail; + else if (size > 0) // percentage, eg: .25 + return round(avail * size); + else if (pane=="center") + return 0; + else { // size < 0 || size=='auto' || size==Missing || size==Invalid + // auto-size the pane + var dim = (dir === "horz" ? "height" : "width") + , $P = $Ps[pane] + , $C = dim === 'height' ? $Cs[pane] : false + , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden + , szP = $P.css(dim) // SAVE current pane size + , szC = $C ? $C.css(dim) : 0 // SAVE current content size + ; + $P.css(dim, "auto"); + if ($C) $C.css(dim, "auto"); + size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE + $P.css(dim, szP).css(vis); // RESET size & visibility + if ($C) $C.css(dim, szC); + return size; + } + } + + /** + * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added + * + * @param {(string|!Object)} pane + * @param {boolean=} [inclSpace=false] + * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser + */ +, getPaneSize = function (pane, inclSpace) { + var + $P = $Ps[pane] + , o = options[pane] + , s = state[pane] + , oSp = (inclSpace ? o.spacing_open : 0) + , cSp = (inclSpace ? o.spacing_closed : 0) + ; + if (!$P || s.isHidden) + return 0; + else if (s.isClosed || (s.isSliding && inclSpace)) + return cSp; + else if (_c[pane].dir === "horz") + return $P.outerHeight() + oSp; + else // dir === "vert" + return $P.outerWidth() + oSp; + } + + /** + * Calculate min/max pane dimensions and limits for resizing + * + * @param {string} pane + * @param {boolean=} [slide=false] + */ +, setSizeLimits = function (pane, slide) { + if (!isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , dir = c.dir + , side = c.side.toLowerCase() + , type = c.sizeType.toLowerCase() + , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param + , $P = $Ps[pane] + , paneSpacing = o.spacing_open + // measure the pane on the *opposite side* from this pane + , altPane = _c.oppositeEdge[pane] + , altS = state[altPane] + , $altP = $Ps[altPane] + , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth())) + , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0) + // limitSize prevents this pane from 'overlapping' opposite pane + , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth) + , minCenterDims = cssMinDims("center") + , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth) + // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them + , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing))) + , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize ) + , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize ) + , r = s.resizerPosition = {} // used to set resizing limits + , top = sC.insetTop + , left = sC.insetLeft + , W = sC.innerWidth + , H = sC.innerHeight + , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east + ; + switch (pane) { + case "north": r.min = top + minSize; + r.max = top + maxSize; + break; + case "west": r.min = left + minSize; + r.max = left + maxSize; + break; + case "south": r.min = top + H - maxSize - rW; + r.max = top + H - minSize - rW; + break; + case "east": r.min = left + W - maxSize - rW; + r.max = left + W - minSize - rW; + break; + }; + } + + /** + * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes + * + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height + */ +, calcNewCenterPaneDims = function () { + var d = { + top: getPaneSize("north", true) // true = include 'spacing' value for pane + , bottom: getPaneSize("south", true) + , left: getPaneSize("west", true) + , right: getPaneSize("east", true) + , width: 0 + , height: 0 + }; + + // NOTE: sC = state.container + // calc center-pane outer dimensions + d.width = sC.innerWidth - d.left - d.right; // outerWidth + d.height = sC.innerHeight - d.bottom - d.top; // outerHeight + // add the 'container border/padding' to get final positions relative to the container + d.top += sC.insetTop; + d.bottom += sC.insetBottom; + d.left += sC.insetLeft; + d.right += sC.insetRight; + + return d; + } + + + /** + * @param {!Object} el + * @param {boolean=} [allStates=false] + */ +, getHoverClasses = function (el, allStates) { + var + $El = $(el) + , type = $El.data("layoutRole") + , pane = $El.data("layoutEdge") + , o = options[pane] + , root = o[type +"Class"] + , _pane = "-"+ pane // eg: "-west" + , _open = "-open" + , _closed = "-closed" + , _slide = "-sliding" + , _hover = "-hover " // NOTE the trailing space + , _state = $El.hasClass(root+_closed) ? _closed : _open + , _alt = _state === _closed ? _open : _closed + , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover) + ; + if (allStates) // when 'removing' classes, also remove alternate-state classes + classes += (root+_alt+_hover) + (root+_pane+_alt+_hover); + + if (type=="resizer" && $El.hasClass(root+_slide)) + classes += (root+_slide+_hover) + (root+_pane+_slide+_hover); + + return $.trim(classes); + } +, addHover = function (evt, el) { + var $E = $(el || this); + if (evt && $E.data("layoutRole") === "toggler") + evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar + $E.addClass( getHoverClasses($E) ); + } +, removeHover = function (evt, el) { + var $E = $(el || this); + $E.removeClass( getHoverClasses($E, true) ); + } + +, onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter + if ($.fn.disableSelection) + $("body").disableSelection(); + } +, onResizerLeave = function (evt, el) { + var + e = el || this // el is only passed when called by the timer + , pane = $(e).data("layoutEdge") + , name = pane +"ResizerLeave" + ; + timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set + timer.clear(name); // cancel enableSelection timer - may re/set below + // this method calls itself on a timer because it needs to allow + // enough time for dragging to kick-in and set the isResizing flag + // dragging has a 100ms delay set, so this delay must be >100 + if (!el) // 1st call - mouseleave event + timer.set(name, function(){ onResizerLeave(evt, e); }, 200); + // if user is resizing, then dragStop will enableSelection(), so can skip it here + else if (!state[pane].isResizing && $.fn.enableSelection) // 2nd call - by timer + $("body").enableSelection(); + } + +/* + * ########################### + * INITIALIZATION METHODS + * ########################### + */ + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see none - triggered onInit + * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort + */ +, _create = function () { + // initialize config/options + initOptions(); + var o = options; + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // init plugins for this layout, if there are any (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onCreate ); + + // options & state have been initialized, so now run beforeLoad callback + // onload will CANCEL layout creation if it returns false + if (false === _runCallbacks("onload_start")) + return 'cancel'; + + // initialize the container element + _initContainer(); + + // bind hotkey function - keyDown - if required + initHotkeys(); + + // bind window.onunload + $(window).bind("unload."+ sID, unload); + + // init plugins for this layout, if there are any (eg: customButtons) + runPluginCallbacks( Instance, $.layout.onLoad ); + + // if layout elements are hidden, then layout WILL NOT complete initialization! + // initLayoutElements will set initialized=true and run the onload callback IF successful + if (o.initPanes) _initLayoutElements(); + + delete state.creatingLayout; + + return state.initialized; + } + + /** + * Initialize the layout IF not already + * + * @see All methods in Instance run this test + * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet) + */ +, isInitialized = function () { + if (state.initialized || state.creatingLayout) return true; // already initialized + else return _initLayoutElements(); // try to init panes NOW + } + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see _create() & isInitialized + * @return An object pointer to the instance created + */ +, _initLayoutElements = function (retry) { + // initialize config/options + var o = options; + + // CANNOT init panes inside a hidden container! + if (!$N.is(":visible")) { + // handle Chrome bug where popup window 'has no height' + // if layout is BODY element, try again in 50ms + // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html + if ( !retry && browser.webkit && $N[0].tagName === "BODY" ) + setTimeout(function(){ _initLayoutElements(true); }, 50); + return false; + } + + // a center pane is required, so make sure it exists + if (!getPane("center").length) { + if (options.showErrorMessages) + _log( lang.errCenterPaneMissing, true ); + return false; + } + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // update Container dims + $.extend(sC, elDims( $N )); + + // initialize all layout elements + initPanes(); // size & position panes - calls initHandles() - which calls initResizable() + + if (o.scrollToBookmarkOnLoad) { + var l = self.location; + if (l.hash) l.replace( l.hash ); // scrollTo Bookmark + } + + // check to see if this layout 'nested' inside a pane + if (Instance.hasParentLayout) + o.resizeWithWindow = false; + // bind resizeAll() for 'this layout instance' to window.resize event + else if (o.resizeWithWindow) + $(window).bind("resize."+ sID, windowResize); + + delete state.creatingLayout; + state.initialized = true; + + // init plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onReady ); + + // now run the onload callback, if exists + _runCallbacks("onload_end"); + + return true; // elements initialized successfully + } + + /** + * Initialize nested layouts - called when _initLayoutElements completes + * + * NOT CURRENTLY USED + * + * @see _initLayoutElements + * @return An object pointer to the instance created + */ +, _initChildLayouts = function () { + $.each(_c.allPanes, function (idx, pane) { + if (options[pane].initChildLayout) + createChildLayout( pane ); + }); + } + + /** + * Initialize nested layouts for a specific pane - can optionally pass layout-options + * + * @see _initChildLayouts + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].childOptions + * @return An object pointer to the layout instance created - or null + */ +, createChildLayout = function (evt_or_pane, opts) { + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , C = children + ; + if ($P) { + var $C = $Cs[pane] + , o = opts || options[pane].childOptions + , d = "layout" + // determine which element is supposed to be the 'child container' + // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane + , $Cont = o.containerSelector ? $P.find( o.containerSelector ) : ($C || $P) + , containerFound = $Cont.length + // see if a child-layout ALREADY exists on this element + , child = containerFound ? (C[pane] = $Cont.data(d) || null) : null + ; + // if no layout exists, but childOptions are set, try to create the layout now + if (!child && containerFound && o) + child = C[pane] = $Cont.eq(0).layout(o) || null; + if (child) + child.hasParentLayout = true; // set parent-flag in child + } + Instance[pane].child = C[pane]; // ALWAYS set pane-object pointer, even if null + } + +, windowResize = function () { + var delay = Number(options.resizeWithWindowDelay); + if (delay < 10) delay = 100; // MUST have a delay! + // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway + timer.clear("winResize"); // if already running + timer.set("winResize", function(){ + timer.clear("winResize"); + timer.clear("winResizeRepeater"); + var dims = elDims( $N ); + // only trigger resizeAll() if container has changed size + if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight) + resizeAll(); + }, delay); + // ALSO set fixed-delay timer, if not already running + if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater(); + } + +, setWindowResizeRepeater = function () { + var delay = Number(options.resizeWithWindowMaxDelay); + if (delay > 0) + timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay); + } + +, unload = function () { + var o = options; + + _runCallbacks("onunload_start"); + + // trigger plugin callabacks for this layout (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onUnload ); + + _runCallbacks("onunload_end"); + } + + /** + * Validate and initialize container CSS and events + * + * @see _create() + */ +, _initContainer = function () { + var + N = $N[0] + , tag = sC.tagName = N.tagName + , id = sC.id = N.id + , cls = sC.className = N.className + , o = options + , name = o.name + , fullPage= (tag === "BODY") + , props = "overflow,position,margin,padding,border" + , css = "layoutCSS" + , CSS = {} + , hid = "hidden" // used A LOT! + // see if this container is a 'pane' inside an outer-layout + , parent = $N.data("parentLayout") // parent-layout Instance + , pane = $N.data("layoutEdge") // pane-name in parent-layout + , isChild = parent && pane + ; + // sC -> state.container + sC.selector = $N.selector.split(".slice")[0]; + sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages + + $N .data({ + layout: Instance + , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID + }) + .addClass(o.containerClass) + ; + var layoutMethods = { + destroy: '' + , initPanes: '' + , resizeAll: 'resizeAll' + , resize: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in layoutMethods) { + $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]); + } + + // if this container is another layout's 'pane', then set child/parent pointers + if (isChild) { + // update parent flag + Instance.hasParentLayout = true; + // set pointers to THIS child-layout (Instance) in parent-layout + // NOTE: parent.PANE.child is an ALIAS to parent.children.PANE + parent[pane].child = parent.children[pane] = $N.data("layout"); + } + + // SAVE original container CSS for use in destroy() + if (!$N.data(css)) { + // handle props like overflow different for BODY & HTML - has 'system default' values + if (fullPage) { + CSS = $.extend( elCSS($N, props), { + height: $N.css("height") + , overflow: $N.css("overflow") + , overflowX: $N.css("overflowX") + , overflowY: $N.css("overflowY") + }); + // ALSO SAVE CSS + var $H = $("html"); + $H.data(css, { + height: "auto" // FF would return a fixed px-size! + , overflow: $H.css("overflow") + , overflowX: $H.css("overflowX") + , overflowY: $H.css("overflowY") + }); + } + else // handle props normally for non-body elements + CSS = elCSS($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"); + + $N.data(css, CSS); + } + + try { // format html/body if this is a full page layout + if (fullPage) { + $("html").css({ + height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + }); + $("body").css({ + position: "relative" + , height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + , margin: 0 + , padding: 0 // TODO: test whether body-padding could be handled? + , border: "none" // a body-border creates problems because it cannot be measured! + }); + + // set current layout-container dimensions + $.extend(sC, elDims( $N )); + } + else { // set required CSS for overflow and position + // ENSURE container will not 'scroll' + CSS = { overflow: hid, overflowX: hid, overflowY: hid } + var + p = $N.css("position") + , h = $N.css("height") + ; + // if this is a NESTED layout, then container/outer-pane ALREADY has position and height + if (!isChild) { + if (!p || !p.match(/fixed|absolute|relative/)) + CSS.position = "relative"; // container MUST have a 'position' + /* + if (!h || h=="auto") + CSS.height = "100%"; // container MUST have a 'height' + */ + } + $N.css( CSS ); + + // set current layout-container dimensions + if ( $N.is(":visible") ) { + $.extend(sC, elDims( $N )); + if (o.showErrorMessages && sC.innerHeight < 1) + _log( lang.errContainerHeight.replace(/CONTAINER/, sC.ref), true ); + } + } + } catch (ex) {} + } + + /** + * Bind layout hotkeys - if options enabled + * + * @see _create() and addPane() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHotkeys = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + // bind keyDown to capture hotkeys, if option enabled for ANY pane + $.each(panes, function (i, pane) { + var o = options[pane]; + if (o.enableCursorHotkey || o.customHotkey) { + $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE + return false; // BREAK - binding was done + } + }); + } + + /** + * Build final OPTIONS data + * + * @see _create() + */ +, initOptions = function () { + var data, d, pane, key, val, i, c, o; + + // reprocess user's layout-options to have correct options sub-key structure + opts = $.layout.transformData( opts ); // panes = default subkey + + // auto-rename old options for backward compatibility + opts = $.layout.backwardCompatibility.renameAllOptions( opts ); + + // if user-options has 'panes' key (pane-defaults), process it... + if (!$.isEmptyObject(opts.panes)) { + // REMOVE any pane-defaults that MUST be set per-pane + data = $.layout.optionsMap.noDefault; + for (i=0, c=data.length; i 0) { + z.pane_normal = zo; + z.content_mask = max(zo+1, z.content_mask); // MIN = +1 + z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2 + } + + function createFxOptions ( pane ) { + var o = options[pane] + , d = options.panes; + // ensure fxSettings key to avoid errors + if (!o.fxSettings) o.fxSettings = {}; + if (!d.fxSettings) d.fxSettings = {}; + + $.each(["_open","_close","_size"], function (i,n) { + var + sName = "fxName"+ n + , sSpeed = "fxSpeed"+ n + , sSettings = "fxSettings"+ n + // recalculate fxName according to specificity rules + , fxName = o[sName] = + o[sName] // options.west.fxName_open + || d[sName] // options.panes.fxName_open + || o.fxName // options.west.fxName + || d.fxName // options.panes.fxName + || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0 + ; + // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects + if (fxName === "none" || !$.effects || !$.effects[fxName] || !options.effects[fxName]) + fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName + + // set vars for effects subkeys to simplify logic + var fx = options.effects[fxName] || {} // effects.slide + , fx_all = fx.all || null // effects.slide.all + , fx_pane = fx[pane] || null // effects.slide.west + ; + // create fxSpeed[_open|_close|_size] + o[sSpeed] = + o[sSpeed] // options.west.fxSpeed_open + || d[sSpeed] // options.west.fxSpeed_open + || o.fxSpeed // options.west.fxSpeed + || d.fxSpeed // options.panes.fxSpeed + || null // DEFAULT - let fxSetting.duration control speed + ; + // create fxSettings[_open|_close|_size] + o[sSettings] = $.extend( + {} + , fx_all // effects.slide.all + , fx_pane // effects.slide.west + , d.fxSettings // options.panes.fxSettings + , o.fxSettings // options.west.fxSettings + , d[sSettings] // options.panes.fxSettings_open + , o[sSettings] // options.west.fxSettings_open + ); + }); + + // DONE creating action-specific-settings for this pane, + // so DELETE generic options - are no longer meaningful + delete o.fxName; + delete o.fxSpeed; + delete o.fxSettings; + } + + // DELETE 'panes' key now that we are done - values were copied to EACH pane + delete options.panes; + } + + /** + * Initialize module objects, styling, size and position for all panes + * + * @see _initElements() + * @param {string} pane The pane to process + */ +, getPane = function (pane) { + var sel = options[pane].paneSelector + if (sel.substr(0,1)==="#") // ID selector + // NOTE: elements selected 'by ID' DO NOT have to be 'children' + return $N.find(sel).eq(0); + else { // class or other selector + var $P = $N.children(sel).eq(0); + // look for the pane nested inside a 'form' element + return $P.length ? $P : $N.children("form:first").children(sel).eq(0); + } + } + +, initPanes = function () { + // NOTE: do north & south FIRST so we can measure their height - do center LAST + $.each(_c.allPanes, function (idx, pane) { + addPane( pane, true ); + }); + + // init the pane-handles NOW in case we have to hide or close the pane below + initHandles(); + + // now that all panes have been initialized and initially-sized, + // make sure there is really enough space available for each pane + $.each(_c.borderPanes, function (i, pane) { + if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN + setSizeLimits(pane); + makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit() + } + }); + // size center-pane AGAIN in case we 'closed' a border-pane in loop above + sizeMidPanes("center"); + + // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing! + // Before RC30.3, there was a 10ms delay here, but that caused layout + // to load asynchrously, which is BAD, so try skipping delay for now + + // process pane contents and callbacks, and init/resize child-layout if exists + $.each(_c.allPanes, function (i, pane) { + var o = options[pane]; + if ($Ps[pane]) { + if (state[pane].isVisible) { // pane is OPEN + sizeContent(pane); + // trigger pane.onResize if triggerEventsOnLoad = true + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); + } + // init childLayout - even if pane is not visible + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + }); + } + + /** + * Add a pane to the layout - subroutine of initPanes() + * + * @see initPanes() + * @param {string} pane The pane to process + * @param {boolean=} [force=false] Size content after init + */ +, addPane = function (pane, force) { + if (!force && !isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , fx = s.fx + , dir = c.dir + , spacing = o.spacing_open || 0 + , isCenter = (pane === "center") + , CSS = {} + , $P = $Ps[pane] + , size, minSize, maxSize + ; + // if pane-pointer already exists, remove the old one first + if ($P) + removePane( pane, false, true, false ); + else + $Cs[pane] = false; // init + + $P = $Ps[pane] = getPane(pane); + if (!$P.length) { + $Ps[pane] = false; // logic + return; + } + + // SAVE original Pane CSS + if (!$P.data("layoutCSS")) { + var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border"; + $P.data("layoutCSS", elCSS($P, props)); + } + + // create alias for pane data in Instance - initHandles will add more + Instance[pane] = { name: pane, pane: $Ps[pane], content: $Cs[pane], options: options[pane], state: state[pane], child: children[pane] }; + + // add classes, attributes & events + $P .data({ + parentLayout: Instance // pointer to Layout Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "pane" + }) + .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal) + .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles + .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector' + .bind("mouseenter."+ sID, addHover ) + .bind("mouseleave."+ sID, removeHover ) + ; + var paneMethods = { + hide: '' + , show: '' + , toggle: '' + , close: '' + , open: '' + , slideOpen: '' + , slideClose: '' + , slideToggle: '' + , size: 'manualSizePane' + , sizePane: 'manualSizePane' + , sizeContent: '' + , sizeHandles: '' + , enableClosable: '' + , disableClosable: '' + , enableSlideable: '' + , disableSlideable: '' + , enableResizable: '' + , disableResizable: '' + , swapPanes: 'swapPanes' + , swap: 'swapPanes' + , move: 'swapPanes' + , removePane: 'removePane' + , remove: 'removePane' + , createChildLayout: '' + , resizeChildLayout: '' + , resizeAll: 'resizeAll' + , resizeLayout: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in paneMethods) { + $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]); + } + + // see if this pane has a 'scrolling-content element' + initContent(pane, false); // false = do NOT sizeContent() - called later + + if (!isCenter) { + // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden) + // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size' + size = s.size = _parseSize(pane, o.size); + minSize = _parseSize(pane,o.minSize) || 1; + maxSize = _parseSize(pane,o.maxSize) || 100000; + if (size > 0) size = max(min(size, maxSize), minSize); + + // state for border-panes + s.isClosed = false; // true = pane is closed + s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes + s.isResizing= false; // true = pane is in process of being resized + s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible! + + // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close + if (!s.pins) s.pins = []; + } + // states common to ALL panes + s.tagName = $P[0].tagName; + s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going) + s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically + s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic + + // set css-position to account for container borders & padding + switch (pane) { + case "north": CSS.top = sC.insetTop; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "south": CSS.bottom = sC.insetBottom; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes() + break; + case "east": CSS.right = sC.insetRight; // ditto + break; + case "center": // top, left, width & height set by sizeMidPanes() + } + + if (dir === "horz") // north or south pane + CSS.height = cssH($P, size); + else if (dir === "vert") // east or west pane + CSS.width = cssW($P, size); + //else if (isCenter) {} + + $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes + if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback + + // close or hide the pane if specified in settings + if (o.initClosed && o.closable && !o.initHidden) + close(pane, true, true); // true, true = force, noAnimation + else if (o.initHidden || o.initClosed) + hide(pane); // will be completely invisible - no resizer or spacing + else if (!s.noRoom) + // make the pane visible - in case was initially hidden + $P.css("display","block"); + // ELSE setAsOpen() - called later by initHandles() + + // RESET visibility now - pane will appear IF display:block + $P.css("visibility","visible"); + + // check option for auto-handling of pop-ups & drop-downs + if (o.showOverflowOnHover) + $P.hover( allowOverflow, resetOverflow ); + + // if manually adding a pane AFTER layout initialization, then... + if (state.initialized) { + initHandles( pane ); + initHotkeys( pane ); + resizeAll(); // will sizeContent if pane is visible + if (s.isVisible) { // pane is OPEN + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); // a previously existing childLayout + } + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + } + + /** + * Initialize module objects, styling, size and position for all resize bars and toggler buttons + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHandles = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + + // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV + $.each(panes, function (i, pane) { + var $P = $Ps[pane]; + $Rs[pane] = false; // INIT + $Ts[pane] = false; + if (!$P) return; // pane does not exist - skip + + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , rClass = o.resizerClass + , tClass = o.togglerClass + , side = c.side.toLowerCase() + , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed) + , _pane = "-"+ pane // used for classNames + , _state = (s.isVisible ? "-open" : "-closed") // used for classNames + , I = Instance[pane] + // INIT RESIZER BAR + , $R = I.resizer = $Rs[pane] = $("
      ") + // INIT TOGGLER BUTTON + , $T = I.toggler = (o.closable ? $Ts[pane] = $("
      ") : false) + ; + + //if (s.isVisible && o.resizable) ... handled by initResizable + if (!s.isVisible && o.slidable) + $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor); + + $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "resizer" + }) + .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal) + .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles + .addClass(rClass +" "+ rClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead + .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter + .appendTo($N) // append DIV to container + ; + + if ($T) { + $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "toggler" + }) + .css(_c.togglers.cssReq) // add base/required styles + .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles + .addClass(tClass +" "+ tClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead + .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer + .appendTo($R) // append SPAN to resizer DIV + ; + // ADD INNER-SPANS TO TOGGLER + if (o.togglerContent_open) // ui-layout-open + $(""+ o.togglerContent_open +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .data("layoutRole", "togglerContent") + .data("layoutEdge", pane) + .addClass("content content-open") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead! + ; + if (o.togglerContent_closed) // ui-layout-closed + $(""+ o.togglerContent_closed +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .addClass("content content-closed") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead! + ; + // ADD TOGGLER.click/.hover + enableClosable(pane); + } + + // add Draggable events + initResizable(pane); + + // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open" + if (s.isVisible) + setAsOpen(pane); // onOpen will be called, but NOT onResize + else { + setAsClosed(pane); // onClose will be called + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + }); + + // SET ALL HANDLE DIMENSIONS + sizeHandles(); + } + + + /** + * Initialize scrolling ui-layout-content div - if exists + * + * @see initPane() - or externally after an Ajax injection + * @param {string} [pane] The pane to process + * @param {boolean=} [resize=true] Size content after init + */ +, initContent = function (pane, resize) { + if (!isInitialized()) return; + var + o = options[pane] + , sel = o.contentSelector + , I = Instance[pane] + , $P = $Ps[pane] + , $C + ; + if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent) + ? $P.find(sel).eq(0) // match 1-element only + : $P.children(sel).eq(0) + ; + if ($C && $C.length) { + $C.data("layoutRole", "content"); + // SAVE original Pane CSS + if (!$C.data("layoutCSS")) + $C.data("layoutCSS", elCSS($C, "height")); + $C.css( _c.content.cssReq ); + if (o.applyDemoStyles) { + $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div + $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane + } + state[pane].content = {}; // init content state + if (resize !== false) sizeContent(pane); + // sizeContent() is called AFTER init of all elements + } + else + I.content = $Cs[pane] = false; + } + + + /** + * Add resize-bars to all panes that specify it in options + * -dependancy: $.fn.resizable - will skip if not found + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initResizable = function (panes) { + var draggingAvailable = $.layout.plugins.draggable + , side // set in start() + ; + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (idx, pane) { + var o = options[pane]; + if (!draggingAvailable || !$Ps[pane] || !o.resizable) { + o.resizable = false; + return true; // skip to next + } + + var s = state[pane] + , z = options.zIndexes + , c = _c[pane] + , side = c.dir=="horz" ? "top" : "left" + , opEdge = _c.oppositeEdge[pane] + , masks = pane +",center,"+ opEdge + (c.dir=="horz" ? ",west,east" : "") + , $P = $Ps[pane] + , $R = $Rs[pane] + , base = o.resizerClass + , lastPos = 0 // used when live-resizing + , r, live // set in start because may change + // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process + , resizerClass = base+"-drag" // resizer-drag + , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag + // 'helper' class is applied to the CLONED resizer-bar while it is being dragged + , helperClass = base+"-dragging" // resizer-dragging + , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging + , helperLimitClass = base+"-dragging-limit" // resizer-drag + , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag + , helperClassesSet = false // logic var + ; + + if (!s.isClosed) + $R.attr("title", o.resizerTip) + .css("cursor", o.resizerCursor); // n-resize, s-resize, etc + + $R.draggable({ + containment: $N[0] // limit resizing to layout container + , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis + , delay: 0 + , distance: 1 + , grid: o.resizingGrid + // basic format for helper - style it using class: .ui-draggable-dragging + , helper: "clone" + , opacity: o.resizerDragOpacity + , addClasses: false // avoid ui-state-disabled class when disabled + //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed + , zIndex: z.resizer_drag + + , start: function (e, ui) { + // REFRESH options & state pointers in case we used swapPanes + o = options[pane]; + s = state[pane]; + // re-read options + live = o.livePaneResizing; + + // ondrag_start callback - will CANCEL hide if returns false + // TODO: dragging CANNOT be cancelled like this, so see if there is a way? + if (false === _runCallbacks("ondrag_start", pane)) return false; + + s.isResizing = true; // prevent pane from closing while resizing + timer.clear(pane+"_closeSlider"); // just in case already triggered + + // SET RESIZER LIMITS - used in drag() + setSizeLimits(pane); // update pane/resizer state + r = s.resizerPosition; + lastPos = ui.position[ side ] + + $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes + helperClassesSet = false; // reset logic var - see drag() + + // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver) + $('body').disableSelection(); + + // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS + showMasks( masks ); + } + + , drag: function (e, ui) { + if (!helperClassesSet) { // can only add classes after clone has been added to the DOM + //$(".ui-draggable-dragging") + ui.helper + .addClass( helperClass +" "+ helperPaneClass ) // add helper classes + .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue + .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar + ; + helperClassesSet = true; + // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane! + if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding); + } + // CONTAIN RESIZER-BAR TO RESIZING LIMITS + var limit = 0; + if (ui.position[side] < r.min) { + ui.position[side] = r.min; + limit = -1; + } + else if (ui.position[side] > r.max) { + ui.position[side] = r.max; + limit = 1; + } + // ADD/REMOVE dragging-limit CLASS + if (limit) { + ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit + window.defaultStatus = (limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? lang.maxSizeWarning : lang.minSizeWarning; + } + else { + ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit + window.defaultStatus = ""; + } + // DYNAMICALLY RESIZE PANES IF OPTION ENABLED + // won't trigger unless resizer has actually moved! + if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) { + lastPos = ui.position[side]; + resizePanes(e, ui, pane) + } + } + + , stop: function (e, ui) { + $('body').enableSelection(); // RE-ENABLE TEXT SELECTION + window.defaultStatus = ""; // clear 'resizing limit' message from statusbar + $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer + s.isResizing = false; + resizePanes(e, ui, pane, true, masks); // true = resizingDone + } + + }); + }); + + /** + * resizePanes + * + * Sub-routine called from stop() - and drag() if livePaneResizing + * + * @param {!Object} evt + * @param {!Object} ui + * @param {string} pane + * @param {boolean=} [resizingDone=false] + */ + var resizePanes = function (evt, ui, pane, resizingDone, masks) { + var dragPos = ui.position + , c = _c[pane] + , o = options[pane] + , s = state[pane] + , resizerPos + ; + switch (pane) { + case "north": resizerPos = dragPos.top; break; + case "west": resizerPos = dragPos.left; break; + case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break; + case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break; + }; + // remove container margin from resizer position to get the pane size + var newSize = resizerPos - sC["inset"+ c.side]; + + // Disable OR Resize Mask(s) created in drag.start + if (!resizingDone) { + // ensure we meet liveResizingTolerance criteria + if (Math.abs(newSize - s.size) < o.liveResizingTolerance) + return; // SKIP resize this time + // resize the pane + manualSizePane(pane, newSize, false, true); // true = noAnimation + sizeMasks(); // resize all visible masks + } + else { // resizingDone + // ondrag_end callback + if (false !== _runCallbacks("ondrag_end", pane)) + manualSizePane(pane, newSize, false, true); // true = noAnimation + hideMasks(); // hide all masks, which include panes with 'content/iframe-masks' + if (s.isSliding && masks) // RE-SHOW only 'object-masks' so objects won't show through sliding pane + showMasks( masks, true ); // true = onlyForObjects + } + }; + } + + /** + * sizeMask + * + * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane + * Called when mask created, and during livePaneResizing + */ +, sizeMask = function () { + var $M = $(this) + , pane = $M.data("layoutMask") // eg: "west" + , s = state[pane] + ; + // only masks over an IFRAME-pane need manual resizing + if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes + $M.css({ + top: s.offsetTop + , left: s.offsetLeft + , width: s.outerWidth + , height: s.outerHeight + }); + /* ALT Method... + var $P = $Ps[pane]; + $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight }); + */ + } +, sizeMasks = function () { + $Ms.each( sizeMask ); // resize all 'visible' masks + } + +, showMasks = function (panes, onlyForObjects) { + var a = panes ? panes.split(",") : $.layout.config.allPanes + , z = options.zIndexes + , o, s; + $.each(a, function(i,p){ + s = state[p]; + o = options[p]; + if (s.isVisible && ( (!onlyForObjects && o.maskContents) || o.maskObjects )) { + getMasks(p).each(function(){ + sizeMask.call(this); + this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1 + this.style.display = "block"; + }); + } + }); + } + +, hideMasks = function () { + // ensure no pane is resizing - could be a timing issue + var skip; + $.each( $.layout.config.borderPanes, function(i,p){ + if (state[p].isResizing) { + skip = true; + return false; // BREAK + } + }); + if (!skip) + $Ms.hide(); // hide ALL masks + } + +, getMasks = function (pane) { + var $Masks = $([]) + , $M, i = 0, c = $Ms.length + ; + for (; i CSS + if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET CSS + $N.css( $N.data(css) ).removeData(css); + + // trigger plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onDestroy ); + + // trigger state-management and onunload callback + unload(); + + // clear the Instance of everything except for container & options (so could recreate) + // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options ); + for (n in Instance) + if (!n.match(/^(container|options)$/)) delete Instance[ n ]; + // add a 'destroyed' flag to make it easy to check + Instance.destroyed = true; + + // if this is a child layout, CLEAR the child-pointer in the parent + /* for now the pointer REMAINS, but with only container, options and destroyed keys + if (parentPane) { + var layout = parentPane.pane.data("parentLayout"); + parentPane.child = layout.children[ parentPane.name ] = null; + } + */ + + return Instance; // for coding convenience + } + + /** + * Remove a pane from the layout - subroutine of destroy() + * + * @see destroy() + * @param {string} pane The pane to process + * @param {boolean=} [remove=false] Remove the DOM element? + * @param {boolean=} [skipResize=false] Skip calling resizeAll()? + */ +, removePane = function (evt_or_pane, remove, skipResize, destroyChild) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $C = $Cs[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + ; + //alert( '$P.length = '+ $P.length ); + // NOTE: elements can still exist even after remove() + // so check for missing data(), which is cleared by removed() + if ($P && $.isEmptyObject( $P.data() )) $P = false; + if ($C && $.isEmptyObject( $C.data() )) $C = false; + if ($R && $.isEmptyObject( $R.data() )) $R = false; + if ($T && $.isEmptyObject( $T.data() )) $T = false; + + if ($P) $P.stop(true, true); + + // check for a child layout + var o = options[pane] + , s = state[pane] + , d = "layout" + , css = "layoutCSS" + , child = children[pane] || ($P ? $P.data(d) : 0) || ($C ? $C.data(d) : 0) || null + , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildLayout + ; + + // FIRST destroy the child-layout(s) + if (destroy && child && !child.destroyed) { + child.destroy(true); // tell child-layout to destroy ALL its child-layouts too + if (child.destroyed) // destroy was successful + child = null; // clear pointer for logic below + } + + if ($P && remove && !child) + $P.remove(); + else if ($P && $P[0]) { + // create list of ALL pane-classes that need to be removed + var root = o.paneClass // default="ui-layout-pane" + , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west" + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes + pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes + ; + $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes + // remove all Layout classes from pane-element + $P .removeClass( classes.join(" ") ) // remove ALL pane-classes + .removeData("parentLayout") + .removeData("layoutPane") + .removeData("layoutRole") + .removeData("layoutEdge") + .removeData("autoHidden") // in case set + .unbind("."+ sID) // remove ALL Layout events + // TODO: remove these extra unbind commands when jQuery is fixed + //.unbind("mouseenter"+ sID) + //.unbind("mouseleave"+ sID) + ; + // do NOT reset CSS if this pane/content is STILL the container of a nested layout! + // the nested layout will reset its 'container' CSS when/if it is destroyed + if ($C && $C.data(d)) { + // a content-div may not have a specific width, so give it one to contain the Layout + $C.width( $C.width() ); + child.resizeAll(); // now resize the Layout + } + else if ($C) + $C.css( $C.data(css) ).removeData(css).removeData("layoutRole"); + // remove pane AFTER content in case there was a nested layout + if (!$P.data(d)) + $P.css( $P.data(css) ).removeData(css); + } + + // REMOVE pane resizer and toggler elements + if ($T) $T.remove(); + if ($R) $R.remove(); + + // CLEAR all pointers and state data + Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = children[pane] = false; + s = { removed: true }; + + if (!skipResize) + resizeAll(); + } + + +/* + * ########################### + * ACTION METHODS + * ########################### + */ + +, _hidePane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , s = $P[0].style + ; + if (o.useOffscreenClose) { + if (!$P.data(_c.offscreenReset)) + $P.data(_c.offscreenReset, { left: s.left, right: s.right }); + $P.css( _c.offscreenCSS ); + } + else + $P.hide().removeData(_c.offscreenReset); + } + +, _showPane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , off = _c.offscreenCSS + , old = $P.data(_c.offscreenReset) + , s = $P[0].style + ; + $P .show() // ALWAYS show, just in case + .removeData(_c.offscreenReset); + if (o.useOffscreenClose && old) { + if (s.left == off.left) + s.left = old.left; + if (s.right == off.right) + s.right = old.right; + } + } + + + /** + * Completely 'hides' a pane, including its spacing - as if it does not exist + * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it + * + * @param {string} pane The pane being hidden, ie: north, south, east, or west + * @param {boolean=} [noAnimation=false] + */ +, hide = function (evt_or_pane, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || s.isHidden) return; // pane does not exist OR is already hidden + + // onhide_start callback - will CANCEL hide if returns false + if (state.initialized && false === _runCallbacks("onhide_start", pane)) return; + + s.isSliding = false; // just in case + + // now hide the elements + if ($R) $R.hide(); // hide resizer-bar + if (!state.initialized || s.isClosed) { + s.isClosed = true; // to trigger open-animation on show() + s.isHidden = true; + s.isVisible = false; + if (!state.initialized) + _hidePane(pane); // no animation when loading page + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center"); + if (state.initialized || o.triggerEventsOnLoad) + _runCallbacks("onhide_end", pane); + } + else { + s.isHiding = true; // used by onclose + close(pane, false, noAnimation); // adjust all panes to fit + } + } + + /** + * Show a hidden pane - show as 'closed' by default unless openPane = true + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [openPane=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, show = function (evt_or_pane, openPane, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden + + // onshow_start callback - will CANCEL show if returns false + if (false === _runCallbacks("onshow_start", pane)) return; + + s.isSliding = false; // just in case + s.isShowing = true; // used by onopen/onclose + //s.isHidden = false; - will be set by open/close - if not cancelled + + // now show the elements + //if ($R) $R.show(); - will be shown by open/close + if (openPane === false) + close(pane, true); // true = force + else + open(pane, false, noAnimation, noAlert); // adjust all panes to fit + } + + + /** + * Toggles a pane open/closed by calling either open or close + * + * @param {string} pane The pane being toggled, ie: north, south, east, or west + * @param {boolean=} [slide=false] + */ +, toggle = function (evt_or_pane, slide) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + ; + if (evt) // called from to $R.dblclick OR triggerPaneEvent + evt.stopImmediatePropagation(); + if (s.isHidden) + show(pane); // will call 'open' after unhiding it + else if (s.isClosed) + open(pane, !!slide); + else + close(pane); + } + + + /** + * Utility method used during init or other auto-processes + * + * @param {string} pane The pane being closed + * @param {boolean=} [setHandles=false] + */ +, _closePane = function (pane, setHandles) { + var + $P = $Ps[pane] + , s = state[pane] + ; + _hidePane(pane); + s.isClosed = true; + s.isVisible = false; + // UNUSED: if (setHandles) setAsClosed(pane, true); // true = force + } + + /** + * Close the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being closed, ie: north, south, east, or west + * @param {boolean=} [force=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [skipCallback=false] + */ +, close = function (evt_or_pane, force, noAnimation, skipCallback) { + var pane = evtPane.call(this, evt_or_pane); + // if pane has been initialized, but NOT the complete layout, close pane instantly + if (!state.initialized && $Ps[pane]) { + _closePane(pane); // INIT pane as closed + return; + } + if (!isInitialized()) return; + + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing, isHiding, wasSliding; + + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ??? + || (!force && s.isClosed && !s.isShowing) // already closed + ) return queueNext(); + + // onclose_start callback - will CANCEL hide if returns false + // SKIP if just 'showing' a hidden pane as 'closed' + var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane); + + // transfer logic vars to temp vars + isShowing = s.isShowing; + isHiding = s.isHiding; + wasSliding = s.isSliding; + // now clear the logic vars (REQUIRED before aborting) + delete s.isShowing; + delete s.isHiding; + + if (abort) return queueNext(); + + doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none"); + s.isMoving = true; + s.isClosed = true; + s.isVisible = false; + // update isHidden BEFORE sizing panes + if (isHiding) s.isHidden = true; + else if (isShowing) s.isHidden = false; + + if (s.isSliding) // pane is being closed, so UNBIND trigger events + bindStopSlidingEvents(pane, false); // will set isSliding=false + else // resize panes adjacent to this one + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback + + // if this pane has a resizer bar, move it NOW - before animation + setAsClosed(pane); + + // CLOSE THE PANE + if (doFX) { // animate the close + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () { + lockPaneForFX(pane, false); // undo + if (s.isClosed) close_2(); + queueNext(); + }); + } + else { // hide the pane without animation + _hidePane(pane); + close_2(); + queueNext(); + }; + }); + + // SUBROUTINE + function close_2 () { + s.isMoving = false; + bindStartSlidingEvent(pane, true); // will enable if o.slidable = true + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane ); + } + + // hide any masks shown while closing + hideMasks(); + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) { + // onclose callback - UNLESS just 'showing' a hidden pane as 'closed' + if (!isShowing) _runCallbacks("onclose_end", pane); + // onhide OR onshow callback + if (isShowing) _runCallbacks("onshow_end", pane); + if (isHiding) _runCallbacks("onhide_end", pane); + } + } + } + + /** + * @param {string} pane The pane just closed, ie: north, south, east, or west + */ +, setAsClosed = function (pane) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + ; + $R + .css(side, sC[inset]) // move the resizer + .removeClass( rClass+_open +" "+ rClass+_pane+_open ) + .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + .addClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .unbind("dblclick."+ sID) + ; + // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent? + if (o.resizable && $.layout.plugins.draggable) + $R + .draggable("disable") + .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here + .css("cursor", "default") + .attr("title","") + ; + + // if pane has a toggler button, adjust that too + if ($T) { + $T + .removeClass( tClass+_open +" "+ tClass+_pane+_open ) + .addClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .attr("title", o.togglerTip_closed) // may be blank + ; + // toggler-content - if exists + $T.children(".content-open").hide(); + $T.children(".content-closed").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, false); + + if (state.initialized) { + // resize 'length' and position togglers for adjacent panes + sizeHandles(); + } + } + + /** + * Open the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [slide=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, open = function (evt_or_pane, slide, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.resizable && !o.closable && !s.isShowing) // invalid request + || (s.isVisible && !s.isSliding) // already open + ) return queueNext(); + + // pane can ALSO be unhidden by just calling show(), so handle this scenario + if (s.isHidden && !s.isShowing) { + queueNext(); // call before show() because it needs the queue free + show(pane, true); + return; + } + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else + // make sure there is enough space available to open the pane + setSizeLimits(pane, slide); + + // onopen_start callback - will CANCEL open if returns false + var cbReturn = _runCallbacks("onopen_start", pane); + + if (cbReturn === "abort") + return queueNext(); + + // update pane-state again in case options were changed in onopen_start + if (cbReturn !== "NC") // NC = "No Callback" + setSizeLimits(pane, slide); + + if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN! + syncPinBtns(pane, false); // make sure pin-buttons are reset + if (!noAlert && o.noRoomToOpenTip) + alert(o.noRoomToOpenTip); + return queueNext(); // ABORT + } + + if (slide) // START Sliding - will set isSliding=true + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead + bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false + else if (o.slidable) + bindStartSlidingEvent(pane, false); // UNBIND trigger events + + s.noRoom = false; // will be reset by makePaneFit if 'noRoom' + makePaneFit(pane); + + // transfer logic var to temp var + isShowing = s.isShowing; + // now clear the logic var + delete s.isShowing; + + doFX = !noAnimation && s.isClosed && (o.fxName_open != "none"); + s.isMoving = true; + s.isVisible = true; + s.isClosed = false; + // update isHidden BEFORE sizing panes - WHY??? Old? + if (isShowing) s.isHidden = false; + + if (doFX) { // ANIMATE + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + if (s.isSliding) masks += ","+ _c.oppositeEdge[pane]; + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() { + lockPaneForFX(pane, false); // undo + if (s.isVisible) open_2(); // continue + queueNext(); + }); + } + else { // no animation + _showPane(pane);// just show pane and... + open_2(); // continue + queueNext(); + }; + }); + + // SUBROUTINE + function open_2 () { + s.isMoving = false; + + // cure iframe display issues + _fixIframe(pane); + + // NOTE: if isSliding, then other panes are NOT 'resized' + if (!s.isSliding) { // resize all panes adjacent to this one + hideMasks(); // remove any masks shown while opening + sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback + } + + // set classes, position handles and execute callbacks... + setAsOpen(pane); + }; + + } + + /** + * @param {string} pane The pane just opened, ie: north, south, east, or west + * @param {boolean=} [skipCallback=false] + */ +, setAsOpen = function (pane, skipCallback) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _closed = "-closed" + , _sliding= "-sliding" + ; + $R + .css(side, sC[inset] + getPaneSize(pane)) // move the resizer + .removeClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .addClass( rClass+_open +" "+ rClass+_pane+_open ) + ; + if (s.isSliding) + $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + else // in case 'was sliding' + $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + + if (o.resizerDblClickToggle) + $R.bind("dblclick", toggle ); + removeHover( 0, $R ); // remove hover classes + if (o.resizable && $.layout.plugins.draggable) + $R .draggable("enable") + .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + else if (!s.isSliding) + $R.css("cursor", "default"); // n-resize, s-resize, etc + + // if pane also has a toggler button, adjust that too + if ($T) { + $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .addClass( tClass+_open +" "+ tClass+_pane+_open ) + .attr("title", o.togglerTip_open); // may be blank + removeHover( 0, $T ); // remove hover classes + // toggler-content - if exists + $T.children(".content-closed").hide(); + $T.children(".content-open").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, !s.isSliding); + + // update pane-state dimensions - BEFORE resizing content + $.extend(s, elDims($P)); + + if (state.initialized) { + // resize resizer & toggler sizes for all panes + sizeHandles(); + // resize content every time pane opens - to be sure + sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving' + } + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) { + // onopen callback + _runCallbacks("onopen_end", pane); + // onshow callback - TODO: should this be here? + if (s.isShowing) _runCallbacks("onshow_end", pane); + + // ALSO call onresize because layout-size *may* have changed while pane was closed + if (state.initialized) + _runCallbacks("onresize_end", pane); + } + + // TODO: Somehow sizePane("north") is being called after this point??? + } + + + /** + * slideOpen / slideClose / slideToggle + * + * Pass-though methods for sliding + */ +, slideOpen = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + , delay = options[pane].slideDelay_open + ; + // prevent event from triggering on NEW resizer binding created below + if (evt) evt.stopImmediatePropagation(); + + if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0) + // trigger = mouseenter - use a delay + timer.set(pane+"_openSlider", open_NOW, delay); + else + open_NOW(); // will unbind events if is already open + + /** + * SUBROUTINE for timed open + */ + function open_NOW () { + if (!s.isClosed) // skip if no longer closed! + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (!s.isMoving) + open(pane, true); // true = slide - open() will handle binding + }; + } + +, slideClose = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override + ; + if (s.isClosed || s.isResizing) + return; // skip if already closed OR in process of resizing + else if (o.slideTrigger_close === "click") + close_NOW(); // close immediately onClick + else if (o.preventQuickSlideClose && s.isMoving) + return; // handle Chrome quick-close on slide-open + else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane])) + return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + else if (evt) // trigger = mouseleave - use a delay + // 1 sec delay if 'opening', else .3 sec + timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay)); + else // called programically + close_NOW(); + + /** + * SUBROUTINE for timed close + */ + function close_NOW () { + if (s.isClosed) // skip 'close' if already closed! + bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here? + else if (!s.isMoving) + close(pane); // close will handle unbinding + }; + } + + /** + * @param {string} pane The pane being opened, ie: north, south, east, or west + */ +, slideToggle = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + toggle(pane, true); + } + + + /** + * Must set left/top on East/South panes so animation will work properly + * + * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored! + * @param {boolean} doLock true = set left/top, false = remove + */ +, lockPaneForFX = function (pane, doLock) { + var $P = $Ps[pane] + , s = state[pane] + , o = options[pane] + , z = options.zIndexes + ; + if (doLock) { + $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation + if (pane=="south") + $P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() }); + else if (pane=="east") + $P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() }); + } + else { // animation DONE - RESET CSS + // TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + if (pane=="south") + $P.css({ top: "auto" }); + // if pane is positioned 'off-screen', then DO NOT screw with it! + else if (pane=="east" && !$P.css("left").match(/\-99999/)) + $P.css({ left: "auto" }); + // fix anti-aliasing in IE - only needed for animations that change opacity + if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1) + $P[0].style.removeAttribute('filter'); + } + } + + + /** + * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger + * + * @see open(), close() + * @param {string} pane The pane to enable/disable, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable sliding? + */ +, bindStartSlidingEvent = function (pane, enable) { + var o = options[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , evtName = o.slideTrigger_open.toLowerCase() + ; + if (!$R || (enable && !o.slidable)) return; + + // make sure we have a valid event + if (evtName.match(/mouseover/)) + evtName = o.slideTrigger_open = "mouseenter"; + else if (!evtName.match(/click|dblclick|mouseenter/)) + evtName = o.slideTrigger_open = "click"; + + $R + // add or remove event + [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen) + // set the appropriate cursor & title/tip + .css("cursor", enable ? o.sliderCursor : "default") + .attr("title", enable ? o.sliderTip : "") + ; + } + + /** + * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed + * Also increases zIndex when pane is sliding open + * See bindStartSlidingEvent for code to control 'slide open' + * + * @see slideOpen(), slideClose() + * @param {string} pane The pane to process, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable events? + */ +, bindStopSlidingEvents = function (pane, enable) { + var o = options[pane] + , s = state[pane] + , c = _c[pane] + , z = options.zIndexes + , evtName = o.slideTrigger_close.toLowerCase() + , action = (enable ? "bind" : "unbind") + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + s.isSliding = enable; // logic + timer.clear(pane+"_closeSlider"); // just in case + + // remove 'slideOpen' event from resizer + // ALSO will raise the zIndex of the pane & resizer + if (enable) bindStartSlidingEvent(pane, false); + + // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not + $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal); + $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1 + + // make sure we have a valid event + if (!evtName.match(/click|mouseleave/)) + evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout' + + // add/remove slide triggers + $R[action](evtName, slideClose); // base event on resize + // need extra events for mouseleave + if (evtName === "mouseleave") { + // also close on pane.mouseleave + $P[action]("mouseleave."+ sID, slideClose); + // cancel timer when mouse moves between 'pane' and 'resizer' + $R[action]("mouseenter."+ sID, cancelMouseOut); + $P[action]("mouseenter."+ sID, cancelMouseOut); + } + + if (!enable) + timer.clear(pane+"_closeSlider"); + else if (evtName === "click" && !o.resizable) { + // IF pane is not resizable (which already has a cursor and tip) + // then set the a cursor & title/tip on resizer when sliding + $R.css("cursor", enable ? o.sliderCursor : "default"); + $R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane" + } + + // SUBROUTINE for mouseleave timer clearing + function cancelMouseOut (evt) { + timer.clear(pane+"_closeSlider"); + evt.stopPropagation(); + } + } + + + /** + * Hides/closes a pane if there is insufficient room - reverses this when there is room again + * MUST have already called setSizeLimits() before calling this method + * + * @param {string} pane The pane being resized + * @param {boolean=} [isOpening=false] Called from onOpen? + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, makePaneFit = function (pane, isOpening, skipCallback, force) { + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isSidePane = c.dir==="vert" + , hasRoom = false + ; + // special handling for center & east/west panes + if (pane === "center" || (isSidePane && s.noVerticalRoom)) { + // see if there is enough room to display the pane + // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth); + hasRoom = (s.maxHeight >= 0); + if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now + _showPane(pane); + if ($R) $R.show(); + s.isVisible = true; + s.noRoom = false; + if (isSidePane) s.noVerticalRoom = false; + _fixIframe(pane); + } + else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now + _hidePane(pane); + if ($R) $R.hide(); + s.isVisible = false; + s.noRoom = true; + } + } + + // see if there is enough room to fit the border-pane + if (pane === "center") { + // ignore center in this block + } + else if (s.minSize <= s.maxSize) { // pane CAN fit + hasRoom = true; + if (s.size > s.maxSize) // pane is too big - shrink it + sizePane(pane, s.maxSize, skipCallback, force, true); // true = noAnimation + else if (s.size < s.minSize) // pane is too small - enlarge it + sizePane(pane, s.minSize, skipCallback, force, true); + // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen + else if ($R && s.isVisible && $P.is(":visible")) { + // make sure resizer-bar is positioned correctly + // handles situation where nested layout was 'hidden' when initialized + var side = c.side.toLowerCase() + , pos = s.size + sC["inset"+ c.side] + ; + if ($.layout.cssNum($R, side) != pos) $R.css( side, pos ); + } + + // if was previously hidden due to noRoom, then RESET because NOW there is room + if (s.noRoom) { + // s.noRoom state will be set by open or show + if (s.wasOpen && o.closable) { + if (o.autoReopen) + open(pane, false, true, true); // true = noAnimation, true = noAlert + else // leave the pane closed, so just update state + s.noRoom = false; + } + else + show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert + } + } + else { // !hasRoom - pane CANNOT fit + if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now... + s.noRoom = true; // update state + s.wasOpen = !s.isClosed && !s.isSliding; + if (s.isClosed){} // SKIP + else if (o.closable) // 'close' if possible + close(pane, true, true); // true = force, true = noAnimation + else // 'hide' pane if cannot just be closed + hide(pane, true); // true = noAnimation + } + } + } + + + /** + * sizePane / manualSizePane + * sizePane is called only by internal methods whenever a pane needs to be resized + * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized' + * + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [noAnimation=false] + */ +, manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete... + , forceResize = o.livePaneResizing && !s.isResizing + ; + // ANY call to manualSizePane disables autoResize - ie, percentage sizing + o.autoResize = false; + // flow-through... + sizePane(pane, size, skipCallback, forceResize, noAnimation); // will animate resize if option enabled + } + + /** + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] Force resizing even if does not seem necessary + * @param {boolean=} [noAnimation=false] + */ +, sizePane = function (evt_or_pane, size, skipCallback, force, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event? + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , side = _c[pane].side.toLowerCase() + , dimName = _c[pane].sizeType.toLowerCase() + , inset = "inset"+ _c[pane].side + , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize + , doFX = noAnimation !== true && o.animatePaneSizing + , oldSize, newSize + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + // calculate 'current' min/max sizes + setSizeLimits(pane); // update pane-state + oldSize = s.size; + size = _parseSize(pane, size); // handle percentages & auto + size = max(size, _parseSize(pane, o.minSize)); + size = min(size, s.maxSize); + if (size < s.minSize) { // not enough room for pane! + queueNext(); // call before makePaneFit() because it needs the queue free + makePaneFit(pane, false, skipCallback); // will hide or close pane + return; + } + + // IF newSize is same as oldSize, then nothing to do - abort + if (!force && size === oldSize) + return queueNext(); + + // onresize_start callback CANNOT cancel resizing because this would break the layout! + if (!skipCallback && state.initialized && s.isVisible) + _runCallbacks("onresize_start", pane); + + // resize the pane, and make sure its visible + newSize = cssSize(pane, size); + + if (doFX && $P.is(":visible")) { // ANIMATE + var fx = $.layout.effects.size[pane] || $.layout.effects.size.all + , easing = o.fxSettings_size.easing || fx.easing + , z = options.zIndexes + , props = {}; + props[ dimName ] = newSize +'px'; + s.isMoving = true; + // overlay all elements during animation + $P.css({ zIndex: z.pane_animate }) + .show().animate( props, o.fxSpeed_size, easing, function(){ + // reset zIndex after animation + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + s.isMoving = false; + sizePane_2(); // continue + queueNext(); + }); + } + else { // no animation + $P.css( dimName, newSize ); // resize pane + // if pane is visible, then + if ($P.is(":visible")) + sizePane_2(); // continue + else { + // pane is NOT VISIBLE, so just update state data... + // when pane is *next opened*, it will have the new size + s.size = size; // update state.size + $.extend(s, elDims($P)); // update state dimensions + } + queueNext(); + }; + + }); + + // SUBROUTINE + function sizePane_2 () { + /* Panes are sometimes not sized precisely in some browsers!? + * This code will resize the pane up to 3 times to nudge the pane to the correct size + */ + var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight() + , tries = [{ + pane: pane + , count: 1 + , target: size + , actual: actual + , correct: (size === actual) + , attempt: size + , cssSize: newSize + }] + , lastTry = tries[0] + , msg = 'Inaccurate size after resizing the '+ pane +'-pane.' + ; + while ( !lastTry.correct ) { + thisTry = { pane: pane, count: lastTry.count+1, target: size }; + + if (lastTry.actual > size) + thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size)); + else // lastTry.actual < size + thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual)); + + thisTry.cssSize = cssSize(pane, thisTry.attempt); + $P.css( dimName, thisTry.cssSize ); + + thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight(); + thisTry.correct = (size === thisTry.actual); + + // if showDebugMessages, log attempts and alert the user of this *non-fatal error* + if (options.showDebugMessages) { + if ( tries.length === 1) { + _log(msg, false); + _log(lastTry, false); + } + _log(thisTry, false); + } + + // after 4 tries, is as close as its gonna get! + if (tries.length > 3) break; + + tries.push( thisTry ); + lastTry = tries[ tries.length - 1 ]; + } + // END TESTING CODE + + // update pane-state dimensions + s.size = size; + $.extend(s, elDims($P)); + + if (s.isVisible && $P.is(":visible")) { + // reposition the resizer-bar + if ($R) $R.css( side, size + sC[inset] ); + // resize the content-div + sizeContent(pane); + } + + if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible) + _runCallbacks("onresize_end", pane); + + // resize all the adjacent panes, and adjust their toggler buttons + // when skipCallback passed, it means the controlling method will handle 'other panes' + if (!skipCallback) { + // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize + if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force); + sizeHandles(); + } + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (size < oldSize && state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane, false, skipCallback ); + } + + // DEBUG - ALERT user/developer so they know there was a sizing problem + if (options.showDebugMessages && tries.length > 1) + _log(msg +'\nSee the Error Console for details.', true); + } + } + + /** + * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide() + * @param {string} panes The pane(s) being resized, comma-delmited string + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, sizeMidPanes = function (panes, skipCallback, force) { + panes = (panes ? panes : "east,west,center").split(","); + + $.each(panes, function (i, pane) { + if (!$Ps[pane]) return; // NO PANE - skip + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isCenter= (pane=="center") + , hasRoom = true + , CSS = {} + , newCenter = calcNewCenterPaneDims() + ; + // update pane-state dimensions + $.extend(s, elDims($P)); + + if (pane === "center") { + if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // set state for makePaneFit() logic + $.extend(s, cssMinDims(pane), { + maxWidth: newCenter.width + , maxHeight: newCenter.height + }); + CSS = newCenter; + // convert OUTER width/height to CSS width/height + CSS.width = cssW($P, CSS.width); + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, CSS.height); + hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW + // during layout init, try to shrink east/west panes to make room for center + if (!state.initialized && o.minWidth > s.outerWidth) { + var + reqPx = o.minWidth - s.outerWidth + , minE = options.east.minSize || 0 + , minW = options.west.minSize || 0 + , sizeE = state.east.size + , sizeW = state.west.size + , newE = sizeE + , newW = sizeW + ; + if (reqPx > 0 && state.east.isVisible && sizeE > minE) { + newE = max( sizeE-minE, sizeE-reqPx ); + reqPx -= sizeE-newE; + } + if (reqPx > 0 && state.west.isVisible && sizeW > minW) { + newW = max( sizeW-minW, sizeW-reqPx ); + reqPx -= sizeW-newW; + } + // IF we found enough extra space, then resize the border panes as calculated + if (reqPx === 0) { + if (sizeE != minE) + sizePane('east', newE, true, force, true); // true = skipCallback/noAnimation - initPanes will handle when done + if (sizeW != minW) + sizePane('west', newW, true, force, true); + // now start over! + sizeMidPanes('center', skipCallback, force); + return; // abort this loop + } + } + } + else { // for east and west, set only the height, which is same as center height + // set state.min/maxWidth/Height for makePaneFit() logic + if (s.isVisible && !s.noVerticalRoom) + $.extend(s, elDims($P), cssMinDims(pane)) + if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // east/west have same top, bottom & height as center + CSS.top = newCenter.top; + CSS.bottom = newCenter.bottom; + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, newCenter.height); + s.maxHeight = CSS.height; + hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW + if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic + } + + if (hasRoom) { + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_start", pane); + + $P.css(CSS); // apply the CSS to pane + sizeHandles(pane); // also update resizer length + if (s.noRoom && !s.isClosed && !s.isHidden) + makePaneFit(pane); // will re-open/show auto-closed/hidden pane + if (s.isVisible) { + $.extend(s, elDims($P)); // update pane dimensions + if (state.initialized) sizeContent(pane); // also resize the contents, if exists + } + } + else if (!s.noRoom && s.isVisible) // no room for pane + makePaneFit(pane); // will hide or close pane + + if (!s.isVisible) + return true; // DONE - next pane + + /* + * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes + * Normally these panes have only 'left' & 'right' positions so pane auto-sizes + * ALSO required when pane is an IFRAME because will NOT default to 'full width' + */ + if (pane === "center") { // finished processing midPanes + var b = $.layout.browser; + var fix = b.isIE6 || (b.msie && !$.support.boxModel); + if ($Ps.north && (fix || state.north.tagName=="IFRAME")) + $Ps.north.css("width", cssW($Ps.north, sC.innerWidth)); + if ($Ps.south && (fix || state.south.tagName=="IFRAME")) + $Ps.south.css("width", cssW($Ps.south, sC.innerWidth)); + } + + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_end", pane); + }); + } + + + /** + * @see window.onresize(), callbacks or custom code + */ +, resizeAll = function () { + if (!state.initialized) { + _initLayoutElements(); + return; // no need to resize since we just initialized! + } + var oldW = sC.innerWidth + , oldH = sC.innerHeight + ; + // cannot size layout when 'container' is hidden or collapsed + if (!$N.is(":visible:") ) return; + $.extend( state.container, elDims( $N ) ); // UPDATE container dimensions + if (!sC.outerHeight) return; + + // onresizeall_start will CANCEL resizing if returns false + // state.container has already been set, so user can access this info for calcuations + if (false === _runCallbacks("onresizeall_start")) return false; + + var // see if container is now 'smaller' than before + shrunkH = (sC.innerHeight < oldH) + , shrunkW = (sC.innerWidth < oldW) + , $P, o, s, dir + ; + // NOTE special order for sizing: S-N-E-W + $.each(["south","north","east","west"], function (i, pane) { + if (!$Ps[pane]) return; // no pane - SKIP + s = state[pane]; + o = options[pane]; + dir = _c[pane].dir; + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else { + setSizeLimits(pane); + makePaneFit(pane, false, true, true); // true=skipCallback/forceResize + } + }); + + sizeMidPanes("", true, true); // true=skipCallback, true=forceResize + sizeHandles(); // reposition the toggler elements + + // trigger all individual pane callbacks AFTER layout has finished resizing + o = options; // reuse alias + $.each(_c.allPanes, function (i, pane) { + $P = $Ps[pane]; + if (!$P) return; // SKIP + if (state[pane].isVisible) // undefined for non-existent panes + _runCallbacks("onresize_end", pane); // callback - if exists + }); + + _runCallbacks("onresizeall_end"); + //_triggerLayoutEvent(pane, 'resizeall'); + } + + /** + * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll + * + * @param {string} pane The pane just resized or opened + */ +, resizeChildLayout = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + if (!options[pane].resizeChildLayout) return; + var $P = $Ps[pane] + , $C = $Cs[pane] + , d = "layout" + , P = Instance[pane] + , L = children[pane] + ; + // user may have manually set EITHER instance pointer, so handle that + if (P.child && !L) { + // have to reverse the pointers! + var el = P.child.container; + L = children[pane] = (el ? el.data(d) : 0) || null; // set pointer _directly_ to layout instance + } + + // if a layout-pointer exists, see if child has been destroyed + if (L && L.destroyed) + L = children[pane] = null; // clear child pointers + // no child layout pointer is set - see if there is a child layout NOW + if (!L) L = children[pane] = $P.data(d) || ($C ? $C.data(d) : 0) || null; // set/update child pointers + + // ALWAYS refresh the pane.child alias + P.child = children[pane]; + + if (L) L.resizeAll(); + } + + + /** + * IF pane has a content-div, then resize all elements inside pane to fit pane-height + * + * @param {string=} [panes=""] The pane(s) being resized + * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured? + */ +, sizeContent = function (evt_or_panes, remeasure) { + if (!isInitialized()) return; + + var panes = evtPane.call(this, evt_or_panes); + panes = panes ? panes.split(",") : _c.allPanes; + + $.each(panes, function (idx, pane) { + var + $P = $Ps[pane] + , $C = $Cs[pane] + , o = options[pane] + , s = state[pane] + , m = s.content // m = measurements + ; + if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip + + // if content-element was REMOVED, update OR remove the pointer + if (!$C.length) { + initContent(pane, false); // false = do NOT sizeContent() - already there! + if (!$C) return; // no replacement element found - pointer have been removed + } + + // onsizecontent_start will CANCEL resizing if returns false + if (false === _runCallbacks("onsizecontent_start", pane)) return; + + // skip re-measuring offsets if live-resizing + if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) { + _measure(); + // if any footers are below pane-bottom, they may not measure correctly, + // so allow pane overflow and re-measure + if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") { + $P.css("overflow", "visible"); + _measure(); // remeasure while overflowing + $P.css("overflow", "hidden"); + } + } + // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders + var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom); + + if (!$C.is(":visible") || m.height != newH) { + // size the Content element to fit new pane-size - will autoHide if not enough room + setOuterHeight($C, newH, true); // true=autoHide + m.height = newH; // save new height + }; + + if (state.initialized) + _runCallbacks("onsizecontent_end", pane); + + function _below ($E) { + return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0)); + }; + + function _measure () { + var + ignore = options[pane].contentIgnoreSelector + , $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL + , $Fs_vis = $Fs.filter(':visible') + , $F = $Fs_vis.filter(':last') + ; + m = { + top: $C[0].offsetTop + , height: $C.outerHeight() + , numFooters: $Fs.length + , hiddenFooters: $Fs.length - $Fs_vis.length + , spaceBelow: 0 // correct if no content footer ($E) + } + m.spaceAbove = m.top; // just for state - not used in calc + m.bottom = m.top + m.height; + if ($F.length) + //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom) + m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F); + else // no footer - check marginBottom on Content element itself + m.spaceBelow = _below($C); + }; + }); + } + + + /** + * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary + * + * @see initHandles(), open(), close(), resizeAll() + * @param {string=} [panes=""] The pane(s) being resized + */ +, sizeHandles = function (evt_or_panes) { + var panes = evtPane.call(this, evt_or_panes) + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (i, pane) { + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , $TC + ; + if (!$P || !$R) return; + + var + dir = _c[pane].dir + , _state = (s.isClosed ? "_closed" : "_open") + , spacing = o["spacing"+ _state] + , togAlign = o["togglerAlign"+ _state] + , togLen = o["togglerLength"+ _state] + , paneLen + , left + , offset + , CSS = {} + ; + + if (spacing === 0) { + $R.hide(); + return; + } + else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason + $R.show(); // in case was previously hidden + + // Resizer Bar is ALWAYS same width/height of pane it is attached to + if (dir === "horz") { // north/south + //paneLen = $P.outerWidth(); // s.outerWidth || + paneLen = sC.innerWidth; // handle offscreen-panes + s.resizerLength = paneLen; + left = $.layout.cssNum($P, "left") + $R.css({ + width: cssW($R, paneLen) // account for borders & padding + , height: cssH($R, spacing) // ditto + , left: left > -9999 ? left : sC.insetLeft // handle offscreen-panes + }); + } + else { // east/west + paneLen = $P.outerHeight(); // s.outerHeight || + s.resizerLength = paneLen; + $R.css({ + height: cssH($R, paneLen) // account for borders & padding + , width: cssW($R, spacing) // ditto + , top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane? + //, top: $.layout.cssNum($Ps["center"], "top") + }); + } + + // remove hover classes + removeHover( o, $R ); + + if ($T) { + if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) { + $T.hide(); // always HIDE the toggler when 'sliding' + return; + } + else + $T.show(); // in case was previously hidden + + if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) { + togLen = paneLen; + offset = 0; + } + else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed + if (isStr(togAlign)) { + switch (togAlign) { + case "top": + case "left": offset = 0; + break; + case "bottom": + case "right": offset = paneLen - togLen; + break; + case "middle": + case "center": + default: offset = round((paneLen - togLen) / 2); // 'default' catches typos + } + } + else { // togAlign = number + var x = parseInt(togAlign, 10); // + if (togAlign >= 0) offset = x; + else offset = paneLen - togLen + x; // NOTE: x is negative! + } + } + + if (dir === "horz") { // north/south + var width = cssW($T, togLen); + $T.css({ + width: width // account for borders & padding + , height: cssH($T, spacing) // ditto + , left: offset // TODO: VERIFY that toggler positions correctly for ALL values + , top: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative + }); + } + else { // east/west + var height = cssH($T, togLen); + $T.css({ + height: height // account for borders & padding + , width: cssW($T, spacing) // ditto + , top: offset // POSITION the toggler + , left: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative + }); + } + + // remove ALL hover classes + removeHover( 0, $T ); + } + + // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now + if (!state.initialized && (o.initHidden || s.noRoom)) { + $R.hide(); + if ($T) $T.hide(); + } + }); + } + + + /** + * @param {string} pane + */ +, enableClosable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + , o = options[pane] + ; + if (!$T) return; + o.closable = true; + $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); }) + .css("visibility", "visible") + .css("cursor", "pointer") + .attr("title", state[pane].isClosed ? o.togglerTip_closed : o.togglerTip_open) // may be blank + .show(); + } + /** + * @param {string} pane + * @param {boolean=} [hide=false] + */ +, disableClosable = function (evt_or_pane, hide) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + ; + if (!$T) return; + options[pane].closable = false; + // is closable is disable, then pane MUST be open! + if (state[pane].isClosed) open(pane, false, true); + $T .unbind("."+ sID) + .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues + .css("cursor", "default") + .attr("title", ""); + } + + + /** + * @param {string} pane + */ +, enableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].slidable = true; + if (s.isClosed) + bindStartSlidingEvent(pane, true); + } + /** + * @param {string} pane + */ +, disableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R) return; + options[pane].slidable = false; + if (state[pane].isSliding) + close(pane, false, true); + else { + bindStartSlidingEvent(pane, false); + $R .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + } + + + /** + * @param {string} pane + */ +, enableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + , o = options[pane] + ; + if (!$R || !$R.data('draggable')) return; + o.resizable = true; + $R.draggable("enable"); + if (!state[pane].isClosed) + $R .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + } + /** + * @param {string} pane + */ +, disableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].resizable = false; + $R .draggable("disable") + .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + + + /** + * Move a pane from source-side (eg, west) to target-side (eg, east) + * If pane exists on target-side, move that to source-side, ie, 'swap' the panes + * + * @param {string} pane1 The pane/edge being swapped + * @param {string} pane2 ditto + */ +, swapPanes = function (evt_or_pane1, pane2) { + if (!isInitialized()) return; + var pane1 = evtPane.call(this, evt_or_pane1); + // change state.edge NOW so callbacks can know where pane is headed... + state[pane1].edge = pane2; + state[pane2].edge = pane1; + // run these even if NOT state.initialized + if (false === _runCallbacks("onswap_start", pane1) + || false === _runCallbacks("onswap_start", pane2) + ) { + state[pane1].edge = pane1; // reset + state[pane2].edge = pane2; + return; + } + + var + oPane1 = copy( pane1 ) + , oPane2 = copy( pane2 ) + , sizes = {} + ; + sizes[pane1] = oPane1 ? oPane1.state.size : 0; + sizes[pane2] = oPane2 ? oPane2.state.size : 0; + + // clear pointers & state + $Ps[pane1] = false; + $Ps[pane2] = false; + state[pane1] = {}; + state[pane2] = {}; + + // ALWAYS remove the resizer & toggler elements + if ($Ts[pane1]) $Ts[pane1].remove(); + if ($Ts[pane2]) $Ts[pane2].remove(); + if ($Rs[pane1]) $Rs[pane1].remove(); + if ($Rs[pane2]) $Rs[pane2].remove(); + $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false; + + // transfer element pointers and data to NEW Layout keys + move( oPane1, pane2 ); + move( oPane2, pane1 ); + + // cleanup objects + oPane1 = oPane2 = sizes = null; + + // make panes 'visible' again + if ($Ps[pane1]) $Ps[pane1].css(_c.visible); + if ($Ps[pane2]) $Ps[pane2].css(_c.visible); + + // fix any size discrepancies caused by swap + resizeAll(); + + // run these even if NOT state.initialized + _runCallbacks("onswap_end", pane1); + _runCallbacks("onswap_end", pane2); + + return; + + function copy (n) { // n = pane + var + $P = $Ps[n] + , $C = $Cs[n] + ; + return !$P ? false : { + pane: n + , P: $P ? $P[0] : false + , C: $C ? $C[0] : false + , state: $.extend(true, {}, state[n]) + , options: $.extend(true, {}, options[n]) + } + }; + + function move (oPane, pane) { + if (!oPane) return; + var + P = oPane.P + , C = oPane.C + , oldPane = oPane.pane + , c = _c[pane] + , side = c.side.toLowerCase() + , inset = "inset"+ c.side + // save pane-options that should be retained + , s = $.extend({}, state[pane]) + , o = options[pane] + // RETAIN side-specific FX Settings - more below + , fx = { resizerCursor: o.resizerCursor } + , re, size, pos + ; + $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) { + fx[k +"_open"] = o[k +"_open"]; + fx[k +"_close"] = o[k +"_close"]; + fx[k +"_size"] = o[k +"_size"]; + }); + + // update object pointers and attributes + $Ps[pane] = $(P) + .data({ + layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + }) + .css(_c.hidden) + .css(c.cssReq) + ; + $Cs[pane] = C ? $(C) : false; + + // set options and state + options[pane] = $.extend({}, oPane.options, fx); + state[pane] = $.extend({}, oPane.state); + + // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west + re = new RegExp(o.paneClass +"-"+ oldPane, "g"); + P.className = P.className.replace(re, o.paneClass +"-"+ pane); + + // ALWAYS regenerate the resizer & toggler elements + initHandles(pane); // create the required resizer & toggler + + // if moving to different orientation, then keep 'target' pane size + if (c.dir != _c[oldPane].dir) { + size = sizes[pane] || 0; + setSizeLimits(pane); // update pane-state + size = max(size, state[pane].minSize); + // use manualSizePane to disable autoResize - not useful after panes are swapped + manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation + } + else // move the resizer here + $Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0)); + + + // ADD CLASSNAMES & SLIDE-BINDINGS + if (oPane.state.isVisible && !s.isVisible) + setAsOpen(pane, true); // true = skipCallback + else { + setAsClosed(pane); + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + // DESTROY the object + oPane = null; + }; + } + + + /** + * INTERNAL method to sync pin-buttons when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), setAsOpen(), setAsClosed() + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns = function (pane, doPin) { + if ($.layout.plugins.buttons) + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(Instance, $(selector), pane, doPin); + }); + } + +; // END var DECLARATIONS + + /** + * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed + * + * @see document.keydown() + */ + function keyDown (evt) { + if (!evt) return true; + var code = evt.keyCode; + if (code < 33) return true; // ignore special keys: ENTER, TAB, etc + + var + PANE = { + 38: "north" // Up Cursor - $.ui.keyCode.UP + , 40: "south" // Down Cursor - $.ui.keyCode.DOWN + , 37: "west" // Left Cursor - $.ui.keyCode.LEFT + , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT + } + , ALT = evt.altKey // no worky! + , SHIFT = evt.shiftKey + , CTRL = evt.ctrlKey + , CURSOR = (CTRL && code >= 37 && code <= 40) + , o, k, m, pane + ; + + if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey + pane = PANE[code]; + else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey + $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey + o = options[p]; + k = o.customHotkey; + m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT" + if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches + if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches + pane = p; + return false; // BREAK + } + } + }); + + // validate pane + if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden) + return true; + + toggle(pane); + + evt.stopPropagation(); + evt.returnValue = false; // CANCEL key + return false; + }; + + +/* + * ###################################### + * UTILITY METHODS + * called externally or by initButtons + * ###################################### + */ + + /** + * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work + * + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function allowOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + ; + + // if pane is already raised, then reset it before doing it again! + // this would happen if allowOverflow is attached to BOTH the pane and an element + if (s.cssSaved) + resetOverflow(pane); // reset previous CSS before continuing + + // if pane is raised by sliding or resizing, or its closed, then abort + if (s.isSliding || s.isResizing || s.isClosed) { + s.cssSaved = false; + return; + } + + var + newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) } + , curCSS = {} + , of = $P.css("overflow") + , ofX = $P.css("overflowX") + , ofY = $P.css("overflowY") + ; + // determine which, if any, overflow settings need to be changed + if (of != "visible") { + curCSS.overflow = of; + newCSS.overflow = "visible"; + } + if (ofX && !ofX.match(/visible|auto/)) { + curCSS.overflowX = ofX; + newCSS.overflowX = "visible"; + } + if (ofY && !ofY.match(/visible|auto/)) { + curCSS.overflowY = ofX; + newCSS.overflowY = "visible"; + } + + // save the current overflow settings - even if blank! + s.cssSaved = curCSS; + + // apply new CSS to raise zIndex and, if necessary, make overflow 'visible' + $P.css( newCSS ); + + // make sure the zIndex of all other panes is normal + $.each(_c.allPanes, function(i, p) { + if (p != pane) resetOverflow(p); + }); + + }; + /** + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function resetOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + , CSS = s.cssSaved || {} + ; + // reset the zIndex + if (!s.isSliding && !s.isResizing) + $P.css("zIndex", options.zIndexes.pane_normal); + + // reset Overflow - if necessary + $P.css( CSS ); + + // clear var + s.cssSaved = false; + }; + +/* + * ##################### + * CREATE/RETURN LAYOUT + * ##################### + */ + + // validate that container exists + var $N = $(this).eq(0); // FIRST matching Container element + if (!$N.length) { + if (options.showErrorMessages) + _log( lang.errContainerMissing, true ); + return null; + }; + + // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout") + // return the Instance-pointer if layout has already been initialized + if ($N.data("layoutContainer") && $N.data("layout")) + return $N.data("layout"); // cached pointer + + // init global vars + var + $Ps = {} // Panes x5 - set in initPanes() + , $Cs = {} // Content x5 - set in initPanes() + , $Rs = {} // Resizers x4 - set in initHandles() + , $Ts = {} // Togglers x4 - set in initHandles() + , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV) + // aliases for code brevity + , sC = state.container // alias for easy access to 'container dimensions' + , sID = state.id // alias for unique layout ID/namespace - eg: "layout435" + ; + + // create Instance object to expose data & option Properties, and primary action Methods + var Instance = { + // layout data + options: options // property - options hash + , state: state // property - dimensions hash + // object pointers + , container: $N // property - object pointers for layout container + , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center + , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center + , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north + , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north + // border-pane open/close + , hide: hide // method - ditto + , show: show // method - ditto + , toggle: toggle // method - pass a 'pane' ("north", "west", etc) + , open: open // method - ditto + , close: close // method - ditto + , slideOpen: slideOpen // method - ditto + , slideClose: slideClose // method - ditto + , slideToggle: slideToggle // method - ditto + // pane actions + , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data + , _sizePane: sizePane // method -intended for user by plugins only! + , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto' + , sizeContent: sizeContent // method - pass a 'pane' + , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them + // pane element methods + , initContent: initContent // method - ditto + , addPane: addPane // method - pass a 'pane' + , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem + , createChildLayout: createChildLayout// method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].childOptions + // special pane option setting + , enableClosable: enableClosable // method - pass a 'pane' + , disableClosable: disableClosable // method - ditto + , enableSlidable: enableSlidable // method - ditto + , disableSlidable: disableSlidable // method - ditto + , enableResizable: enableResizable // method - ditto + , disableResizable: disableResizable// method - ditto + // utility methods for panes + , allowOverflow: allowOverflow // utility - pass calling element (this) + , resetOverflow: resetOverflow // utility - ditto + // layout control + , destroy: destroy // method - no parameters + , initPanes: isInitialized // method - no parameters + , resizeAll: resizeAll // method - no parameters + // callback triggering + , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west") + // alias collections of options, state and children - created in addPane and extended elsewhere + , hasParentLayout: false // set by initContainer() + , children: children // pointers to child-layouts, eg: Instance.children["west"] + , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], child: children[pane] } + , south: false // ditto + , west: false // ditto + , east: false // ditto + , center: false // ditto + }; + + // create the border layout NOW + if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation + return null; + else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later + return Instance; // return the Instance object + +} + + + + +/** + * jquery.layout.state 1.0 + * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * @dependancies: $.ui.cookie (above) + * + * @support: http://groups.google.com/group/jquery-ui-layout + */ +/* + * State-management options stored in options.stateManagement, which includes a .cookie hash + * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden + * + * // STATE/COOKIE OPTIONS + * @example $(el).layout({ + stateManagement: { + enabled: true + , stateKeys: "east.size,west.size,east.isClosed,west.isClosed" + , cookie: { name: "appLayout", path: "/" } + } + }) + * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies + * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } }) + * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" }) + * + * // STATE/COOKIE METHODS + * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} ); + * @example myLayout.loadCookie(); + * @example myLayout.deleteCookie(); + * @example var JSON = myLayout.readState(); // CURRENT Layout State + * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie) + * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash) + * + * CUSTOM STATE-MANAGEMENT (eg, saved in a database) + * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" ); + * @example myLayout.loadState( JSON ); + */ + +/** + * UI COOKIE UTILITY + * + * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then... + * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin + * NOTE: This utility is REQUIRED by the layout.state plugin + * + * Cookie methods in Layout are created as part of State Management + */ +if (!$.ui) $.ui = {}; +$.ui.cookie = { + + // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6 + acceptsCookies: !!navigator.cookieEnabled + +, read: function (name) { + var + c = document.cookie + , cs = c ? c.split(';') : [] + , pair // loop var + ; + for (var i=0, n=cs.length; i < n; i++) { + pair = $.trim(cs[i]).split('='); // name=value pair + if (pair[0] == name) // found the layout cookie + return decodeURIComponent(pair[1]); + + } + return null; + } + +, write: function (name, val, cookieOpts) { + var + params = '' + , date = '' + , clear = false + , o = cookieOpts || {} + , x = o.expires + ; + if (x && x.toUTCString) + date = x; + else if (x === null || typeof x === 'number') { + date = new Date(); + if (x > 0) + date.setDate(date.getDate() + x); + else { + date.setFullYear(1970); + clear = true; + } + } + if (date) params += ';expires='+ date.toUTCString(); + if (o.path) params += ';path='+ o.path; + if (o.domain) params += ';domain='+ o.domain; + if (o.secure) params += ';secure'; + document.cookie = name +'='+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie + } + +, clear: function (name) { + $.ui.cookie.write(name, '', {expires: -1}); + } + +}; +// if cookie.jquery.js is not loaded, create an alias to replicate it +// this may be useful to other plugins or code dependent on that plugin +if (!$.cookie) $.cookie = function (k, v, o) { + var C = $.ui.cookie; + if (v === null) + C.clear(k); + else if (v === undefined) + return C.read(k); + else + C.write(k, v, o); +}; + + +// tell Layout that the state plugin is available +$.layout.plugins.stateManagement = true; + +// Add State-Management options to layout.defaults +$.layout.config.optionRootKeys.push("stateManagement"); +$.layout.defaults.stateManagement = { + enabled: false // true = enable state-management, even if not using cookies +, autoSave: true // Save a state-cookie when page exits? +, autoLoad: true // Load the state-cookie when Layout inits? + // List state-data to save - must be pane-specific +, stateKeys: "north.size,south.size,east.size,west.size,"+ + "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+ + "north.isHidden,south.isHidden,east.isHidden,west.isHidden" +, cookie: { + name: "" // If not specified, will use Layout.name, else just "Layout" + , domain: "" // blank = current domain + , path: "" // blank = current page, '/' = entire website + , expires: "" // 'days' to keep cookie - leave blank for 'session cookie' + , secure: false + } +}; +// Set stateManagement as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("stateManagement"); + +/* + * State Management methods + */ +$.layout.state = { + + /** + * Get the current layout state and save it to a cookie + * + * myLayout.saveCookie( keys, cookieOpts ) + * + * @param {Object} inst + * @param {(string|Array)=} keys + * @param {Object=} opts + */ + saveCookie: function (inst, keys, cookieOpts) { + var o = inst.options + , oS = o.stateManagement + , oC = $.extend(true, {}, oS.cookie, cookieOpts || null) + , data = inst.state.stateData = inst.readState( keys || oS.stateKeys ) // read current panes-state + ; + $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC ); + return $.extend(true, {}, data); // return COPY of state.stateData data + } + + /** + * Remove the state cookie + * + * @param {Object} inst + */ +, deleteCookie: function (inst) { + var o = inst.options; + $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" ); + } + + /** + * Read & return data from the cookie - as JSON + * + * @param {Object} inst + */ +, readCookie: function (inst) { + var o = inst.options; + var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" ); + // convert cookie string back to a hash and return it + return c ? $.layout.state.decodeJSON(c) : {}; + } + + /** + * Get data from the cookie and USE IT to loadState + * + * @param {Object} inst + */ +, loadCookie: function (inst) { + var c = $.layout.state.readCookie(inst); // READ the cookie + if (c) { + inst.state.stateData = $.extend(true, {}, c); // SET state.stateData + inst.loadState(c); // LOAD the retrieved state + } + return c; + } + + /** + * Update layout options from the cookie, if one exists + * + * @param {Object} inst + * @param {Object=} stateData + * @param {boolean=} animate + */ +, loadState: function (inst, stateData, animate) { + stateData = $.layout.transformData( stateData ); // panes = default subkey + if ($.isEmptyObject( stateData )) return; + $.extend(true, inst.options, stateData); // update layout options + // if layout has already been initialized, then UPDATE layout state + if (inst.state.initialized) { + var pane, vis, o, s, h, c + , noAnimate = (animate===false) + ; + $.each($.layout.config.borderPanes, function (idx, pane) { + state = inst.state[pane]; + o = stateData[ pane ]; + if (typeof o != 'object') return; // no key, continue + s = o.size; + c = o.initClosed; + h = o.initHidden; + vis = state.isVisible; + // resize BEFORE opening + if (!vis) + inst.sizePane(pane, s, false, false); + if (h === true) inst.hide(pane, noAnimate); + else if (c === false) inst.open (pane, false, noAnimate); + else if (c === true) inst.close(pane, false, noAnimate); + else if (h === false) inst.show (pane, false, noAnimate); + // resize AFTER any other actions + if (vis) + inst.sizePane(pane, s, false, noAnimate); // animate resize if option passed + }); + }; + } + + /** + * Get the *current layout state* and return it as a hash + * + * @param {Object=} inst + * @param {(string|Array)=} keys + */ +, readState: function (inst, keys) { + var + data = {} + , alt = { isClosed: 'initClosed', isHidden: 'initHidden' } + , state = inst.state + , panes = $.layout.config.allPanes + , pair, pane, key, val + ; + if (!keys) keys = inst.options.stateManagement.stateKeys; // if called by user + if ($.isArray(keys)) keys = keys.join(","); + // convert keys to an array and change delimiters from '__' to '.' + keys = keys.replace(/__/g, ".").split(','); + // loop keys and create a data hash + for (var i=0, n=keys.length; i < n; i++) { + pair = keys[i].split("."); + pane = pair[0]; + key = pair[1]; + if ($.inArray(pane, panes) < 0) continue; // bad pane! + val = state[ pane ][ key ]; + if (val == undefined) continue; + if (key=="isClosed" && state[pane]["isSliding"]) + val = true; // if sliding, then *really* isClosed + ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val; + } + return data; + } + + /** + * Stringify a JSON hash so can save in a cookie or db-field + */ +, encodeJSON: function (JSON) { + return parse(JSON); + function parse (h) { + var D=[], i=0, k, v, t; // k = key, v = value + for (k in h) { + v = h[k]; + t = typeof v; + if (t == 'string') // STRING - add quotes + v = '"'+ v +'"'; + else if (t == 'object') // SUB-KEY - recurse into it + v = parse(v); + D[i++] = '"'+ k +'":'+ v; + } + return '{'+ D.join(',') +'}'; + }; + } + + /** + * Convert stringified JSON back to a hash object + * @see $.parseJSON(), adding in jQuery 1.4.1 + */ +, decodeJSON: function (str) { + try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; } + catch (e) { return {}; } + } + + +, _create: function (inst) { + var _ = $.layout.state; + // ADD State-Management plugin methods to inst + $.extend( inst, { + // readCookie - update options from cookie - returns hash of cookie data + readCookie: function () { return _.readCookie(inst); } + // deleteCookie + , deleteCookie: function () { _.deleteCookie(inst); } + // saveCookie - optionally pass keys-list and cookie-options (hash) + , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); } + // loadCookie - readCookie and use to loadState() - returns hash of cookie data + , loadCookie: function () { return _.loadCookie(inst); } + // loadState - pass a hash of state to use to update options + , loadState: function (stateData, animate) { _.loadState(inst, stateData, animate); } + // readState - returns hash of current layout-state + , readState: function (keys) { return _.readState(inst, keys); } + // add JSON utility methods too... + , encodeJSON: _.encodeJSON + , decodeJSON: _.decodeJSON + }); + + // init state.stateData key, even if plugin is initially disabled + inst.state.stateData = {}; + + // read and load cookie-data per options + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoLoad) // update the options from the cookie + inst.loadCookie(); + else // don't modify options - just store cookie data in state.stateData + inst.state.stateData = inst.readCookie(); + } + } + +, _unload: function (inst) { + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoSave) // save a state-cookie automatically + inst.saveCookie(); + else // don't save a cookie, but do store state-data in state.stateData key + inst.state.stateData = inst.readState(); + } + } + +}; + +// add state initialization method to Layout's onCreate array of functions +$.layout.onCreate.push( $.layout.state._create ); +$.layout.onUnload.push( $.layout.state._unload ); + + + + +/** + * jquery.layout.buttons 1.0 + * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * Docs: [ to come ] + * Tips: [ to come ] + */ + +// tell Layout that the state plugin is available +$.layout.plugins.buttons = true; + +// Add buttons options to layout.defaults +$.layout.defaults.autoBindCustomButtons = false; +// Specify autoBindCustomButtons as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("autoBindCustomButtons"); + +var lang = $.layout.language; + +/* + * Button methods + */ +$.layout.buttons = { + + /** + * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons + * + * @see _create() + * + * @param {Object} inst Layout Instance object + */ + init: function (inst) { + var pre = "ui-layout-button-" + , layout = inst.options.name || "" + , name; + $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) { + $.each($.layout.config.borderPanes, function (ii, pane) { + $("."+pre+action+"-"+pane).each(function(){ + // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name' + name = $(this).data("layoutName") || $(this).attr("layoutName"); + if (name == undefined || name === layout) + inst.bindButton(this, action, pane); + }); + }); + }); + } + + /** + * Helper function to validate params received by addButton utilities + * + * Two classes are added to the element, based on the buttonClass... + * The type of button is appended to create the 2nd className: + * - ui-layout-button-pin // action btnClass + * - ui-layout-button-pin-west // action btnClass + pane + * - ui-layout-button-toggle + * - ui-layout-button-open + * - ui-layout-button-close + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * + * @return {Array.} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null + */ +, get: function (inst, selector, pane, action) { + var $E = $(selector) + , o = inst.options + , err = o.showErrorMessages + ; + if (!$E.length) { // element not found + if (err) $.layout.msg(lang.errButton + lang.selector +": "+ selector, true); + } + else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified + if (err) $.layout.msg(lang.errButton + lang.pane +": "+ pane, true); + $E = $(""); // NO BUTTON + } + else { // VALID + var btn = o[pane].buttonClass +"-"+ action; + $E .addClass( btn +" "+ btn +"-"+ pane ) + .data("layoutName", o.name); // add layout identifier - even if blank! + } + return $E; + } + + + /** + * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc. + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} action + * @param {string} pane + */ +, bind: function (inst, selector, action, pane) { + var _ = $.layout.buttons; + switch (action.toLowerCase()) { + case "toggle": _.addToggle (inst, selector, pane); break; + case "open": _.addOpen (inst, selector, pane); break; + case "close": _.addClose (inst, selector, pane); break; + case "pin": _.addPin (inst, selector, pane); break; + case "toggle-slide": _.addToggle (inst, selector, pane, true); break; + case "open-slide": _.addOpen (inst, selector, pane, true); break; + } + return inst; + } + + /** + * Add a custom Toggler button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addToggle: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "toggle") + .click(function(evt){ + inst.toggle(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Open button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addOpen: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "open") + .attr("title", lang.Open) + .click(function (evt) { + inst.open(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Close button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + */ +, addClose: function (inst, selector, pane) { + $.layout.buttons.get(inst, selector, pane, "close") + .attr("title", lang.Close) + .click(function (evt) { + inst.close(pane); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Pin button for a pane + * + * Four classes are added to the element, based on the paneClass for the associated pane... + * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin: + * - ui-layout-pane-pin + * - ui-layout-pane-west-pin + * - ui-layout-pane-pin-up + * - ui-layout-pane-west-pin-up + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc. + */ +, addPin: function (inst, selector, pane) { + var _ = $.layout.buttons + , $E = _.get(inst, selector, pane, "pin"); + if ($E.length) { + var s = inst.state[pane]; + $E.click(function (evt) { + _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed)); + if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open + else inst.close( pane ); // slide-closed + evt.stopPropagation(); + }); + // add up/down pin attributes and classes + _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding)); + // add this pin to the pane data so we can 'sync it' automatically + // PANE.pins key is an array so we can store multiple pins for each pane + s.pins.push( selector ); // just save the selector string + } + return inst; + } + + /** + * Change the class of the pin button to make it look 'up' or 'down' + * + * @see addPin(), syncPins() + * + * @param {Object} inst Layout Instance object + * @param {Array.} $Pin The pin-span element in a jQuery wrapper + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin true = set the pin 'down', false = set it 'up' + */ +, setPinState: function (inst, $Pin, pane, doPin) { + var updown = $Pin.attr("pin"); + if (updown && doPin === (updown=="down")) return; // already in correct state + var + pin = inst.options[pane].buttonClass +"-pin" + , side = pin +"-"+ pane + , UP = pin +"-up "+ side +"-up" + , DN = pin +"-down "+side +"-down" + ; + $Pin + .attr("pin", doPin ? "down" : "up") // logic + .attr("title", doPin ? lang.Unpin : lang.Pin) + .removeClass( doPin ? UP : DN ) + .addClass( doPin ? DN : UP ) + ; + } + + /** + * INTERNAL function to sync 'pin buttons' when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), close() + * + * @param {Object} inst Layout Instance object + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns: function (inst, pane, doPin) { + // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(inst, $(selector), pane, doPin); + }); + } + + +, _load: function (inst) { + var _ = $.layout.buttons; + // ADD Button methods to Layout Instance + // Note: sel = jQuery Selector string + $.extend( inst, { + bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); } + // DEPRECATED METHODS + , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); } + , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); } + , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); } + , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); } + }); + + // init state array to hold pin-buttons + for (var i=0; i<4; i++) { + var pane = $.layout.config.borderPanes[i]; + inst.state[pane].pins = []; + } + + // auto-init buttons onLoad if option is enabled + if ( inst.options.autoBindCustomButtons ) + _.init(inst); + } + +, _unload: function (inst) { + // TODO: unbind all buttons??? + } + +}; + +// add initialization method to Layout's onLoad array of functions +$.layout.onLoad.push( $.layout.buttons._load ); +//$.layout.onUnload.push( $.layout.buttons._unload ); + + + +/** + * jquery.layout.browserZoom 1.0 + * $Date: 2011-12-29 08:00:00 (Thu, 29 Dec 2011) $ + * + * Copyright (c) 2012 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * @todo: Extend logic to handle other problematic zooming in browsers + * @todo: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event + */ + +// tell Layout that the plugin is available +$.layout.plugins.browserZoom = true; + +$.layout.defaults.browserZoomCheckInterval = 1000; +$.layout.optionsMap.layout.push("browserZoomCheckInterval"); + +/* + * browserZoom methods + */ +$.layout.browserZoom = { + + _init: function (inst) { + // abort if browser does not need this check + if ($.layout.browserZoom.ratio() !== false) + $.layout.browserZoom._setTimer(inst); + } + +, _setTimer: function (inst) { + // abort if layout destroyed or browser does not need this check + if (inst.destroyed) return; + var o = inst.options + , s = inst.state + // don't need check if inst has parentLayout, but check occassionally in case parent destroyed! + // MINIMUM 100ms interval, for performance + , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 ) + ; + // set the timer + setTimeout(function(){ + if (inst.destroyed || !o.resizeWithWindow) return; + var d = $.layout.browserZoom.ratio(); + if (d !== s.browserZoom) { + s.browserZoom = d; + inst.resizeAll(); + } + // set a NEW timeout + $.layout.browserZoom._setTimer(inst); + } + , ms ); + } + +, ratio: function () { + var w = window + , s = screen + , d = document + , dE = d.documentElement || d.body + , b = $.layout.browser + , v = b.version + , r, sW, cW + ; + // we can ignore all browsers that fire window.resize event onZoom + if ((b.msie && v > 8) + || !b.msie + ) return false; // don't need to track zoom + + if (s.deviceXDPI) + return calc(s.deviceXDPI, s.systemXDPI); + // everything below is just for future reference! + if (b.webkit && (r = d.body.getBoundingClientRect)) + return calc((r.left - r.right), d.body.offsetWidth); + if (b.webkit && (sW = w.outerWidth)) + return calc(sW, w.innerWidth); + if ((sW = s.width) && (cW = dE.clientWidth)) + return calc(sW, cW); + return false; // no match, so cannot - or don't need to - track zoom + + function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); } + } + +}; +// add initialization method to Layout's onLoad array of functions +$.layout.onReady.push( $.layout.browserZoom._init ); + + + +})( jQuery ); \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif new file mode 100644 index 0000000000000000000000000000000000000000..085ccaecaf5fa5c34bc14cd2c2ed5cbbd8e25dcb GIT binary patch literal 1553 zcma)+TTl~c6vwlh>nb99Af5rT)t{mCEg5urg=A(g z{C|6SPb~9Xage|wB`SrZk2FOMYM!buln2sX?5Y+T78iB(Zu9cS7|LZyZ++}u$^oi1 z_j@S}bW9OzU2R+RMy&~OT>X-oZ98$jq#ogNfJ!BM-42wHGZk*6s2KD}U*IA%epmxb zm}|6BK9YoIF;*xSL!+z@<64lB7->LTW2Vi4ostCA(z&2XniwNIv}fFo-`MbG;)u4G z^p@F!)|9HhZprHd_vXjDoxs6WkK-6P0@lfxnGT>*p(QHoUV=u1FAqb@b%*W=a3{`LsH5k^AvQNL>6fPpy#oU(&MuH(*aEX4b35*} zn4n7)`I2U%=+Z=?BVZQ?vjQFW4gD@~XSOO6b{qu81`4&LFuU2(ilxW+1|ZkNMnWe79C$gs zWT?Ele|HR{JGPe)5BTW>0Ey?-Ls6S#GoV0tbt6ku7B&*0 z;i9QM$W1Rj*rRIdceL)rAOSl+sDe3LkB87<%){;ZdHp6|SNlopDXRx< zxBDF9-lTo&v`8$humFygUij@qgT=Qzhj8{ym2-{Xciwqq_Xwk%=O3B-MNAL_6e`3U zyxwmXex4`g0^1RYw~Dth3av3Dl^AAlpO3mG!nLr#&ZZ7c_wUboI+deC+&%TFjK2Lm z!Y&f1h|T_On%RCV&=4bx`!>(YezqGVhl&QpED?N6GV)HmzJ9&rh$x*i?*@o9#6QI< z5ZI_MRX;0+pY8$`j)eF#TlUyG(eE%E7S!rj;mj^M5vhUicPm zVWQ2z+imFyg}SRABmOBY_@osR!>7Ov!ioK`NB6_Rv}7Ud?35ed5Sb@?yND?kv~RCa wqs^a3Sh>&&L4)!LKI?D2&k@))k(LESaga|C278ChSzn3NWVkcuNoY&{0f?~U_5c6? literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100644 index 0000000000000000000000000000000000000000..5b5dab2ab7b1c50dea9cfe73dc5a269a92d2d4b4 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F!3HG1q!d*FscKIb$B>N1x91EQ4=4yQ7#`R^ z$vje}bP0l+XkK DSH>_4 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png new file mode 100644 index 0000000000000000000000000000000000000000..47acaadd737478ddb090f47f618810712163317b GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F!3HG1q!d*Fsaj7L$B>N1x91EQ8x$BA993)+ za~~)OO5|O5sDCi_{N8&XlRv*c;OQ6|AR59NN?mFzWBXJVGojypu|S6~c)I$ztaD0e F0syyrGF|`x literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..9d149b1c61fdee2de5cb342741c243abb9058bb3 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAGVZ#9R3S1u{Kd978O6pI&z4VlotPxp?2+ z_9ElQf7546?+BK3Q+%u|q&R!~TD`8c>Nm?7lq=+T^Fw3At=o;a{QQ?&v0rW43t78u zKLhT~Z`;~2oo9{ezlW>%eD?g@v!}03FhOcY)5-`I-U~CHGCzC3{y9?4*Y0Z~JJ3=F MPgg&ebxsLQ09`{nxc~qF literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..014951529c315d6042e72febc310a4d2db5b4a82 GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAK^akKnouq?|lm978O6-<~(*YA_IRxoBVf zfAX@vsV!R#l$@#*eLnw)_Sv|_?i7P!ORnX)SxaXh+BPpZ!Fw~yjr&#G|Jw^YMHDhV X&EsZx`7bsSXc~j3tDnm{r-UW|&(SK+ literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..4443fdc1a156babad4336f004eaf5ca5dfa0f9ab GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAK^akKnour0hIh978O6-<~(*YA|4MzBvER z|7}eQtdCVXoUc2b{PaWeaIKu7gJx>{vDV26o)#~38k_!`W=^oo1w6ixmPC4R1b Tyd6G3lNdZ*{an^LB{Ts5`idse literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png new file mode 100644 index 0000000000000000000000000000000000000000..81ecc362d50ef5abbc0420aacd5345822f1f6098 GIT binary patch literal 3457 zcmb7Hc~FyQ{ttEAS{+2H6+w~K2vj0cZV^b5fVt)XuC7JvopV${pbC@&olEr?>nFQTyMtr zt`4e4w2lA(097YPI}ZRrWlMPjVS53Hs9(fjYkM{>RDl)}YR#{PI{UAXZZ)e7~Wr)BPK4TRcVqm-}EA=rOqdBHQ7fG}5`;N!#WGTYp3F`bEb2my*vF(>I zKqcn9+(yT|Zo>xNL6U)j@WJ-m|9JBc{X&|g06KY<5Vn-3g!f3!7zIEeDwx{*>rJf?MGbRV3&=hgpu4$Sz=YF`qNtN`$D^h1QdwMxGr% zZ3amx2KVP-^P=*M9Hjn*h$;!RZn7^TdN8I-D@%_o4G@Cv=J?bBDXND0bn~jt$r97v z`wte$jnvS&pZ6PMetmn99+6T9P7(Oj-P$m%4B#~atw`D|}>FjiMd#aasA=AiC!kx=f!;*(7XLHJ;FfclH-IIS2+{z=mLvYTEdt#Y}|;8MFIF zHGfd?g;afd-z(1Bl5m@6k`^rcueYCndy(aRcp#_C+6}fQTXhe`zQ)K`HhX)OaU9xCZ_0{kd zB3o7D{o6=8lfJK*$+0~T+UBP6<0EMGw``EV;9(wBBe^{RlHOt$hMu!u4W7%_MCLo9s-?$$rb)w; zDo_c$xHPv1A-TWmTka<+F!#-PR(N!bZqy5-kymvzt+}*y(v|n7^ZikoLW-T=oswho zY0G;K`#%Tk23+#XV@=VfkYQ&_SaQLOvYw(8OkM!2&4xv}0<*9|t515=TqrAX^Y^8X zhQ=u666u7SkBaJkr!OsKTT^f$0pe-6B?01p*;z(P3vGEi2RoOfK(5EIvkEQyS5vr) z)`6aVPW*sg$c?E?)_mb&;sJOiYsi6k)R}5QaBM{Yt#g?lD}HfVNJ4yN7eXTX57kzY zA&dN6R3?GaQ~5Bv7jEaC%z4i6@sfp^02e2;SQ=;g?9E(ZSZBTSh3rC**wVV2>$@Wc zmCO|s-InBMs}XWmuUZoW2#Ox9%r*Vtrv6%EPC|p5E}>k6+!^UXUvB>YExTrrIP+d0 z@zP{o$yU`2ae$H7ty|oFUm!vNi_Gr`sQ+Mq=H+d4%qVIkI>8)(1%RmZr zFBTjIZk7Ah`yYc2h^?-N^xFi;(uzm&Fc&-11QBVFN zlDzAlF}Xa!IaN;%tl;Y4bCxxq{2D>+x>Q#S+6xL1Lgxy`er;oR)@h6#1*OO=+^Cxk z<}cRUBMX-&8L>yfue%wld&E%zj}Cd41RtLZqr9XT3KN`_PO_`l7JO}*!Hl$rN)MkR zN^stHb6!J*uZ$FXY3yFM*ZT7z`9i`woFRodIsd4LcfJBWamv*MFk=&V4eJFyvPPlb zxEKy|pGcIS5HK2_xH)`uy0?`;K6fgpl0=`_k7hRJi$_-QuUm0dB!ONw*G5D29#ibZ1R? zsGL((=KR|&B3^!dV4`0avoJ7@qiR1DQ~hin`rb-{UwM)g4=xpjG&1RIt84O6;;y;4 zn~?#9?S)IZJ~|vL0HFK<<4Jpzj?)dFa{-yIm!NMZ?8V1Rzc&tN+Q;Pm;sNY&B58(|A}8 zI!;7h)hD5l#{)^z4=&rzKEqOa9pcLIG?_P!tl4}GGSTL3gW%WP$$3l|hW8)|{!1T{jBfHF3gp50 z!s>p`h;Ph?T9tNEIlfUz{r1BO{N%ls(-ojZW%Js#_@VbhJ@_;A1m>0#A1P~u*Q-C0 zZYKFdKl|n0&G*3oAM~=jK7RDUQ1J)#m*z1}FudlR-%M;0rO3v@KZ}%=TIiqx$eRMLP8buA!H{z0{I$a=Y_&JgXnwdW9(26fjVHP#uYm>|0(Tqv_zQk*@iV*s6box`l# zsWn(Z%0l9D(<{@$D;EDKM1Q*Z%!v=>^3OIj93?rVrTpxqnPFH2+KVgU96SxOor-p5 z1z(S_ehrVo8*jCkX|k6d-eY6g(>1=qHn-avlCyf8z~O00j7qTmY>j#WO?=)`{xv^2AxjfI6 zQtwjz+u;O*wyv^NHzftX*P*ZQU-Z zJ!I~SvPUm)V~iTy*cD{R1uKr?VG(j4SL?)9bGz(3bbknGhpOD*>^`F-7tK$IOhv#Q z5IPW%I(RyG^9}D%Wj7Ffdq?(WDxbZ9a%cUT_;39?olYP2-@q^TiA&OMX&RT01)BWm zm6fr?+1NG3VChXc^I*p6Y17!m;YR9PcbcV%WjQ5c(WbD8xpF6fOEmy?nZjM{*TaoB z_N~rgpNpuc8u1g|1nnTiT6HQtH-lR6_JvH88n4yQy2Jck9DKf_b(RZSFo50p3I{^_9#FH@g zg*dDNvGk3SHk&VTv&!)=AqYe}B&9CWHGltuWdHF8BiQRId=K(;*}1R+}Z$C%HZkh=d#Wzp$Pz8A{XNT literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..6f4bd87c041453ef037c4a9a1a698f0105d02eba GIT binary patch literal 4369 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..09d1cdc856c292c4ab6dd818c7543ac0828bd616 GIT binary patch literal 4369 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..bd2cf079add1ca236adeb509698adabbffb08acb GIT binary patch literal 4369 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..c7c53cb11904843e176e4ce1f4e7247cd90b3590 GIT binary patch literal 5355 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 t>_S@PWkKlK01oMw@pjEVpN literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder-closed.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder-closed.gif new file mode 100644 index 0000000000000000000000000000000000000000..be6b59c2bafc37724de6a8904caf8ddb52185f07 GIT binary patch literal 631 zcmV--0*L)bNk%w1VGsZi0OoZ7Zc+gM@owbb(D(J~{kRkV=)C^@`FC9q$-khblVJYv z)5ozv$hAcOfX1|Jz_gHwZxsLR$M*H` z)5VgcjVaB&g#X~Bn}|^6)K>kvApXNk{?U8w>frwL-;#Ym&AMUr=V$)PW&YTa>#Gp{ z$5^hOaMH=J$FMm5$62+73I57t#-KOer4h}bD~WS3yQMU?q;vkxak`{N&AEBc#G?Jc zKK|H{jB+E}qY%KYW|e?Jt%4WhuRrYIzx}uttbPdi>1gcRT)?bi*~ygsy)VYKbl=sl z!LDb`w?4L^YVzd5|KO(4ze~WaWw4)Z<=wvhxEIZ>RsZvV+R0MBjTPX{P^5)3t(IEZ zo(`LK71O>%%$yd@ws6O^WdH2Q^sy2D_NBk8J;AJDcUuPR<<6~{Vg0!m{?dHMvTC`j zfZ5BO|NGMa|Nj6000000000000000000000000000000000000A^8LW004CWEC2ui z01yBW06+)SfOUcbFM}==AarS4f^`T0To+{@4nGeh6)G`B2p9kiNn<+@0|r=5Yepst zIgKY#WJd%9EJPL?t^m4h5ez8-Aqy8z25mic2N?k#R&i4b8U+nh4l7`S2^}ajGc6+$ z6C!V6UyXu5K{9S7=8Z222f8;D0KLCn3s7|l^;H1@N?@2FHGqSVIadS#=nw*efr3kz ztU4o2N*xdYmhp(zfYOQwaCBG@bU+OXEtfKR^UfI%4+*Z?OY3oS7i+9AMEg8&*N RE^xJLBxeY_p@ISd06U6)DM0`L literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder-closed2.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder-closed2.gif new file mode 100644 index 0000000000000000000000000000000000000000..541107888e6739a7b367ad3d208e1efa933f877d GIT binary patch literal 105 zcmZ?wbhEHb6ky4lrdiO0bk3ZcRLy6E?4f Hg~1vCyv-@{ literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..be6b59c2bafc37724de6a8904caf8ddb52185f07 GIT binary patch literal 631 zcmV--0*L)bNk%w1VGsZi0OoZ7Zc+gM@owbb(D(J~{kRkV=)C^@`FC9q$-khblVJYv z)5ozv$hAcOfX1|Jz_gHwZxsLR$M*H` z)5VgcjVaB&g#X~Bn}|^6)K>kvApXNk{?U8w>frwL-;#Ym&AMUr=V$)PW&YTa>#Gp{ z$5^hOaMH=J$FMm5$62+73I57t#-KOer4h}bD~WS3yQMU?q;vkxak`{N&AEBc#G?Jc zKK|H{jB+E}qY%KYW|e?Jt%4WhuRrYIzx}uttbPdi>1gcRT)?bi*~ygsy)VYKbl=sl z!LDb`w?4L^YVzd5|KO(4ze~WaWw4)Z<=wvhxEIZ>RsZvV+R0MBjTPX{P^5)3t(IEZ zo(`LK71O>%%$yd@ws6O^WdH2Q^sy2D_NBk8J;AJDcUuPR<<6~{Vg0!m{?dHMvTC`j zfZ5BO|NGMa|Nj6000000000000000000000000000000000000A^8LW004CWEC2ui z01yBW06+)SfOUcbFM}==AarS4f^`T0To+{@4nGeh6)G`B2p9kiNn<+@0|r=5Yepst zIgKY#WJd%9EJPL?t^m4h5ez8-Aqy8z25mic2N?k#R&i4b8U+nh4l7`S2^}ajGc6+$ z6C!V6UyXu5K{9S7=8Z222f8;D0KLCn3s7|l^;H1@N?@2FHGqSVIadS#=nw*efr3kz ztU4o2N*xdYmhp(zfYOQwaCBG@bU+OXEtfKR^UfI%4+*Z?OY3oS7i+9AMEg8&*N RE^xJLBxeY_p@ISd06U6)DM0`L literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder2.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/folder2.gif new file mode 100644 index 0000000000000000000000000000000000000000..2b31631ca2bfec3a8afb1bfdd4f8ed4c5bcc3a18 GIT binary patch literal 106 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-gray-line.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-gray-line.gif new file mode 100644 index 0000000000000000000000000000000000000000..37600447dc002bbc0dd16e1391b711360aae2e34 GIT binary patch literal 1877 zcmeH``8OK|0LL@bF~qSc#n50?JXNI+k>{#)#go3O{g`&sTA06+?`JRv{%1VB*=kSggPTmbZ?E2@Hm10RaqGJr~M_swEK9(fuU z9bXMur@nY#Xn3Qp;v6X2AT> zA>EM+>y@m1^a49s_E1X&+bZH^!_a=e{N6Su)s&U>sDnd!~=b?JFEB#FT8 zioZMFaK52~t&52oqdWW~2MJ1ue%%?en#qCfU7u!nC|sSJi5E`}X3h8)ly{+5*|mp+ zYqNE`8MkZN-)k};oze-j%*tB&sNuZif|=0wM%!=l0sXF(V)Zg+3_ zjbW;EBEX2ytHG=$Dx2Ha{HE%5V3a1hHnd2R32m%R*9#gFWf^4tEW&~!6yIiV)*e*l zireg~b4-8KL1b9Tn<4TQc-aUN7>=bBxE!0Aep)ES$dA>bZ zlac_>GSf$}Amq|xpG2f_X<$)PU0E=BExZ&}FuYP8&bwD%fgJCOsK5%!A}jIpO{>+( zGV75wBp|A>JOyOlNY1dq-7SE-P1iq3bVQx6%Yk<{*5}84F?-+_`Yq}S#U}_=SCzX? zX`+&GsCqhDsvFh7AWWM#ck=(Rps}W(-f3)-hf$w$i>58wymeug)RAsnbE^=j9L-?f zpi-Z);Tuuyqj4L}9YcZxTIWO&p4K%*X3?0-?f4ef8jtm%XgkyEBd6Ds8uOK?%`{)>0D(Cr`A4IcZoG`&U18YKqjoYtzQo|Dt=**7zk597IbK9sJXFyhNi zwtW@gRcSW?gGKMW@kxrlG#OY-do~qJ*-V&3Js8`Y3GYwom_@$iB+g=ml}U5>1u1QR zAzAiA(jrL>&74Uwwqm}`xJ1AT;O_GsONn5#!*ULyhq;oEIkp%2g#mF(6lf@Jxhn4i zV~t87;8y4{2KZG5ao+KL=SUTJlQq*4|E@_PjJ3`!o(GG)^}?JsMpy*)mQYPCf1;Sk`8-A8at@Xm#Gb>oe(v%3b{156)aykj?nu&|IbZfh z!lZx$?iVd}BHwuNSkmco3iwy5Drr$xV-lid6PqT(u95$N>8c#Jm2RMN_SB1WJe9Oq z(x$uU@TQLQX@QVr>U~Sa;vEmbZ_QL7odp^*-BsqVXSqmf)oqYES3tl*66F0YO=#d1 rlgk$~puxAlhuJ^ZHqgioD1o1DVtQEUit~KllU0$5nh)jV0N{TCC3Zqn literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-gray.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-gray.gif new file mode 100644 index 0000000000000000000000000000000000000000..cfb8a2f0961b880d9ecc9e59f831d0c0bf9d06db GIT binary patch literal 1230 zcmZ?wbhEHbOkikb_|5F}1vNN-#bFE}n2rob1X65+pkEe*DZwLSXy)sc-G6LrLE|#j%ny@ltx#{|>*k3`b zudj+f+$8$@s#fHh^zF++cYjOsT#=i)PgZ*SBbQFk<=6g7TzYe_x%fYqoR5WW_>5Nf zsIRkcJbHA@c(c>D3XzqU)=k#8J9nngIK5|{y|vw$2$RE?mT4~XtDRLEe|<_~c?_?$ zLGJZ!!S{W4%zp58Z=>w%X})`Qe0&`0sXRUALwVLJuj#KvHA1S2+ow&BYJYdfr2O^1 zna!)!@5=7^`T51=)#j2iwbhrWRX*39_q(R{^Y??#w#k`8!n#b?Ah=gT4^b_6Je!p-pqnUi6)T{Kw4)JLb3tD)cb}Z;R&ALM=NKo^J zQum3S7LQAK7iB!^v-vhdvhxz-&N&k%mqtvOXdV2 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-red-line.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-red-line.gif new file mode 100644 index 0000000000000000000000000000000000000000..df9e749a8f1f58862588efc64988003efad01d51 GIT binary patch literal 1877 zcmeH``BxGK0LPh{$5cGF%CuRcF0W^1+Eb91Y0har@ns%QJPI-bCps}CP-u#GY96he zH{=x}8cR_?6wMSBHp}~@d8B5Ec_ztT`#0A2hwu02&*#0br`JzT&Np-c8>+j2FWJW9 z|J$$i)xiJGfXTkfHvoVFVDp9i%O?Qp3V=f6d5==7Sk4KMl>Ucik`YxtvJ<)$%#TPKR% zdeBegW3Nr-TZ$_DvX!7#=EQu`)|{{_NO4?Hnuz--`I}N3UjF&+?uwLk+=>GJd{B_Tc2OKbjN9H> z96NPSF%oo|+^NT@plDh-RsN>!ws$&N>eV+-RSK`GN-+xQlcpP|{VXMbZmGY?Sg+bE z&yqDeRb-m~Xn;($Rkc9os0lNWR0x7V&viYtFw425?`)O{#Xnxi^Z-rV%z`xuPf1K3U`ignx^9LiY{9RF`M1 z((4&CBBq9gRTxIqvdNQH4XvU-teM=&r#I{BRpE@Mf`UowW*aYDTj; zR~d}wJj7bmv%$EvhL%3@95+YnP@jZFjkyaK?LZqem&Cp}E@#J}7%>obDszfKXbSed{!N zqe%A5h1G9<<|OWgt(pyPNUi%mt_OllWQ$!DHV#9VzJogSLla83`aMi%;zcml$vXr7 zf<%YcL08HgN8s@2tufz(==0;jh0Ny@q4f1T-P5MdE9;FzHSA-Pm3Wn^KX5K-#%-h+YndE*c}A#} z97|nymmXX*xOhw~p_=<#*Rp;q1c;i_)TkyvQ;xgVtY5mTyh_&|ZEzU`%%?)%UDt;N sUpBjNE)^Df<9oQ%i{r+6SwTgJWAz*lYeQMK?>m|{T3!EviV6VoFXq=mv;Y7A literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-red.gif b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/images/treeview-red.gif new file mode 100644 index 0000000000000000000000000000000000000000..3bbb3a157f1568d59d6db02b55a3b3fe9a1ff7a7 GIT binary patch literal 1230 zcmZ?wbhEHbOkikb_|5q9rFMYXq;dkzBCUd%AXV z7f->2WoKqf=UU0E5MF-1&C2oHA5RfQ-wyu&du5`wWCYCfT`X0jHDP7Qa?|x$vA=>= zUtbk}xJmT)RjtT1>D!lu?*5kMxgs}ppRDxuM=qV7%dh>Fxb)^;bMb#JIUft%@ENV{ zQD0}@c=YI)@n)xQ6(TDyt(&ZGckWD~aeB`@duzKh5hjN(Ez?}&S39dT{`!=}@)%xg zgWT)eg75q8nEl}G-bUHi(|q^r`1m-~Q+ayKhw`jdUejNTYJ^l3w@;fM)&A~|N%`x2 zGn-ed-<93-^Ye?#tIZ{4YO60#t9-6I?{`h@=kEuf$II8+R(@HSYaUSgyf$2+OgK}0 zZsRjUi+L5dHILtK5edt9=qI|b{eIzIMl<7PRm>?O4!tnstX#kf7!b zrS20uEgqNfF3Nb+XY*}_WalNuopUBkE{&Kl(L5+ZuF(6`HI*Fyu5b4nE$kweHiYk+ hA)Dse=Ki!azG~*body { + font-size: 16px; + font-size: 68.75%; +} Reset Base Font Size */ + /* +body { + font-family: Verdana, helvetica, arial, sans-serif; + font-size: 68.75%; + background: #fff; + color: #333; +} */ + +a img { border: none; } \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/jquery.treeview.min.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/jquery.treeview.min.js new file mode 100644 index 000000000000..e693321dd0bd --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/jquery/treeview/jquery.treeview.min.js @@ -0,0 +1,16 @@ +/* + * Treeview 1.4 - jQuery plugin to hide and show branches of a tree + * + * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ + * http://docs.jquery.com/Plugins/Treeview + * + * Copyright (c) 2007 Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $ + * kasunbg: changed the cookieid name + * + */;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("

      ").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){if(typeof(window.treeCookieId) === 'undefined' || window.treeCookieId === ""){treeCookieId = "treeview";} settings=$.extend({cookieId: treeCookieId},settings);if(settings.add){return this.trigger("add",[settings.add]);}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}function serialize(){function binary(arg){return arg?1:0;}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}break;}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery); \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/main.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/main.js new file mode 100644 index 000000000000..5957fb435d69 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/common/main.js @@ -0,0 +1,276 @@ +/** + * Miscellaneous js functions for WebHelp + * Kasun Gajasinghe, http://kasunbg.blogspot.com + * David Cramer, http://www.thingbag.net + * + */ + +//Turn ON and OFF the animations for Show/Hide Sidebar. Extend this to other anime as well if any. +var noAnimations=false; + +$(document).ready(function() { + // When you click on a link to an anchor, scroll down + // 105 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link within a page. + $('a[href*=#]').click(function() { + if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') + && location.hostname == this.hostname) { + var $target = $(this.hash); + $target = $target.length && $target + || $('[name=' + this.hash.slice(1) +']'); + if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv" || this.hash == "") && $target.length) { + var targetOffset = $target.offset().top - 120; + $('html,body') + .animate({scrollTop: targetOffset}, 200); + return false; + } + } + }); + + // $("#showHideHighlight").button(); //add jquery button styling to 'Go' button + //Generate tabs in nav-pane with JQuery + $(function() { + $("#tabs").tabs({ + cookie: { + expires: 2 // store cookie for 2 days. + } + }); + }); + + //Generate the tree + $("#ulTreeDiv").attr("style", ""); + $("#tree").treeview({ + collapsed: true, + animated: "medium", + control: "#sidetreecontrol", + persist: "cookie" + }); + + //after toc fully styled, display it. Until loading, a 'loading' image will be displayed + $("#tocLoading").attr("style", "display:none;"); + // $("#ulTreeDiv").attr("style","display:block;"); + + //.searchButton is the css class applied to 'Go' button + $(function() { + $("button", ".searchButton").button(); + + $("button", ".searchButton").click(function() { + return false; + }); + }); + + //'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('ui-tabs-1') === '1') { //search tab is active + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + searchHighlight($.cookie('textToSearch')); + $("#showHideHighlight").css("display", "block"); + } + } + + syncToc(); //Synchronize the toc tree with the content pane, when loading the page. + //$("#doSearch").button(); //add jquery button styling to 'Go' button + + // When you click on a link to an anchor, scroll down + // 120 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link from another page. + var hash = window.location.hash; + if(hash){ + var targetOffset = $(hash).offset().top - 120; + $('html,body').animate({scrollTop: targetOffset}, 200); + return false; + } +}); + + +/** + * If an user moved to another page by clicking on a toc link, and then clicked on #searchDiv, + * search should be performed if the cookie textToSearch is not empty. + */ +function doSearch() { +//'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + } +} + +/** + * Synchronize with the tableOfContents + */ +function syncToc() { + var a = document.getElementById("webhelp-currentid"); + if (a != undefined) { + //Expanding the child sections of the selected node. + var nodeClass = a.getAttribute("class"); + if (nodeClass != null && !nodeClass.match(/collapsable/)) { + a.setAttribute("class", "collapsable"); + //remove display:none; css style from
        block in the selected node. + var ulNode = a.getElementsByTagName("ul")[0]; + if (ulNode != undefined) { + if (ulNode.hasAttribute("style")) { + ulNode.setAttribute("style", "display: block; background-color: #D8D8D8 !important;"); + } else { + var ulStyle = document.createAttribute("style"); + ulStyle.nodeValue = "display: block; background-color: #D8D8D8 !important;"; + ulNode.setAttributeNode(ulStyle); + } } + //adjust tree's + sign to - + var divNode = a.getElementsByTagName("div")[0]; + if (divNode != undefined) { + if (divNode.hasAttribute("class")) { + divNode.setAttribute("class", "hitarea collapsable-hitarea"); + } else { + var divClass = document.createAttribute("class"); + divClass.nodeValue = "hitarea collapsable-hitarea"; + divNode.setAttributeNode(divClass); + } } + //set persistence cookie when a node is auto expanded + // setCookieForExpandedNode("webhelp-currentid"); + } + var b = a.getElementsByTagName("a")[0]; + + if (b != undefined) { + //Setting the background for selected node. + var style = a.getAttribute("style", 2); + if (style != null && !style.match(/background-color: Background;/)) { + a.setAttribute("style", "background-color: #D8D8D8; " + style); + b.setAttribute("style", "color: black;"); + } else if (style != null) { + a.setAttribute("style", "background-color: #D8D8D8; " + style); + b.setAttribute("style", "color: black;"); + } else { + a.setAttribute("style", "background-color: #D8D8D8; "); + b.setAttribute("style", "color: black;"); + } + } + + //shows the node related to current content. + //goes a recursive call from current node to ancestor nodes, displaying all of them. + while (a.parentNode && a.parentNode.nodeName) { + var parentNode = a.parentNode; + var nodeName = parentNode.nodeName; + + if (nodeName.toLowerCase() == "ul") { + parentNode.setAttribute("style", "display: block;"); + } else if (nodeName.toLocaleLowerCase() == "li") { + parentNode.setAttribute("class", "collapsable"); + parentNode.firstChild.setAttribute("class", "hitarea collapsable-hitarea "); + } + a = parentNode; +} } } +/* + function setCookieForExpandedNode(nodeName) { + var tocDiv = document.getElementById("tree"); //get table of contents Div + var divs = tocDiv.getElementsByTagName("div"); + var matchedDivNumber; + var i; + for (i = 0; i < divs.length; i++) { //1101001 + var div = divs[i]; + var liNode = div.parentNode; + } +//create a new cookie if a treeview does not exist + if ($.cookie(treeCookieId) == null || $.cookie(treeCookieId) == "") { + var branches = $("#tree").find("li");//.prepareBranches(treesettings); + var data = []; + branches.each(function(i, e) { + data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0; + }); + $.cookie(treeCookieId, data.join("")); + + } + + if (i < divs.length) { + var treeviewCookie = $.cookie(treeCookieId); + var tvCookie1 = treeviewCookie.substring(0, i); + var tvCookie2 = treeviewCookie.substring(i + 1); + var newTVCookie = tvCookie1 + "1" + tvCookie2; + $.cookie(treeCookieId, newTVCookie); + } + } */ + +/** + * Code for Show/Hide TOC + * + */ +function showHideToc() { + var showHideButton = $("#showHideButton"); + var leftNavigation = $("#sidebar"); //hide the parent div of leftnavigation, ie sidebar + var content = $("#content"); + var animeTime=75 + + if (showHideButton != undefined && showHideButton.hasClass("pointLeft")) { + //Hide TOC + showHideButton.removeClass('pointLeft').addClass('pointRight'); + + if(noAnimations) { + leftNavigation.css("display", "none"); + content.css("margin", "125px 0 0 0"); + } else { + leftNavigation.hide(animeTime); + content.animate( { "margin-left": 0 }, animeTime); + } + showHideButton.attr("title", "Show Sidebar"); + } else { + //Show the TOC + showHideButton.removeClass('pointRight').addClass('pointLeft'); + if(noAnimations) { + content.css("margin", "125px 0 0 280px"); + leftNavigation.css("display", "block"); + } else { + content.animate( { "margin-left": '280px' }, animeTime); + leftNavigation.show(animeTime); + } + showHideButton.attr("title", "Hide Sidebar"); + } +} + +/** + * Code for search highlighting + */ +var highlightOn = true; +function searchHighlight(searchText) { + highlightOn = true; + if (searchText != undefined) { + var wList; + var sList = new Array(); //stem list + //Highlight the search terms + searchText = searchText.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, "I$N~E8N^zO~Pw;a^(H|lo|{Z2pXH!s%dfd}c>`i1a} zv}w~u+O=z^&ucH8I(3rHojXg{u3e>Dw{8*;5FkBz^pKuCdrDwnp!Dg}NBZ{dEB*TQ z6Nkeg0|pF`prAoAc<^8uHf*StVKRL9a2YvrgqD#qdh{p>4GoboW5&q%@jsOb6UNKL zi9gdaQ6^2AB$FpkmZ?*xNO*X-L`Fu+^y$Bp88fEKtXVU)%#sg3oF&oGQ8IgWw9KDB zPs@B+u;4ecaNzt(}+4YG0LAI0POlNOI`@@$gLn>WkWty^W=wr#RKF;TW}-yu78?2ylPeI~ni@0LA# z_Gn3xq&<5jDQSVbpHow1pOJmCZ{L2| zzkk0RI`n5Pha@d6P14fSB|SY&OS)uaWJqRaretMhNls3#g(&}#*G_t^X5&tb?cVgzI{vX-n}dL z?%k7bzx}s7cC;HDBDMsph1qdetv!((`o7b?{;YGKUdEz%jHZ6 zv#c$>;zP!+HFMWmmmYU{0=tATce>bbS#cp9huibSU}xwMrz7~gd6bnH)iEG2$gFd@ zJYy}(9nkA-M`D7<6YF#(>hm}CcMNiS65O6GA54gHMoozRU`S|`t|U=W6Bf^PyW`>( zeLUB_WbTqha~J)u9;eRs)-qNL_1FBx*pl^~qD_9e6q)zZbzybPEX?t%8DrUQ4=n@2+%jQeC=qF~Z#6-(P8( z8EMt3Rm1lV9Xgn2M%LTwSfl%vy7Bj$sjwu+5)t0_|^tKi_DDD!LDm;9u0$<-Bj83<2 z{nO;fh!O7^n~8(X74#qu#0<{kbJpWG+yB_D?;uL||3=v8fuD&b_Mtl?XJHfE!aj7t zFT6v*$M(K``SF#veRv1|N=c9=38e92+=rps~@$$0vM4h#9$K zV>5yYXQ)Ho`1o1hp_=e-#fs$$&VTYrywZ0!6MOQA*n^3!c1_@!c1W;jpi-y>abld`|wsL0|uqAHKRXC$EU7?Pv7BessvrZt61|tGN+O z&b)f{N&`M~@{t_zwVyNK1^$KG`Zs{dV`4~N!a??5yH@|&_LFxCvE>%RaKhWN1tyApEK|ee!F}3U#2dR zd-w!yk|#MiU%qrdXMkzyPr-lt&$@MM4ELz7-nzE*Tw8ltQJ2UA@Tm#Z2>j7p{JhTr zpZp}&S4!fq}EYe$PMg6A8HUafc_3w>BH~8Kgq12FTYML06*u; zye9ZI2W|c^k{9Sj{^MV`2ItU&e5AipH^D|t&;Dzc2r=hn#9|FL{OiV8S_c*tTt}sfFBI;6HkzJ9U&= zNPaP1tG{OKV&psc{O+*tKlqvc0k>M>Keo|t!Nf%1@CAb2oJntiTksWu>-Gp| zz&}~~b))+q^^+K*haG=!Kj^=Qn7bdorWbR^CMNg{{@HQIJ}`(Q@g-b#_ci}7F>~;LEW*zo0GUu5+Ji~wXu%D6o_uZcXzPI5&U0{b) literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/images/sample.jpg b/core-java/src/test/resources/docbook-xsl/webhelp/docs/images/sample.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d8ec5c311243ad66e28e8b86ee439db9ed6d5589 GIT binary patch literal 78931 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�lJnlbk@ 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/index.html b/core-java/src/test/resources/docbook-xsl/webhelp/docs/index.html new file mode 100644 index 000000000000..a0be769e1882 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/index.html @@ -0,0 +1,179 @@ + + + + +README: Web-based Help from DocBook XML -
      +
      +

      README: Web-based Help from DocBook XML

      + +

      Kasun Gajasinghe

      +
      +

      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.

      • Except as contained in this notice, the names of individuals credited with + contribution to this software shall not be used in advertising or otherwise to promote + the sale, use or other dealings in this Software without prior written authorization + from the individuals in question.

      • Any stylesheet derived from this Software that is publicly distributed will be + identified with a different name and the version strings in any derived Software will + be changed so that no possibility of confusion between the derived package and this + Software will exist.

      Warranty: 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 DAVID CRAMER, KASUN GAJASINGHE, OR ANY + OTHER CONTRIBUTOR 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 package is maintained by Kasun Gajasinghe, + and David Cramer, + and with + contributions by Arun Bharadwaj and Visitha Baddegama. Please + direct support questions to the DocBook-apps + mailing list.

      This package also includes the following software written and copyrighted by others:

      • Files in template/common/jquery are + copyrighted by JQuery under the MIT License. + The file jquery.cookie.js Copyright (c) 2006 Klaus Hartl under + the MIT license.

      • Some files in the template/search and indexer directories were + originally part of N. Quaine's htmlsearch DITA plugin. + The htmlsearch DITA plugin is available from the files page of the DITA-users yahoogroup. The + htmlsearch plugin was released under a BSD-style + license. See indexer/license.txt + for details. +

      • Stemmers from the Snowball + project released under a BSD license.

      • Code from the Apache Lucene search + engine provides support for tokenizing Chinese, Japanese, and Korean content released + under the Apache 2.0 license.

      • Code that provides weighted search results and some + other improvements was graciously donated by SyncRO Soft + Ltd., the publishers of the oXygen XML + Editor.

      • TagSoup, released under the Apache 2.0 + license, makes it possible to index html instead of just + xhtml output.

      • Cosmetic improvements provided by OpenStack.

      Webhelp for DocBook was first developed as a Google Summer of Code project.

      +

      January 2012

      +
      +
      +
      +

      List of Figures

      1. Sample Image
      diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/ix01.html b/core-java/src/test/resources/docbook-xsl/webhelp/docs/ix01.html new file mode 100644 index 000000000000..f0620d2c0eec --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/ix01.html @@ -0,0 +1,128 @@ + + + + +Index - - README: Web-based Help from DocBook XML
      diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/default.props b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/default.props new file mode 100644 index 000000000000..22edf4391592 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/default.props @@ -0,0 +1 @@ +DEF01=a \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/en-us.props b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/en-us.props new file mode 100644 index 000000000000..da284ce5d433 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/en-us.props @@ -0,0 +1,45 @@ +DEF01=this +DEF02=is +DEF03=the +DEF04=in +DEF05=i +DEF06=on +DEF07=a +DEF08=about +DEF09=an +DEF10=are +DEF11=as +DEF12=at +DEF13=be +DEF14=by +DEF15=com +DEF16=de +DEF17=en +DEF18=for +DEF19=from +DEF20=how +DEF21=it +DEF22=la +DEF23=of +DEF24=on +DEF25=or +DEF26=that +DEF27=to +DEF28=was +DEF29=what +DEF30=when +DEF31=where +DEF32=who +DEF33=will +DEF34=with +DEF35=und +DEF36=Next +DEF37=Prev +DEF38=Home +DEF39=Motive +DEF40=Inc +DEF41=Copyright +DEF42=All +DEF43=rights +DEF44=reserved +DEF45=Up \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/es-es.props b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/es-es.props new file mode 100644 index 000000000000..fb73bdcc1fe6 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/es-es.props @@ -0,0 +1,179 @@ +DEF01=un +DEF02=una +DEF03=unas +DEF04=unos +DEF05=uno +DEF06=sobre +DEF07=todo +DEF08=también +DEF09=tras +DEF10=otro +DEF11=algún +DEF12=alguno +DEF13=alguna +DEF14=algunos +DEF15=algunas +DEF16=ser +DEF17=es +DEF18=soy +DEF19=eres +DEF20=somos +DEF21=sois +DEF22=estoy +DEF23=esta +DEF24=estamos +DEF25=estais +DEF26=estan +DEF27=como +DEF28=en +DEF29=para +DEF30=atras +DEF31=porque +DEF32=por +DEF33=estado +DEF34=estaba +DEF35=ante +DEF36=antes +DEF37=siendo +DEF38=ambos +DEF39=pero +DEF40=por +DEF41=poder +DEF42=puede +DEF43=puedo +DEF44=podemos +DEF45=podeis +DEF46=pueden +DEF47=fui +DEF48=fue +DEF49=fuimos +DEF50=fueron +DEF51=hacer +DEF52=hago +DEF53=hace +DEF54=hacemos +DEF55=haceis +DEF56=hacen +DEF57=cada +DEF58=fin +DEF59=incluso +DEF60=primero +DEF61=desde +DEF62=conseguir +DEF63=consigo +DEF64=consigue +DEF65=consigues +DEF66=conseguimos +DEF67=consiguen +DEF68=ir +DEF69=voy +DEF70=va +DEF71=vamos +DEF72=vais +DEF73=van +DEF74=vaya +DEF75=gueno +DEF76=ha +DEF77=tener +DEF78=tengo +DEF79=tiene +DEF80=tenemos +DEF81=teneis +DEF82=tienen +DEF83=el +DEF84=la +DEF85=lo +DEF86=las +DEF87=los +DEF88=su +DEF89=aqui +DEF90=mio +DEF91=tuyo +DEF92=ellos +DEF93=ellas +DEF94=nos +DEF95=nosotros +DEF96=vosotros +DEF97=vosotras +DEF98=si +DEF99=dentro +DEF100=solo +DEF101=solamente +DEF102=saber +DEF103=sabes +DEF104=sabe +DEF105=sabemos +DEF106=sabeis +DEF107=saben +DEF108=ultimo +DEF109=largo +DEF110=bastante +DEF111=haces +DEF112=muchos +DEF113=aquellos +DEF114=aquellas +DEF115=sus +DEF116=entonces +DEF117=tiempo +DEF118=verdad +DEF119=verdadero +DEF120=verdadera +DEF121=cierto +DEF122=ciertos +DEF123=cierta +DEF124=ciertas +DEF125=intentar +DEF126=intento +DEF127=intenta +DEF128=intentas +DEF129=intentamos +DEF130=intentais +DEF131=intentan +DEF132=dos +DEF133=bajo +DEF134=arriba +DEF135=encima +DEF136=usar +DEF137=uso +DEF138=usas +DEF139=usa +DEF140=usamos +DEF141=usais +DEF142=usan +DEF143=emplear +DEF144=empleo +DEF145=empleas +DEF146=emplean +DEF147=ampleamos +DEF148=empleais +DEF149=valor +DEF150=muy +DEF151=era +DEF152=eras +DEF153=eramos +DEF154=eran +DEF155=modo +DEF156=bien +DEF157=cual +DEF158=cuando +DEF159=donde +DEF160=mientras +DEF161=quien +DEF162=con +DEF163=entre +DEF164=sin +DEF165=trabajo +DEF166=trabajar +DEF167=trabajas +DEF168=trabaja +DEF169=trabajamos +DEF170=trabajais +DEF171=trabajan +DEF172=podria +DEF173=podrias +DEF174=podriamos +DEF175=podrian +DEF176=podriais +DEF177=yo +DEF178=aquel +DEF179=qué \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/htmlFileInfoList.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/htmlFileInfoList.js new file mode 100644 index 000000000000..a5efebe71462 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/htmlFileInfoList.js @@ -0,0 +1,38 @@ +var doStem = true; +//List of indexed files. +fl = new Array(); +fl["0"]= "ch04.html"; +fl["1"]= "ch05s01.html"; +fl["2"]= "ch03s02.html"; +fl["3"]= "index.html"; +fl["4"]= "ch02s02s01.html"; +fl["5"]= "ch03s01.html"; +fl["6"]= "ch01.html"; +fl["7"]= "ch02.html"; +fl["8"]= "ch02s01.html"; +fl["9"]= "ch02s03.html"; +fl["10"]= "ch03s02s01.html"; +fl["11"]= "ch05.html"; +fl["12"]= "ch03.html"; +fl["13"]= "ch02s05.html"; +fl["14"]= "ch02s04.html"; +fl["15"]= "ch02s02.html"; +fl["16"]= "ch05s02.html"; +fil = new Array(); +fil["0"]= "ch04.html@@@FAQ@@@Frequently Asked Questions..."; +fil["1"]= "ch05s01.html@@@Some search words for testing@@@null"; +fil["2"]= "ch03s02.html@@@Search@@@Overview design of Search mechanism..."; +fil["3"]= "index.html@@@README: Web-based Help from DocBook XML@@@null"; +fil["4"]= "ch02s02s01.html@@@Recommended Apache configurations@@@null"; +fil["5"]= "ch03s01.html@@@Design@@@An overview of webhelp page structure..."; +fil["6"]= "ch01.html@@@Introduction@@@Overview of the package..."; +fil["7"]= "ch02.html@@@Using the package@@@java available in your PATH..."; +fil["8"]= "ch02s01.html@@@Generating webhelp output using the Ant build.xml file@@@Installation instructions..."; +fil["9"]= "ch02s03.html@@@Search indexing@@@To build the indexer, you must have installed the JDK version 1.5 or higher and set the ANT_HOME environment variable..."; +fil["10"]= "ch03s02s01.html@@@New Stemmers@@@Adding new Stemmers is very simple..."; +fil["11"]= "ch05.html@@@Test section@@@null"; +fil["12"]= "ch03.html@@@Developer Docs@@@This chapter provides an overview of how webhelp is implemented..."; +fil["13"]= "ch02s05.html@@@Adding images@@@null"; +fil["14"]= "ch02s04.html@@@Adding support for other (non-CJKV) languages@@@null"; +fil["15"]= "ch02s02.html@@@Using and customizing the output@@@null"; +fil["16"]= "ch05s02.html@@@Some search words for testing (inflected)@@@null"; diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-1.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-1.js new file mode 100644 index 000000000000..096fcfbb4c42 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-1.js @@ -0,0 +1,391 @@ +var indexerLanguage="en"; +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["-"]="0*2,1*2,2*7,3*1,5*2,6*3,7*2,8*2,9*4,10*2,11*2,12*2,13*2,14*2,15*2,16*2"; +w["-doutput-dir"]="8*1"; +w["-version"]="8*2"; +w["."]="2*5,3*2,4*3,5*5,6*1,7*1,8*11,9*3,10*8,13*2,14*1,15*3"; +w[".chm"]="6*1"; +w[".htaccess"]="4*1"; +w[".html"]="4*1"; +w[".js"]="2*2"; +w[".treeview"]="5*1"; +w["0"]="0*2,3*2,8*5,9*6"; +w["1"]="0*6,3*2,8*3,9*6"; +w["1."]="0*6,3*2"; +w["1.5"]="9*1"; +w["1.6"]="8*1"; +w["1.76.0"]="9*1"; +w["1.76.1"]="9*2"; +w["1.76.1."]="9*1"; +w["1.77.0"]="0*2"; +w["1.8.0"]="8*3,9*1"; +w["1.8.2.custom.css"]="15*1"; +w["172800"]="4*2"; +w["2"]="0*6,3*3,4*2,8*3,15*1"; +w["2."]="0*6,3*1"; +w["2.0"]="3*2"; +w["2006"]="3*1"; +w["2008"]="3*1"; +w["2008-2012"]="3*1"; +w["2012"]="3*2"; +w["290304000"]="4*2"; +w["2:"]="8*3"; +w["3"]="0*8,3*1"; +w["3."]="0*6,3*1"; +w["3.0.0.jar"]="9*2"; +w["3.x"]="0*1"; +w["4"]="0*7,2*1"; +w["4."]="0*6"; +w["480"]="4*1"; +w["5"]="0*8,6*1,8*13,9*1"; +w["5."]="0*6"; +w["596"]="0*2"; +w["596:"]="0*2"; +w["6"]="8*6"; +w["6.5"]="8*4"; +w["6.5.5.jar"]="0*1,8*3"; +w["6.5.x"]="8*1"; +w["7"]="0*1"; +w["7200"]="4*2"; +w["76"]="9*3"; +w["77"]="0*2"; +w["8"]="4*1,8*3,9*1,15*1"; +w[":"]="0*2,10*2,15*3"; +w["_stemmer"]="2*1,10*1"; +w["_stemmer.j"]="2*2,10*2"; +w["abandon"]="5*1"; +w["about"]="0*2,2*2,4*1,8*2,9*1"; +w["abov"]="3*1"; +w["abstract"]="15*1"; +w["accord"]="6*1"; +w["achiev"]="5*2"; +w["action"]="3*1"; +w["actual"]="2*1"; +w["ad"]="2*1,3*1,6*1,7*2,10*3,13*51,14*46,15*2"; +w["adapt"]="8*1"; +w["add"]="3*1,6*1,8*1,10*4,13*1,14*1,15*1"; +w["adddefaultcharset"]="4*1"; +w["addit"]="0*1,4*1,14*1"; +w["addoutputfilterbytyp"]="4*9"; +w["admon.g"]="8*1"; +w["admon.graph"]="8*1"; +w["advertis"]="3*1"; +w["after"]="6*1"; +w["against"]="8*2"; +w["age"]="4*3"; +w["al"]="10*1"; +w["algorithm"]="10*1"; +w["all"]="2*1,3*1,8*1,9*1,10*1"; +w["all."]="10*1"; +w["allow"]="8*1"; +w["alreadi"]="10*1"; +w["also"]="3*1,6*1,7*1,8*2"; +w["altern"]="6*1"; +w["analyz"]="9*1"; +w["ani"]="3*6,10*1,15*1"; +w["anim"]="5*1"; +w["animated:"]="5*1"; +w["anoth"]="8*2,10*1"; +w["ant"]="2*3,6*2,7*2,8*59,9*14,10*2,13*1"; +w["ant.file.dir"]="8*2"; +w["ant_hom"]="8*1,9*1"; +w["apach"]="3*3,4*41,7*1,8*3,15*1"; +w["apache-ant-1"]="8*2"; +w["apache-ant-1.8.0"]="8*2"; +w["apart"]="0*2"; +w["apis.jar"]="0*2,8*9,9*1"; +w["app"]="3*1"; +w["appear"]="6*2,15*1"; +w["appli"]="5*2"; +w["applic"]="4*5,6*1"; +w["applica"]="4*1"; +w["appropri"]="8*1,15*1"; +w["apps@lists.oasi"]="10*1"; +w["ar"]="3*1"; +w["arbitrari"]="8*1"; +w["argument"]="9*1"; +w["arguments:"]="9*1"; +w["aris"]="3*1"; +w["array"]="2*3,3*1,10*7"; +w["array."]="10*1"; +w["arsenal"]="1*1,16*1"; +w["arsenic"]="1*1,16*1"; +w["arun"]="3*1"; +w["ask"]="0*1"; +w["associ"]="3*1"; +w["asspath"]="8*5"; +w["assum"]="8*2,10*1"; +w["assumpt"]="2*1"; +w["attribut"]="0*2"; +w["author"]="3*1"; +w["auto"]="6*1"; +w["auto-synchron"]="6*1"; +w["autoidx"]="0*2"; +w["autoidx.xsl"]="0*2"; +w["autoidx.xsl:"]="0*4"; +w["automat"]="9*1"; +w["ava"]="7*1"; +w["avail"]="3*1,7*1,8*3,9*2,10*3"; +w["away"]="12*1"; +w["back"]="14*1"; +w["backward"]="6*1"; +w["baddegama"]="3*1"; +w["baddegama."]="3*1"; +w["bar."]="15*1"; +w["base"]="0*2,1*1,2*1,3*52,5*2,6*3,7*1,8*1,9*1,10*6,11*1,12*1,13*1,14*1,15*2,16*1"; +w["basedir"]="8*1"; +w["basic"]="0*1"; +w["be"]="8*1"; +w["been"]="8*1"; +w["behav"]="12*1"; +w["below"]="8*1"; +w["below."]="8*1,13*1"; +w["better"]="8*1"; +w["between"]="2*1,3*1"; +w["bharadwaj"]="3*1"; +w["bi"]="2*1"; +w["bi-gram"]="2*1"; +w["bin"]="8*4"; +w["binari"]="8*1"; +w["bit"]="9*1"; +w["bitmap"]="4*1"; +w["bits."]="9*1"; +w["bob"]="4*1,15*1"; +w["bold"]="6*1"; +w["book"]="4*1"; +w["both"]="14*1"; +w["box"]="6*1"; +w["break"]="2*1"; +w["brief"]="6*1,15*1"; +w["brower"]="4*1"; +w["browser"]="0*3,2*1,4*1,5*1,8*1"; +w["browser."]="8*1"; +w["bsd"]="3*2"; +w["bsd-style"]="3*1"; +w["build"]="0*3,1*1,5*1,6*3,7*3,8*59,9*1,10*3,13*1,16*1"; +w["build-index"]="10*1"; +w["build.properti"]="8*1,9*1,10*1,13*1"; +w["build.xml"]="1*1,7*1,8*56,16*1"; +w["build.xml."]="8*1"; +w["built"]="5*1"; +w["but"]="3*1,8*1,10*2"; +w["button"]="5*1"; +w["buy"]="1*1,16*1"; +w["c"]="0*2,3*1,8*3"; +w["c:"]="0*4,8*3"; +w["cach"]="4*5"; +w["cache-control"]="4*3"; +w["call"]="2*1,5*1"; +w["caus"]="4*3,15*1"; +w["certain"]="4*1"; +w["ch03"]="2*1"; +w["ch03.html"]="2*1"; +w["chang"]="2*1,3*1,4*1,8*1,9*1,10*3,15*3"; +w["chapter"]="2*1,12*1,15*1"; +w["chapterinfo"]="15*1"; +w["charact"]="4*1"; +w["charg"]="3*1"; +w["check"]="0*1"; +w["checkout"]="2*1"; +w["chines"]="2*1,3*1,6*1,8*1,10*2"; +w["chm"]="6*1"; +w["chrome"]="0*1"; +w["chunk"]="5*2,6*1,15*2"; +w["cjk"]="2*2,10*2"; +w["cjkv"]="7*1,10*1,14*2"; +w["cl"]="8*3"; +w["claim"]="3*1"; +w["class"]="9*1,10*1"; +w["classpath"]="0*1,8*2,9*2"; +w["classpath."]="9*1"; +w["click."]="2*1"; +w["client"]="2*2,6*1"; +w["client-sid"]="2*1,6*1"; +w["cn"]="10*2"; +w["co"]="3*1"; +w["code"]="0*1,2*1,3*4,5*1,6*1,10*9,13*6"; +w["code."]="10*1"; +w["code:"]="5*1"; +w["collaps"]="5*1,6*1"; +w["collapsed:"]="5*1"; +w["color"]="6*1,15*1"; +w["com"]="3*2,9*2,10*8"; +w["com.nexwave.nquindexer.indexermain"]="9*1"; +w["com.nexwave.nquindexer.indexertask"]="9*1"; +w["come"]="9*1,15*1"; +w["command"]="2*2,7*1,8*5,9*1"; +w["command-lin"]="9*1"; +w["command."]="2*1"; +w["comment"]="8*1"; +w["comments."]="8*1"; +w["common"]="2*1,3*1,6*1,15*7"; +w["commons:"]="8*3"; +w["compani"]="5*1"; +w["compar"]="2*1"; +w["compil"]="10*1"; +w["complet"]="4*3,15*1"; +w["compress"]="4*3"; +w["concern"]="9*1"; +w["condit"]="3*1"; +w["conditions:"]="3*1"; +w["conf"]="4*1"; +w["configur"]="4*40,7*1,15*1"; +w["confirm"]="8*3"; +w["confus"]="3*1"; +w["connect"]="3*1"; +w["consid"]="14*1"; +w["contact"]="10*1"; +w["contain"]="2*1,3*1,8*1,9*1,10*1"; +w["content"]="2*3,3*1,5*6,6*5,7*5,9*1,11*5,12*8"; +w["content."]="2*2,9*1"; +w["content:"]="5*1"; +w["contract"]="3*1"; +w["contribut"]="3*2,14*1"; +w["contributor"]="3*1"; +w["control"]="4*3,5*1,13*1,15*1"; +w["control:"]="5*1"; +w["conveni"]="8*3"; +w["cooki"]="3*1,5*1,12*2"; +w["copi"]="3*3,8*5,10*1,13*2"; +w["copyright"]="3*5"; +w["core"]="9*1"; +w["correct"]="0*1,3*1,8*1,10*5"; +w["cosmet"]="3*1"; +w["could"]="4*1,8*1"; +w["cramer"]="3*4"; +w["creat"]="2*1,6*1,7*1,8*5"; +w["credit"]="3*1"; +w["csrc"]="8*2"; +w["css"]="4*5,5*3,6*1,15*8"; +w["css-base"]="5*1,6*1"; +w["css-style"]="5*1"; +w["css."]="15*1"; +w["currenc"]="1*2,16*1"; +w["current"]="0*1,10*3,14*1"; +w["currently."]="0*1"; +w["custom"]="5*2,7*1,8*1,15*48"; +w["d"]="8*1"; +w["damag"]="3*1"; +w["danish"]="14*1"; +w["data"]="2*1"; +w["david"]="3*6"; +w["day"]="1*1,4*1,16*1"; +w["de"]="8*1,10*3"; +w["deal"]="3*3"; +w["deep"]="15*1"; +w["default"]="2*1,8*1,9*2,15*1"; +w["default."]="8*1"; +w["defin"]="2*1,8*1"; +w["deflat"]="4*10"; +w["delet"]="8*1"; +w["demo"]="0*4"; +w["deploy"]="0*3"; +w["deriv"]="3*3"; +w["describ"]="7*1"; +w["descript"]="6*1"; +w["description."]="6*1"; +w["design"]="2*1,5*47,12*1"; +w["desir"]="8*2"; +w["desired-output-dir"]="8*1"; +w["detail"]="0*1,2*2,3*1,8*1,9*2"; +w["details."]="0*1,3*1,8*1,9*1"; +w["develop"]="3*1,12*51"; +w["differ"]="3*1,8*1"; +w["dir"]="8*6,13*1"; +w["direct"]="3*1,9*1,15*1"; +w["directori"]="2*2,3*1,8*15,9*3,13*4"; +w["directory."]="2*1,8*4,13*1"; +w["disabl"]="8*1"; +w["display"]="2*1"; +w["distribut"]="3*2,8*3,9*1"; +w["dita"]="0*1,3*3"; +w["dita-us"]="3*1"; +w["dita."]="0*1"; +w["div"]="5*1,12*1,15*2"; +w["divid"]="5*1"; +w["do"]="2*2,3*1,8*2,9*1,14*1"; +w["doc"]="2*1,8*3,12*51,15*7"; +w["docbkx"]="6*1,8*1"; +w["docbo"]="0*2"; +w["docbook"]="0*3,1*1,2*3,3*53,4*3,5*4,6*2,7*1,8*6,9*2,10*9,11*1,12*1,13*3,14*1,15*3,16*1"; +w["docbook-app"]="3*1"; +w["docbook-apps@list"]="10*1"; +w["docbook-apps@lists.oasis-open.org"]="10*1"; +w["docbook-webhelp"]="8*1,10*7"; +w["docbook-xsl-1"]="0*1"; +w["docbook-xsl-1.77.0"]="0*2"; +w["docbook."]="15*1"; +w["docbook.sourceforge.net"]="9*2"; +w["docs@@@"]="2*1"; +w["docsbook"]="9*1"; +w["docsbook-xsl-1"]="9*1"; +w["docsbook-xsl-1.76.1"]="9*1"; +w["docsr"]="13*6"; +w["docsrc"]="13*1"; +w["document"]="0*2,3*1,4*2,5*1,6*1,8*10,13*4"; +w["document."]="8*2,13*1"; +w["documentation."]="0*1,5*1,6*1"; +w["doe"]="0*2,2*2,8*1,9*1"; +w["doesn"]="9*1"; +w["don"]="8*1,15*1"; +w["donat"]="3*1"; +w["done"]="0*1,2*1,5*2"; +w["dostem"]="2*1"; +w["dot"]="3*4"; +w["doutput"]="8*1"; +w["down"]="3*1,13*5"; +w["download"]="4*1,8*2,9*1,10*1"; +w["drop"]="2*1"; +w["dtd"]="8*2"; +w["dtd."]="8*1"; +w["dutch"]="14*1"; +w["e"]="10*1,12*1"; +w["easi"]="10*1"; +w["easili"]="5*1,10*2"; +w["easily."]="10*1"; +w["eclips"]="6*1"; +w["edit"]="8*1,15*1"; +w["editor"]="3*1,8*1,10*1"; +w["editor."]="3*1"; +w["efault"]="8*1"; +w["element"]="15*1"; +w["element."]="0*2,15*1"; +w["els"]="9*1,10*7"; +w["email"]="10*1"; +w["en"]="8*3,9*1,10*4"; +w["en."]="8*1"; +w["enabl"]="8*1"; +w["enable.stem"]="8*1"; +w["endors"]="9*1"; +w["engin"]="3*1,6*1"; +w["engine."]="6*1"; +w["english"]="2*1,6*1,8*1,10*3,14*1"; +w["englishstemm"]="10*1"; +w["environ"]="7*1,8*5,9*1"; +w["equalsignorecas"]="10*3"; +w["error"]="0*2"; +w["error."]="0*2"; +w["etc"]="2*1,5*1,6*1,8*2"; +w["etc."]="2*1,5*1,6*1,8*3,15*1"; +w["event"]="3*1"; +w["ex"]="2*1"; +w["ex:"]="2*1"; +w["exact"]="10*1,12*1"; +w["exampl"]="3*6,8*5,10*1,13*1,15*1"; +w["example."]="10*1"; +w["example:"]="8*4"; +w["example 1"]="13*5"; +w["example 1. exampl"]="13*5"; +w["example 2"]="10*5"; +w["example 2. add"]="10*5"; +w["example 3"]="10*5"; +w["example 3. initi"]="10*5"; +w["except"]="3*1"; +w["exist"]="2*1,3*1"; +w["exist."]="3*1,8*1"; +w["expos"]="6*1"; +w["express"]="3*1"; +w["ext"]="10*2"; +w["extend"]="10*2"; +w["extens"]="0*2,2*1,4*1,8*1,9*1,10*1"; + diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-2.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-2.js new file mode 100644 index 000000000000..05d3f0c51df4 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-2.js @@ -0,0 +1,390 @@ +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["extension:"]="4*1"; +w["extent"]="2*1"; +w["extract"]="8*1"; +w["f"]="4*1,9*1,12*1,14*1"; +w["fair"]="10*1"; +w["fals"]="2*1,8*1"; +w["false."]="2*1"; +w["faq"]="0*51"; +w["featur"]="2*1,5*1,6*6"; +w["feature."]="5*1"; +w["feel"]="15*1"; +w["fetch"]="9*1"; +w["few"]="5*1,10*1"; +w["fi"]="4*1"; +w["figur"]="3*5,8*3,13*4"; +w["figure 1"]="13*5"; +w["figure 1. sampl"]="13*5"; +w["fil"]="2*2"; +w["file"]="0*2,2*10,3*5,4*6,5*1,6*1,7*1,8*64,9*1,10*1,13*2,15*4"; +w["file."]="4*1,10*1,15*1"; +w["file:"]="0*4"; +w["fileref"]="13*1"; +w["files."]="4*1,8*1"; +w["files:"]="2*1,15*1"; +w["fileset"]="8*1,13*1"; +w["filesmatch"]="4*6"; +w["find"]="0*4,10*1"; +w["finnish"]="14*1"; +w["firefox"]="0*1"; +w["first"]="2*1,3*1"; +w["fit"]="3*1"; +w["five"]="2*1"; +w["fl"]="2*1"; +w["flv"]="4*2"; +w["folder"]="0*1,2*2,9*1,10*2,15*1"; +w["folder."]="2*1,10*1"; +w["foll"]="0*1"; +w["follos"]="8*3"; +w["follow"]="0*2,2*1,3*2,4*2,5*1,7*1,8*2,9*2,10*1,13*2,14*1,15*1"; +w["foobar"]="2*1"; +w["form"]="14*1"; +w["form."]="14*1"; +w["format"]="2*1,6*3,13*1"; +w["fortun"]="10*1"; +w["forward"]="6*1"; +w["four"]="0*1"; +w["fr"]="8*1,10*4"; +w["frameset"]="5*1,6*1,12*1,15*1"; +w["frameset."]="6*1,12*2"; +w["free"]="3*1"; +w["french"]="2*1,6*1,8*1,10*3"; +w["french."]="2*1"; +w["frenchstemm"]="10*1"; +w["frequent"]="0*1"; +w["from"]="0*3,1*1,2*3,3*57,4*1,5*4,6*4,7*1,8*6,9*2,10*3,11*1,12*2,13*4,14*1,15*2,16*1"; +w["full"]="6*1,10*1"; +w["fulli"]="2*1,5*1"; +w["furnish"]="3*1"; +w["further"]="2*1,5*1,15*1"; +w["gajasingh"]="3*4"; +w["ge"]="8*1"; +w["general"]="10*1,15*1"; +w["generat"]="0*1,2*1,5*3,6*2,7*1,8*49,10*1"; +w["german"]="2*1,6*1,10*3"; +w["german."]="6*1,14*1"; +w["germanstemm"]="10*1"; +w["get"]="0*2,2*1,6*1,10*1,15*1"; +w["gif"]="4*2"; +w["given."]="13*1"; +w["gmail"]="3*2"; +w["go"]="9*1"; +w["googl"]="3*1,6*1"; +w["gorithm"]="10*1"; +w["gracious"]="3*1"; +w["gram"]="2*1"; +w["grant"]="3*1"; +w["graphic"]="8*4,13*2"; +w["group"]="6*1"; +w["guid"]="0*1,4*3,15*1"; +w["handl"]="2*2,15*1"; +w["happen"]="0*1,2*1"; +w["hartl"]="3*1"; +w["hat"]="6*1"; +w["have"]="9*1"; +w["haven"]="0*1"; +w["having."]="9*1"; +w["head"]="5*1"; +w["header"]="4*3,5*2,15*1"; +w["header:"]="5*1"; +w["height"]="15*1"; +w["help"]="0*1,1*1,2*1,3*51,5*1,6*4,7*1,8*1,9*2,10*1,11*1,12*2,13*1,14*1,15*4,16*1"; +w["help."]="6*1"; +w["here"]="8*1,9*1,13*1"; +w["here."]="8*2,13*1"; +w["herebi"]="3*1"; +w["higher"]="8*1,9*1"; +w["higher."]="8*2"; +w["highlight"]="6*1"; +w["hour"]="4*1"; +w["how"]="2*1,6*1,7*1,8*1,12*1,13*1"; +w["howev"]="8*1"; +w["href"]="0*2"; +w["ht"]="8*1"; +w["htaccess"]="4*1"; +w["htm"]="4*2,8*1"; +w["html"]="0*3,2*2,3*1,4*7,5*1,6*1,8*2,15*1"; +w["html.extens"]="8*1"; +w["htmlfileinfolist"]="2*1"; +w["htmlfileinfolist.j"]="2*1"; +w["htmlfilelist"]="2*1"; +w["htmlfilelist.j"]="2*1"; +w["htmlsearch"]="0*2,3*3"; +w["http"]="9*1"; +w["http:"]="9*2"; +w["httpd"]="4*1"; +w["httpd.conf"]="4*1"; +w["hungarian"]="14*1"; +w["ico"]="4*2"; +w["ide"]="2*1"; +w["idea"]="2*1"; +w["identifi"]="3*1,8*1"; +w["ie"]="0*1"; +w["if"]="0*1,2*2,4*2,6*1,8*8,9*1,10*12,12*2,13*1,15*1"; +w["ignor"]="8*1"; +w["ilabl"]="7*1"; +w["ile"]="4*1"; +w["iles."]="4*1"; +w["imag"]="3*2,7*1,8*11,13*72"; +w["imagedata"]="13*1"; +w["imageobject"]="13*2"; +w["images."]="3*1,13*5"; +w["implement"]="2*1,6*2,12*2,14*2"; +w["implemented."]="2*1,12*1"; +w["impli"]="3*1"; +w["import"]="6*1,8*44"; +w["imposs"]="6*1"; +w["improv"]="3*2,4*1"; +w["includ"]="0*1,2*3,3*4,5*4,6*2,10*1,14*1,15*1"; +w["index"]="0*5,2*14,3*5,4*2,6*2,7*1,8*5,9*58,10*12,14*1"; +w["index-"]="2*2"; +w["index.html"]="8*2"; +w["indexer-languag"]="8*1"; +w["indexer-language-cod"]="2*2"; +w["indexer."]="0*2,2*1,9*1,10*1"; +w["indexerlanguag"]="10*5"; +w["indexerlanguage.equalsignorecas"]="10*6"; +w["indexermain"]="9*1"; +w["indexertask"]="9*2,10*1"; +w["indexertask.java"]="10*2"; +w["indexing:"]="2*1"; +w["indic"]="8*4"; +w["indicated:"]="8*3"; +w["individu"]="3*2"; +w["inflect"]="11*1,16*46"; +w["inform"]="0*3,4*1,8*2,9*1,15*1"; +w["information."]="0*1"; +w["initi"]="3*1,10*5"; +w["input"]="8*8,13*1,14*1"; +w["input-images-basedir"]="8*1"; +w["input-images-dir"]="8*2,13*1"; +w["input-xml"]="8*3"; +w["input-xml."]="8*1"; +w["insid"]="2*1,15*1"; +w["instal"]="7*1,8*12,9*1"; +w["instead"]="3*1"; +w["instruct"]="8*2"; +w["integr"]="6*1,10*1"; +w["intellij"]="2*1"; +w["interest"]="15*1"; +w["internet"]="6*1"; +w["into"]="6*2,15*1"; +w["introduct"]="6*51"; +w["invoc"]="9*1"; +w["invocation."]="9*1"; +w["invok"]="2*1,9*2"; +w["involved."]="2*1"; +w["iphone."]="0*1"; +w["ipod"]="0*1"; +w["ipt"]="14*1"; +w["issu"]="9*1"; +w["it_stemm"]="10*1"; +w["it_stemmer.j"]="10*1"; +w["italian"]="10*5,14*1"; +w["italianstemm"]="10*4"; +w["ja"]="8*2,10*2"; +w["januari"]="3*1"; +w["japan"]="10*1"; +w["japanes"]="2*1,3*1,6*1,8*1,10*1"; +w["jar"]="0*1,2*1,8*15,9*5"; +w["java"]="0*6,7*5,8*21,9*1,10*5,14*3"; +w["java."]="10*1"; +w["javascr"]="14*1"; +w["javascrip"]="4*1"; +w["javascript"]="0*1,2*3,4*6,5*1,10*4,14*3"; +w["javascript."]="2*1,14*1"; +w["jdk"]="8*1,9*1"; +w["jdk."]="8*1"; +w["jpeg"]="4*2"; +w["jpg"]="4*2,13*11"; +w["jqueri"]="0*2,3*3,5*3,15*7"; +w["jquery-ui"]="5*1"; +w["jquery-ui-1"]="15*1"; +w["jquery-ui-1.8.2.custom.css"]="15*1"; +w["jquery.cookie.j"]="3*1"; +w["jquery.treeview.css"]="15*1"; +w["jqueryui"]="15*1"; +w["jre"]="9*1"; +w["js"]="2*6,3*1,4*2,10*3"; +w["just"]="3*1"; +w["kasun"]="0*6,3*4"; +w["kasunbg"]="3*2"; +w["key"]="1*1,16*1"; +w["kind"]="3*1"; +w["klaus"]="3*1"; +w["ko"]="10*2"; +w["korean"]="2*1,3*1,6*1,10*2"; +w["languag"]="2*5,3*2,6*2,7*1,8*3,9*1,10*20,14*49"; +w["language-cod"]="10*2"; +w["language."]="8*1,9*1,10*2"; +w["languages."]="14*1"; +w["latest"]="9*1"; +w["layer"]="8*1"; +w["layout"]="6*1"; +w["left"]="5*1,12*1,15*1"; +w["leftnavig"]="15*1"; +w["les"]="4*1"; +w["level"]="8*1"; +w["li"]="5*1"; +w["liabil"]="3*1"; +w["liabl"]="3*1"; +w["lib"]="9*1"; +w["librari"]="2*1"; +w["library."]="2*1"; +w["licens"]="3*5"; +w["license."]="3*5"; +w["license.txt"]="3*1"; +w["like"]="2*1,6*1,10*1"; +w["limit"]="3*2"; +w["line"]="0*2,4*2,8*2,9*1,10*1"; +w["line."]="8*1"; +w["link"]="6*2,15*2"; +w["linux"]="9*1"; +w["list"]="3*11,5*2,8*1,10*3,13*1"; +w["ll"]="9*1,10*1"; +w["ll."]="9*1"; +w["load"]="5*1,12*1"; +w["local"]="8*3"; +w["locat"]="2*1,8*6,10*1"; +w["location."]="10*1"; +w["log"]="6*1"; +w["logo"]="5*1"; +w["long"]="4*1"; +w["look"]="2*1,5*1,15*1"; +w["ltd"]="3*1"; +w["ltd."]="3*1"; +w["lucen"]="3*1,6*1,9*2"; +w["lucene-analyzers-3"]="9*1"; +w["lucene-analyzers-3.0.0.jar"]="9*1"; +w["lucene-core-3"]="9*1"; +w["lucene-core-3.0.0.jar"]="9*1"; +w["m"]="0*2"; +w["made"]="5*1"; +w["mail"]="3*1,10*1"; +w["main"]="2*1,5*1,9*1"; +w["maintain"]="3*1"; +w["make"]="3*1,4*1,8*1,10*1"; +w["makefil"]="6*1,7*2,8*2"; +w["makefile.sampl"]="7*2,8*2"; +w["manag"]="8*1"; +w["mani"]="6*1"; +w["martin"]="14*1"; +w["match"]="2*1"; +w["matrix"]="0*1"; +w["maven"]="6*1,8*1"; +w["max"]="4*3"; +w["max-ag"]="4*3"; +w["may"]="8*1,9*1"; +w["mechan"]="2*2,14*2"; +w["mechanism."]="2*1"; +w["mediaobject"]="13*2"; +w["medium"]="5*1"; +w["merchant"]="3*1"; +w["merg"]="3*1"; +w["messag"]="8*1"; +w["meta"]="2*1"; +w["method"]="2*1"; +w["microsoft"]="6*1"; +w["miss"]="8*1"; +w["mit"]="3*2"; +w["ml"]="8*1"; +w["model"]="6*1"; +w["modifi"]="3*1,8*4"; +w["more"]="0*3,4*1"; +w["most"]="0*2"; +w["move"]="2*1"; +w["multipl"]="15*1"; +w["must"]="4*2,7*1,8*4,9*1,12*1"; +w["must-revalid"]="4*2"; +w["mutandi"]="8*3"; +w["mutati"]="8*3"; +w["n"]="3*1"; +w["n."]="3*1"; +w["name"]="2*4,3*2,8*7,10*3,15*1"; +w["navig"]="5*4,12*1,15*1"; +w["navigation:"]="5*2"; +w["ncomment"]="8*1"; +w["necessari"]="8*2"; +w["necessary."]="15*1"; +w["need"]="0*3,2*1,8*4,9*3,10*3,13*1,14*1,15*2"; +w["need:"]="10*1"; +w["net"]="3*2,9*1"; +w["netbean"]="2*1"; +w["new"]="2*2,3*1,8*1,10*56,12*2,15*1"; +w["newli"]="8*1"; +w["next"]="5*1"; +w["nexwav"]="9*2,10*8"; +w["nice"]="5*1,6*1"; +w["no"]="2*1,3*2,15*1"; +w["non"]="7*1,8*1,10*1,14*46"; +w["non-cjkv"]="7*1,10*1,14*46"; +w["non-n"]="8*1"; +w["noninfring"]="3*1"; +w["noninfringement."]="3*1"; +w["norwegian"]="14*1"; +w["note"]="3*1,4*1,8*162,9*40,10*40,13*5"; +w["noth"]="15*1"; +w["notic"]="3*3"; +w["now"]="2*1,10*3"; +w["nquindex"]="9*2,10*6"; +w["ns"]="8*1"; +w["nuclei"]="16*1"; +w["nucleus"]="1*1"; +w["null"]="10*1"; +w["number"]="10*1"; +w["nwsearchfnt"]="2*2"; +w["nwsearchfnt.j"]="2*2"; +w["o"]="2*1,12*1"; +w["oasis-open"]="10*1"; +w["object"]="10*4"; +w["object."]="10*3"; +w["obtain"]="3*1"; +w["odd"]="4*1"; +w["ok"]="0*1"; +w["ok-xsl-1"]="0*1"; +w["ok-xsl-1.77.0"]="0*2"; +w["onc"]="8*1"; +w["one"]="2*1,10*1,15*1"; +w["onli"]="8*2,10*3,14*1"; +w["only."]="10*2"; +w["open"]="2*1,8*1,10*2"; +w["open.org"]="10*1"; +w["openstack"]="3*1"; +w["oper"]="0*2"; +w["option"]="9*1"; +w["org"]="10*1"; +w["organ"]="5*1"; +w["origin"]="3*1"; +w["other"]="0*2,3*6,6*1,7*1,8*3,10*2,14*46"; +w["others:"]="3*1"; +w["otherwis"]="3*2"; +w["ouput"]="8*1"; +w["out"]="3*1,6*1"; +w["output"]="0*3,2*1,4*1,5*1,6*2,7*2,8*56,10*1,13*2,15*47"; +w["output-dir"]="8*2"; +w["output."]="3*1,6*1"; +w["outsid"]="0*2"; +w["over"]="13*1"; +w["overal"]="5*1"; +w["overview"]="2*2,5*1,6*1,12*1"; +w["owe"]="0*1"; +w["own"]="2*1,6*3,8*3"; +w["oxygen"]="3*1"; +w["packag"]="3*3,7*52,8*8,10*1"; +w["package."]="6*1,8*1,10*1"; +w["page"]="3*1,5*5,6*2,12*4,15*1"; +w["page."]="12*1,15*1"; +w["pane"]="5*1,6*4,12*2"; +w["para"]="15*1"; +w["paramet"]="8*3,9*1"; +w["parameters."]="8*2"; +w["parent"]="5*1"; +w["part"]="2*1,3*1,5*1,9*1,15*1"; +w["particul"]="3*1"; +w["parts."]="2*1"; +w["pass"]="8*2"; +w["path"]="0*1,3*1,7*1,8*11,13*5"; +w["path-"]="8*4"; +w["paths."]="0*1"; + diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-3.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-3.js new file mode 100644 index 000000000000..9a8057e62de5 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/index-3.js @@ -0,0 +1,388 @@ +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["pattern"]="8*1,13*2"; +w["patterns."]="8*1,13*1"; +w["pdf"]="4*2"; +w["peopl"]="9*1"; +w["perform"]="4*1,15*1"; +w["performance."]="4*1"; +w["permiss"]="3*2"; +w["permit"]="3*1"; +w["persist"]="5*1"; +w["persist:"]="5*1"; +w["person"]="3*2"; +w["phrase"]="15*1"; +w["pie"]="3*1"; +w["place"]="6*1"; +w["plain"]="4*1"; +w["pleas"]="3*1,14*1"; +w["plugin"]="0*2,3*2,5*2,6*1,8*1"; +w["plugin."]="3*1"; +w["png"]="4*2"; +w["point"]="7*1,8*5,15*1"; +w["popul"]="15*1"; +w["popular"]="10*1"; +w["porter"]="14*1"; +w["portion"]="3*1"; +w["portugues"]="14*1"; +w["posit"]="5*1,15*4"; +w["positioning.css"]="5*1,15*1"; +w["positions."]="15*1"; +w["possibl"]="3*2"; +w["pretti"]="9*1"; +w["prev"]="5*1"; +w["prior"]="3*1,9*1"; +w["privat"]="10*2"; +w["probabl"]="9*1"; +w["procedur"]="8*1,13*1"; +w["procedure 1"]="8*5"; +w["procedure 1. "]="8*1"; +w["process"]="2*2,5*1,8*3,9*2"; +w["processor"]="0*1,8*4"; +w["processors."]="8*1"; +w["produc"]="6*1"; +w["product"]="0*3"; +w["program"]="8*6"; +w["project"]="2*1,3*2,8*2,14*2"; +w["project."]="3*1"; +w["promot"]="3*1"; +w["prompt"]="8*2"; +w["prompt:"]="8*2"; +w["properti"]="8*5,10*2,13*1"; +w["provid"]="0*1,2*1,3*4,6*1,12*1"; +w["public"]="3*1,4*2,6*1"; +w["publish"]="3*2"; +w["punctuat"]="2*1,8*1"; +w["purpos"]="3*1"; +w["put"]="8*1,9*1,13*1"; +w["quain"]="3*1"; +w["queri"]="2*7,6*1,8*1"; +w["querying:"]="2*1"; +w["question"]="0*1,3*2,10*1"; +w["question."]="3*1"; +w["r"]="8*1"; +w["raphic"]="8*1"; +w["rate"]="6*1"; +w["read"]="12*1"; +w["readm"]="0*1,1*1,2*1,3*51,5*1,6*1,7*1,8*2,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1"; +w["readme.xml"]="8*1"; +w["readme:"]="0*1,1*1,2*1,3*51,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1"; +w["reason"]="0*2"; +w["recommend"]="4*41,7*1,15*1"; +w["recompil"]="2*1"; +w["redmond"]="15*2"; +w["refer"]="8*2,13*1"; +w["relat"]="3*1,8*1,13*5,15*1"; +w["releas"]="3*4"; +w["remov"]="9*1"; +w["render"]="12*1"; +w["replac"]="15*1"; +w["requir"]="6*2,14*1"; +w["resid"]="2*1,9*1"; +w["resourc"]="4*1"; +w["restor"]="12*1"; +w["restrict"]="3*1"; +w["result"]="2*2,3*1,6*5,12*2,15*1"; +w["result."]="6*1"; +w["results."]="2*1,6*1"; +w["return"]="2*1"; +w["revalid"]="4*2"; +w["right"]="3*1,15*1"; +w["rman"]="8*1"; +w["role"]="15*1"; +w["romanian"]="14*1"; +w["root"]="2*1,10*1"; +w["rss"]="4*1"; +w["run"]="2*2,8*1,9*2,10*2"; +w["russian"]="14*1"; +w["s"]="0*2,2*3,3*1,4*1,9*3,10*2,14*2,15*1"; +w["safari"]="0*1"; +w["safe"]="8*1"; +w["sale"]="3*1"; +w["same"]="8*2"; +w["sampl"]="3*1,6*1,7*3,8*2,13*11"; +w["sample.jpg"]="13*10"; +w["save"]="12*1"; +w["saxhtmlindex"]="10*1"; +w["saxhtmlindex.java"]="10*2"; +w["saxon"]="0*1,8*10"; +w["saxon-6"]="0*1,8*3"; +w["saxon-6.5.5.jar"]="0*1,8*3"; +w["saxon.jar"]="8*1"; +w["say"]="1*1,16*1"; +w["score"]="2*1,6*2"; +w["script"]="6*2,7*2,8*2,9*1"; +w["script."]="6*1,7*2,8*1,9*1"; +w["search"]="1*46,2*51,3*3,4*2,5*4,6*13,7*1,8*3,9*46,10*3,11*2,12*4,14*3,15*1,16*46"; +w["search-result."]="6*1"; +w["search."]="6*2,12*1"; +w["searching."]="2*1"; +w["section"]="5*1,7*1,11*51,13*1,15*1"; +w["sectioninfo"]="15*1"; +w["see"]="0*1,3*1,4*1,8*6,9*1,10*2,13*1,15*1"; +w["see."]="5*1"; +w["seem"]="9*1"; +w["self"]="10*1"; +w["sell"]="3*1"; +w["separ"]="5*1"; +w["serch"]="2*1"; +w["serv"]="4*1"; +w["server"]="2*1,4*2"; +w["servic"]="6*1"; +w["set"]="0*1,4*4,8*5,9*1,15*1"; +w["setoutputfilt"]="4*1"; +w["setting."]="4*1"; +w["shall"]="3*3"; +w["share"]="0*6,8*12,9*1"; +w["shell"]="7*1,8*1"; +w["should"]="2*1,8*1,9*1"; +w["show"]="6*2,13*1"; +w["shown"]="6*1,13*1"; +w["side"]="2*2,6*1"; +w["side."]="2*1"; +w["sidetreecontrol"]="5*1"; +w["similar"]="6*1"; +w["simpl"]="10*1,13*1"; +w["simple."]="10*1"; +w["simpli"]="2*2,8*1,15*1"; +w["simplifi"]="2*1"; +w["sinc"]="2*1,4*1"; +w["sky"]="1*1,16*1"; +w["small"]="6*3"; +w["smooth"]="9*1"; +w["snapshot"]="9*4"; +w["snowbal"]="3*1,10*6"; +w["snowballstemm"]="10*2"; +w["soft"]="3*1"; +w["softwar"]="3*15"; +w["software."]="3*2"; +w["some"]="1*46,2*1,3*2,8*1,9*2,11*2,16*46"; +w["sophist"]="6*1"; +w["sourc"]="2*2,8*1,13*2"; +w["source."]="2*1"; +w["sourceforg"]="9*1"; +w["sources."]="2*1"; +w["space"]="2*1"; +w["spanish"]="14*1"; +w["specifi"]="3*1,8*1,10*5"; +w["src"]="10*8"; +w["stale"]="4*1"; +w["start"]="7*1,8*2"; +w["state"]="12*2"; +w["stayton"]="4*1,15*1"; +w["stem"]="2*6,6*2,8*2,14*3"; +w["stemmer"]="2*3,3*2,8*1,10*74,12*1,14*3"; +w["stemmer."]="6*1,10*1"; +w["stemming."]="2*1"; +w["step"]="0*1,8*2"; +w["steps."]="10*1"; +w["store"]="2*2,4*1,8*2"; +w["string"]="3*1,10*3"; +w["structur"]="5*4"; +w["structure."]="5*2"; +w["studi"]="15*1"; +w["stuff"]="15*1"; +w["stuff."]="15*1"; +w["style"]="3*1,5*4,15*1"; +w["stylesheet"]="3*1,8*1"; +w["stylesheet-path"]="8*1"; +w["styling."]="5*1"; +w["subdirectori"]="13*1"; +w["subject"]="3*1"; +w["sublicens"]="3*1"; +w["substanti"]="3*1"; +w["such"]="2*1,4*1,10*1"; +w["summari"]="2*1,15*2"; +w["summaries."]="15*1"; +w["summer"]="3*1"; +w["support"]="0*2,2*3,3*2,6*3,7*1,10*3,14*49"; +w["supportedlanguag"]="3*1,10*8"; +w["suppress.footer.navig"]="8*1"; +w["sure"]="10*1"; +w["svn"]="2*1"; +w["swedish"]="14*1"; +w["swf"]="4*2"; +w["synchron"]="6*1"; +w["syncro"]="3*1"; +w["system"]="0*2,6*1,8*4,12*1,15*1"; +w["system."]="6*1,8*3"; +w["system:"]="8*1"; +w["t"]="0*2,2*1,4*1,6*1,8*1,9*1,15*1"; +w["tab"]="5*7,8*1"; +w["tab."]="5*2,8*1"; +w["tab:"]="5*1"; +w["tabl"]="5*3,6*2,7*5,11*5,12*8"; +w["tabs."]="5*1"; +w["tag"]="5*2"; +w["tagsoup"]="3*1"; +w["target"]="6*1"; +w["target."]="6*1"; +w["task"]="9*1,14*1"; +w["technic"]="6*1"; +w["tell"]="8*1"; +w["templat"]="3*2,6*1,10*2"; +w["template."]="14*1"; +w["term"]="6*2"; +w["test"]="0*3,1*46,8*5,11*53,16*46"; +w["test-ouput"]="8*1"; +w["test-output"]="8*3"; +w["text"]="2*1,4*5,8*1,10*1"; +w["that"]="2*2,3*3,4*2,5*1,6*2,8*11,10*2,12*1,13*2"; +w["them"]="4*1,9*1"; +w["them."]="2*1"; +w["theme"]="15*7"; +w["theme-redmond"]="15*3"; +w["then"]="2*1,6*1,10*6,13*1,15*1"; +w["there"]="0*1,2*1,10*1"; +w["therefor"]="14*1"; +w["these"]="2*1,4*2,9*3,12*1,14*1,15*1"; +w["they"]="8*3,12*1"; +w["thingbag"]="3*2"; +w["those"]="4*1,13*1"; +w["though"]="8*1"; +w["three"]="2*2,5*1,9*1"; +w["time"]="6*1"; +w["tion"]="4*1"; +w["tip"]="8*41,15*40"; +w["titl"]="2*1,5*1,13*2"; +w["toc"]="5*2,6*4,15*1"; +w["toc."]="6*1"; +w["token"]="2*2,3*1"; +w["too"]="2*1"; +w["tool"]="8*1"; +w["tools.jar"]="8*1"; +w["top"]="6*1,8*1,15*1"; +w["top-level"]="8*1"; +w["topic"]="15*1"; +w["topic."]="5*1"; +w["tort"]="3*1"; +w["total"]="2*1"; +w["transform"]="0*3"; +w["travers"]="2*1"; +w["tree"]="5*6,6*1,12*1,13*2,15*1"; +w["tree."]="6*1,15*1"; +w["tree:"]="5*1,13*1"; +w["treeview"]="5*2,15*3"; +w["tri"]="1*1,16*1"; +w["true"]="5*1,8*4"; +w["trunk"]="2*3"; +w["turkish"]="14*1"; +w["two"]="2*1,5*1,9*2,10*2,15*1"; +w["txt"]="3*1,4*2"; +w["type"]="4*1,8*4"; +w["u"]="5*1,8*1"; +w["ui"]="5*1,15*1"; +w["ul"]="5*1"; +w["unchang"]="15*1"; +w["unchanged."]="15*1"; +w["uncompress"]="4*1"; +w["under"]="3*6,9*1"; +w["understandable."]="10*1"; +w["undertak"]="14*1"; +w["unix"]="7*1,8*1"; +w["unnecessari"]="2*1"; +w["unord"]="5*1"; +w["unzip"]="8*2"; +w["up"]="1*1,2*2,4*1,5*1,8*1,9*1,10*1,13*1,14*1,15*1,16*1"; +w["updat"]="4*1"; +w["us"]="10*1"; +w["use"]="2*2,3*5,5*2,6*7,7*56,8*55,10*1,13*5,14*2,15*48"; +w["used."]="2*1"; +w["user"]="0*6,2*2,3*1,4*1,6*1,8*1,14*1"; +w["usr"]="0*6,8*12,9*1"; +w["utf"]="4*1"; +w["utf-8"]="4*1"; +w["valid"]="8*2"; +w["validate-against-dtd"]="8*1"; +w["valu"]="8*4"; +w["var"]="2*1"; +w["vari"]="1*1,16*1"; +w["variabl"]="8*3,9*1"; +w["variable."]="9*1"; +w["variables."]="8*1"; +w["various"]="4*1"; +w["veri"]="10*1"; +w["verison"]="14*1"; +w["version"]="0*1,3*1,8*3,9*4,10*2,14*2"; +w["versions."]="9*1"; +w["visitha"]="3*1"; +w["w"]="2*1"; +w["wan"]="0*1"; +w["warn"]="0*2"; +w["warranti"]="3*7"; +w["warranty: "]="3*5"; +w["was"]="3*3"; +w["way"]="9*1,15*1"; +w["ways:"]="15*1"; +w["we"]="0*1,2*1,4*1,5*2,9*3"; +w["web"]="0*1,1*1,2*1,3*51,4*1,5*1,6*3,7*1,8*1,9*2,10*1,11*1,12*1,13*1,14*1,15*1,16*1"; +w["web-bas"]="0*1,1*1,2*1,3*51,5*1,6*2,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1"; +w["webhelp"]="0*15,2*2,3*2,5*2,6*1,7*1,8*54,9*8,10*10,12*1,13*7"; +w["webhelp-index"]="0*2"; +w["webhelp-indexer."]="0*2"; +w["webhelp."]="8*1,10*2,13*1"; +w["webhelp.include.search.tab"]="8*1"; +w["webhelp.indexer.languag"]="3*1,8*1,10*2"; +w["webhelp.xsl"]="8*3"; +w["webhelpindex"]="2*3,9*1"; +w["webhelpindexer.jar"]="2*1,9*1"; +w["week"]="4*1"; +w["weight"]="3*1,6*1"; +w["well"]="0*3,9*1"; +w["well."]="9*1"; +w["were"]="3*1,9*1,12*2"; +w["what"]="0*4,6*1,10*1,13*1"; +w["when"]="0*2,2*1,5*2,8*1,12*2,15*1"; +w["where"]="0*4,6*1,7*1,8*1,9*1,10*1"; +w["whether"]="2*1,3*1"; +w["which"]="2*1,5*1,8*2,9*1,15*2"; +w["whom"]="3*1"; +w["width"]="15*1"; +w["wiki"]="0*1"; +w["will"]="3*3,8*3,9*1"; +w["window"]="7*1,8*2"; +w["without"]="3*4,6*1"; +w["word"]="1*46,2*8,6*1,11*2,16*46"; +w["work"]="8*2"; +w["would"]="2*1"; +w["write"]="10*1"; +w["writt"]="8*1"; +w["written"]="3*2,10*1"; +w["x"]="0*1,4*1,8*1"; +w["x-javascript"]="4*1"; +w["xerc"]="8*3"; +w["xerces2"]="8*1"; +w["xercesimpl"]="8*2,9*1"; +w["xercesimpl.jar"]="0*2,8*11,9*1"; +w["xhtml"]="0*9,3*1,4*1,8*1"; +w["xhtml."]="0*1"; +w["xml"]="0*3,1*2,2*1,3*52,4*7,5*1,6*1,7*2,8*74,9*2,10*1,11*1,12*1,13*1,14*1,15*1,16*2"; +w["xml-api"]="8*2,9*1"; +w["xml-apis.jar"]="0*2,8*11,9*1"; +w["xml-common"]="8*3"; +w["xml-commons:"]="8*3"; +w["xml."]="8*1"; +w["xml:"]="4*1"; +w["xp"]="8*1"; +w["xsl"]="0*2,2*2,4*3,5*1,8*3,9*2,15*2"; +w["xsl-webhelpindex"]="2*1"; +w["xsl:"]="0*2,4*3,15*1"; +w["xsls"]="8*1"; +w["xslt"]="0*3,8*5"; +w["xslt-processor-cl"]="8*3"; +w["xslt-processor-classpath"]="0*2,8*1"; +w["xsltproc"]="7*5,8*5"; +w["yahoogroup"]="3*1"; +w["yahoogroup."]="3*1"; +w["yes"]="0*1"; +w["yourfil"]="8*1"; +w["yourfile.xml"]="8*2"; +w["zh"]="8*1"; +w[" "]="0*4,1*3,2*3,3*8,4*3,5*3,6*4,7*4,8*4,9*3,10*3,11*4,12*4,13*3,14*3,15*3,16*3"; +w[" add"]="10*5"; +w[" exampl"]="13*5"; +w[" initi"]="10*5"; +w[" sampl"]="13*5"; +w["©"]="3*1"; +w["’d"]="0*1"; +w["“"]="3*1"; + diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/ja-jp.props b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/ja-jp.props new file mode 100644 index 000000000000..27568054c716 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/ja-jp.props @@ -0,0 +1 @@ +J01=\\u306B \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/l10n.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/l10n.js new file mode 100644 index 000000000000..f25bb8f62849 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/l10n.js @@ -0,0 +1,5 @@ + + //Resource strings for localization + var localeresource = new Object; + localeresource["search_no_results"]="Your search returned no results."; + \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/nwSearchFnt.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/nwSearchFnt.js new file mode 100644 index 000000000000..b115dbe0331b --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/nwSearchFnt.js @@ -0,0 +1,886 @@ +/*---------------------------------------------------------------------------- + * JavaScript for webhelp search + *---------------------------------------------------------------------------- + This file is part of the webhelpsearch plugin for DocBook WebHelp + Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved. + www.nexwave.biz Nadege Quaine + http://kasunbg.blogspot.com/ Kasun Gajasinghe + */ + +//string initialization +var htmlfileList = "htmlFileInfoList.js"; +var htmlfileinfoList = "htmlFileInfoList.js"; +var useCJKTokenizing = false; + +var w = new Object(); +var scoring = new Object(); + +var searchTextField = ''; +var no = 0; +var noWords = 0; +var partialSearch = "There is no page containing all the search terms.
      Partial results:
      "; +var warningMsg = '
      '; +warningMsg+='Please note that due to security settings, Google Chrome does not highlight'; +warningMsg+=' the search results in the right frame.
      '; +warningMsg+='This happens only when the WebHelp files are loaded from the local file system.
      '; +warningMsg+='Workarounds:'; +warningMsg+='
        '; +warningMsg+='
      • Try using another web browser.
      • '; +warningMsg+='
      • Deploy the WebHelp files on a web server.
      • '; +warningMsg+='
      '; +txt_filesfound = 'Results'; +txt_enter_at_least_1_char = "You must enter at least one character."; +txt_enter_more_than_10_words = "Only first 10 words will be processed."; +txt_browser_not_supported = "Your browser is not supported. Use of Mozilla Firefox is recommended."; +txt_please_wait = "Please wait. Search in progress..."; +txt_results_for = "Results for: "; + +/* This function verify the validity of search input by the user + Cette fonction verifie la validite de la recherche entrre par l utilisateur */ +function Verifie(searchForm) { + + // Check browser compatibility + if (navigator.userAgent.indexOf("Konquerer") > -1) { + + alert(txt_browser_not_supported); + return; + } + + searchTextField = trim(document.searchForm.textToSearch.value); + searchTextField = searchTextField.replace(/['"]/g,''); + var expressionInput = searchTextField; + $.cookie('textToSearch', expressionInput); + + if (expressionInput.length < 1) { + + // expression is invalid + alert(txt_enter_at_least_1_char); + // reactive la fenetre de search (utile car cadres) + + document.searchForm.textToSearch.focus(); + } + else { + var splitSpace = searchTextField.split(" "); + var splitWords = []; + for (var i = 0 ; i < splitSpace.length ; i++) { + var splitDot = splitSpace[i].split("."); + + if(!(splitDot.length == 1)){ + splitWords.push(splitSpace[i]); + } + + for (var i1 = 0; i1 < splitDot.length; i1++) { + var splitColon = splitDot[i1].split(":"); + for (var i2 = 0; i2 < splitColon.length; i2++) { + var splitDash = splitColon[i2].split("-"); + for (var i3 = 0; i3 < splitDash.length; i3++) { + if (splitDash[i3].split("").length > 0) { + splitWords.push(splitDash[i3]); + } + } + } + } + } + noWords = splitWords; + if (noWords.length > 9){ + // Allow to search maximum 10 words + alert(txt_enter_more_than_10_words); + expressionInput = ''; + for (var x = 0 ; x < 10 ; x++){ + expressionInput = expressionInput + " " + noWords[x]; + } + Effectuer_recherche(expressionInput); + document.searchForm.textToSearch.focus(); + } else { + // Effectuer la recherche + expressionInput = ''; + for (var x = 0 ; x < noWords.length ; x++) { + expressionInput = expressionInput + " " + noWords[x]; + } + Effectuer_recherche(expressionInput); + // reactive la fenetre de search (utile car cadres) + document.searchForm.textToSearch.focus(); + } + } +} + +var stemQueryMap = new Array(); // A hashtable which maps stems to query words + +/* This function parses the search expression, loads the indices and displays the results*/ +function Effectuer_recherche(expressionInput) { + + /* Display a waiting message */ + //DisplayWaitingMessage(); + + /*data initialisation*/ + var searchFor = ""; // expression en lowercase et sans les caracte res speciaux + //w = new Object(); // hashtable, key=word, value = list of the index of the html files + scriptLetterTab = new Scriptfirstchar(); // Array containing the first letter of each word to look for + var wordsList = new Array(); // Array with the words to look for + var finalWordsList = new Array(); // Array with the words to look for after removing spaces + var linkTab = new Array(); + var fileAndWordList = new Array(); + var txt_wordsnotfound = ""; + + + // -------------------------------------- + // Begin Thu's patch + /*nqu: expressionInput, la recherche est lower cased, plus remplacement des char speciaux*/ + //The original replacement expression is: + //searchFor = expressionInput.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, " 0){ + var searchedWords = noWords.length; + var foundedWords = fileAndWordList[0][0].motslisteDisplay.split(",").length; + //console.info("search : " + noWords.length + " found : " + fileAndWordList[0][0].motslisteDisplay.split(",").length); + if (searchedWords != foundedWords){ + linkTab.push(partialSearch); + } + } + + + for (var i = 0; i < cpt; i++) { + + var hundredProcent = fileAndWordList[i][0].scoring + 100 * fileAndWordList[i][0].motsnb; + var ttScore_first = fileAndWordList[i][0].scoring; + var numberOfWords = fileAndWordList[i][0].motsnb; + + if (fileAndWordList[i] != undefined) { + linkTab.push("

      " + txt_results_for + " " + "" + fileAndWordList[i][0].motslisteDisplay + "" + "

      "); + + linkTab.push("
        "); + for (t in fileAndWordList[i]) { + //linkTab.push("
      • "+fl[fileAndWordList[i][t].filenb]+"
      • "); + + var ttInfo = fileAndWordList[i][t].filenb; + // Get scoring + var ttScore = fileAndWordList[i][t].scoring; + var tempInfo = fil[ttInfo]; + + var pos1 = tempInfo.indexOf("@@@"); + var pos2 = tempInfo.lastIndexOf("@@@"); + var tempPath = tempInfo.substring(0, pos1); + var tempTitle = tempInfo.substring(pos1 + 3, pos2); + var tempShortdesc = tempInfo.substring(pos2 + 3, tempInfo.length); + + + // toc.html will not be displayed on search result + if (tempPath == 'toc.html'){ + continue; + } + /* + //file:///home/kasun/docbook/WEBHELP/webhelp-draft-output-format-idea/src/main/resources/web/webhelp/installation.html + var linkString = "
      • " + tempTitle + ""; + // var linkString = "
      • " + tempTitle + ""; + */ + var split = fileAndWordList[i][t].motsliste.split(","); + // var splitedValues = expressionInput.split(" "); + // var finalArray = split.concat(splitedValues); + + arrayString = 'Array('; + for(var x in finalArray){ + if (finalArray[x].length > 2 || useCJKTokenizing){ + arrayString+= "'" + finalArray[x] + "',"; + } + } + arrayString = arrayString.substring(0,arrayString.length - 1) + ")"; + var idLink = 'foundLink' + no; + var linkString = '
      • ' + tempTitle + ''; + var starWidth = (ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent) * (numberOfWords/maxNumberOfWords); + starWidth = starWidth < 10 ? (starWidth + 5) : starWidth; + // Keep the 5 stars format + if (starWidth > 85){ + starWidth = 85; + } + /* + var noFullStars = Math.ceil(starWidth/17); + var fullStar = "curr"; + var emptyStar = ""; + if (starWidth % 17 == 0){ + // am stea plina + + } else { + + } + console.info(noFullStars); + */ + // Also check if we have a valid description + if ((tempShortdesc != "null" && tempShortdesc != '...')) { + + linkString += "\n
        " + tempShortdesc + "
        "; + } + linkString += "
      • "; + + // Add rating values for scoring at the list of matches + linkString += "
        "; + linkString += "
        "; + //linkString += "
        " + // + ((ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent)) * 1 + "
        "; + linkString += "
          "; + linkString += "
        • "; + linkString += "
        "; + + linkString += "
        "; + linkString += "
        "; + linkString += "
        "; + //linkString += 'Rating: ' + ttScore + ''; + + linkTab.push(linkString); + no++; + } + linkTab.push("
      "); + } + } + } + + var results = ""; + if (linkTab.length > 0) { + /*writeln ("

      " + txt_results_for + " " + "" + cleanwordsList + "" + "
      "+"

      ");*/ + results = "

      "; + //write("

        "); + for (t in linkTab) { + results += linkTab[t].toString(); + } + results += "

        "; + } else { + results = "

        " + localeresource.search_no_results + " " + txt_wordsnotfound + "" + "

        "; + } + + + // Verify if the browser is Google Chrome and the WebHelp is used on a local machine + // If browser is Google Chrome and WebHelp is used on a local machine a warning message will appear + // Highlighting will not work in this conditions. There is 2 workarounds + if (verifyBrowser()){ + document.getElementById('searchResults').innerHTML = results; + } else { + document.getElementById('searchResults').innerHTML = warningMsg + results; + } + +} + + +// Verify if the stemmed word is aproximately the same as the searched word +function verifyWord(word, arr){ + for (var i = 0 ; i < arr.length ; i++){ + if (word[0] == arr[i][0] + && word[1] == arr[i][1] + //&& word[2] == arr[i][2] + ){ + return true; + } + } + return false; +} + +// Look for elements that start with searchedValue. +function wordsStartsWith(searchedValue){ + var toReturn = ''; + for (var sv in w){ + if (searchedValue.length < 3){ + continue; + } else { + if (sv.toLowerCase().indexOf(searchedValue.toLowerCase()) == 0){ + toReturn+=sv + ","; + } + } + } + return toReturn.length > 0 ? toReturn : undefined; +} + + +function tokenize(wordsList){ + var stemmedWordsList = new Array(); // Array with the words to look for after removing spaces + var cleanwordsList = new Array(); // Array with the words to look for + // ------------------------------------------------- + // Thu's patch + for(var j=0;j"; + return this.input.substring(this.offset,this.offset+2); + } + + function getAllTokens(){ + while(this.incrementToken()){ + var tmp = this.tokenize(); + this.tokens.push(tmp); + } + return this.unique(this.tokens); +// document.getElementById("content").innerHTML += tokens+" "; +// document.getElementById("content").innerHTML += "
        dada"+sortedTokens+" "; +// console.log(tokens.length+"dsdsds"); + /*for(i=0;i t2.length) { + return 1; + } else { + return -1; + } + //return t1.length - t2.length); +} + +// return false if browser is Google Chrome and WebHelp is used on a local machine, not a web server +function verifyBrowser(){ + var returnedValue = true; + var browser = BrowserDetect.browser; + var addressBar = window.location.href; + if (browser == 'Chrome' && addressBar.indexOf('file://') === 0){ + returnedValue = false; + } + + return returnedValue; +} + +// Remove duplicate values from an array +function removeDuplicate(arr) { + var r = new Array(); + o:for(var i = 0, n = arr.length; i < n; i++) { + for(var x = 0, y = r.length; x < y; x++) { + if(r[x]==arr[i]) continue o; + } + r[r.length] = arr[i]; + } + return r; +} + +// Create startsWith method +String.prototype.startsWith = function(str) { + return (this.match("^"+str)==str); +} + +function trim(str, chars) { + return ltrim(rtrim(str, chars), chars); +} + +function ltrim(str, chars) { + chars = chars || "\\s"; + return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); +} + +function rtrim(str, chars) { + chars = chars || "\\s"; + return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); +} diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/punctuation.props b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/punctuation.props new file mode 100644 index 000000000000..d3e3fcd28ba0 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/punctuation.props @@ -0,0 +1,31 @@ +Punct01=\\u3002 +Punct02=\\u3003 +Punct03=\\u300C +Punct04=\\u300D +Punct05=\\u300E +Punct06=\\u300F +Punct07=\\u301D +Punct08=\\u301E +Punct09=\\u301F +Punct10=\\u309B +Punct11=\\u2018 +Punct12=\\u2019 +Punct13=\\u201A +Punct14=\\u201C +Punct15=\\u201D +Punct16=\\u201E +Punct17=\\u2032 +Punct18=\\u2033 +Punct19=\\u2035 +Punct20=\\u2039 +Punct21=\\u203A +Punct22=\\u201E +Punct23=\\u00BB +Punct24=\\u00AB +Punct25=© +Punct26=’ +Punct27=\\u00A0 +Punct28=\\u2014 + + + diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/de_stemmer.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/de_stemmer.js new file mode 100644 index 000000000000..7ff3822a45ba --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/de_stemmer.js @@ -0,0 +1,247 @@ +/* + * Author: Joder Illi + * + * Copyright (c) 2010, FormBlitz AG + * All rights reserved. + * Implementation of the stemming algorithm from http://snowball.tartarus.org/algorithms/german/stemmer.html + * Copyright of the algorithm is: Copyright (c) 2001, Dr Martin Porter and can be found at http://snowball.tartarus.org/license.php + * + * Redistribution and use in source and binary forms, with or without modification, is covered by the standard BSD license. + * + */ + +//var stemmer = function Stemmer() { + /* + German includes the following accented forms, + ä ö ü + and a special letter, ß, equivalent to double s. + The following letters are vowels: + a e i o u y ä ö ü + */ + + var stemmer = function(word) { + /* + Put u and y between vowels into upper case + */ + word = word.replace(/([aeiouyäöü])u([aeiouyäöü])/g, '$1U$2'); + word = word.replace(/([aeiouyäöü])y([aeiouyäöü])/g, '$1Y$2'); + + /* + and then do the following mappings, + (a) replace ß with ss, + (a) replace ae with ä, Not doing these, have trouble with diphtongs + (a) replace oe with ö, Not doing these, have trouble with diphtongs + (a) replace ue with ü unless preceded by q. Not doing these, have trouble with diphtongs + So in quelle, ue is not mapped to ü because it follows q, and in feuer it is not mapped because the first part of the rule changes it to feUer, so the u is not found. + */ + word = word.replace(/ß/g, 'ss'); + //word = word.replace(/ae/g, 'ä'); + //word = word.replace(/oe/g, 'ö'); + //word = word.replace(/([^q])ue/g, '$1ü'); + + /* + R1 and R2 are first set up in the standard way (see the note on R1 and R2), but then R1 is adjusted so that the region before it contains at least 3 letters. + R1 is the region after the first non-vowel following a vowel, or is the null region at the end of the word if there is no such non-vowel. + R2 is the region after the first non-vowel following a vowel in R1, or is the null region at the end of the word if there is no such non-vowel. + */ + + var r1Index = word.search(/[aeiouyäöü][^aeiouyäöü]/); + var r1 = ''; + if (r1Index != -1) { + r1Index += 2; + r1 = word.substring(r1Index); + } + + var r2Index = -1; + var r2 = ''; + + if (r1Index != -1) { + var r2Index = r1.search(/[aeiouyäöü][^aeiouyäöü]/); + if (r2Index != -1) { + r2Index += 2; + r2 = r1.substring(r2Index); + r2Index += r1Index; + } else { + r2 = ''; + } + } + + if (r1Index != -1 && r1Index < 3) { + r1Index = 3; + r1 = word.substring(r1Index); + } + + /* + Define a valid s-ending as one of b, d, f, g, h, k, l, m, n, r or t. + Define a valid st-ending as the same list, excluding letter r. + */ + + /* + Do each of steps 1, 2 and 3. + */ + + /* + Step 1: + Search for the longest among the following suffixes, + (a) em ern er + (b) e en es + (c) s (preceded by a valid s-ending) + */ + var a1Index = word.search(/(em|ern|er)$/g); + var b1Index = word.search(/(e|en|es)$/g); + var c1Index = word.search(/([bdfghklmnrt]s)$/g); + if (c1Index != -1) { + c1Index++; + } + var index1 = 10000; + var optionUsed1 = ''; + if (a1Index != -1 && a1Index < index1) { + optionUsed1 = 'a'; + index1 = a1Index; + } + if (b1Index != -1 && b1Index < index1) { + optionUsed1 = 'b'; + index1 = b1Index; + } + if (c1Index != -1 && c1Index < index1) { + optionUsed1 = 'c'; + index1 = c1Index; + } + + /* + and delete if in R1. (Of course the letter of the valid s-ending is not necessarily in R1.) If an ending of group (b) is deleted, and the ending is preceded by niss, delete the final s. + (For example, äckern -> äck, ackers -> acker, armes -> arm, bedürfnissen -> bedürfnis) + */ + + if (index1 != 10000 && r1Index != -1) { + if (index1 >= r1Index) { + word = word.substring(0, index1); + if (optionUsed1 == 'b') { + if (word.search(/niss$/) != -1) { + word = word.substring(0, word.length -1); + } + } + } + } + /* + Step 2: + Search for the longest among the following suffixes, + (a) en er est + (b) st (preceded by a valid st-ending, itself preceded by at least 3 letters) + */ + + var a2Index = word.search(/(en|er|est)$/g); + var b2Index = word.search(/(.{3}[bdfghklmnt]st)$/g); + if (b2Index != -1) { + b2Index += 4; + } + + var index2 = 10000; + var optionUsed2 = ''; + if (a2Index != -1 && a2Index < index2) { + optionUsed2 = 'a'; + index2 = a2Index; + } + if (b2Index != -1 && b2Index < index2) { + optionUsed2 = 'b'; + index2 = b2Index; + } + + /* + and delete if in R1. + (For example, derbsten -> derbst by step 1, and derbst -> derb by step 2, since b is a valid st-ending, and is preceded by just 3 letters) + */ + + if (index2 != 10000 && r1Index != -1) { + if (index2 >= r1Index) { + word = word.substring(0, index2); + } + } + + /* + Step 3: d-suffixes (*) + Search for the longest among the following suffixes, and perform the action indicated. + end ung + delete if in R2 + if preceded by ig, delete if in R2 and not preceded by e + ig ik isch + delete if in R2 and not preceded by e + lich heit + delete if in R2 + if preceded by er or en, delete if in R1 + keit + delete if in R2 + if preceded by lich or ig, delete if in R2 + */ + + var a3Index = word.search(/(end|ung)$/g); + var b3Index = word.search(/[^e](ig|ik|isch)$/g); + var c3Index = word.search(/(lich|heit)$/g); + var d3Index = word.search(/(keit)$/g); + if (b3Index != -1) { + b3Index ++; + } + + var index3 = 10000; + var optionUsed3 = ''; + if (a3Index != -1 && a3Index < index3) { + optionUsed3 = 'a'; + index3 = a3Index; + } + if (b3Index != -1 && b3Index < index3) { + optionUsed3 = 'b'; + index3 = b3Index; + } + if (c3Index != -1 && c3Index < index3) { + optionUsed3 = 'c'; + index3 = c3Index; + } + if (d3Index != -1 && d3Index < index3) { + optionUsed3 = 'd'; + index3 = d3Index; + } + + if (index3 != 10000 && r2Index != -1) { + if (index3 >= r2Index) { + word = word.substring(0, index3); + var optionIndex = -1; + var optionSubsrt = ''; + if (optionUsed3 == 'a') { + optionIndex = word.search(/[^e](ig)$/); + if (optionIndex != -1) { + optionIndex++; + if (optionIndex >= r2Index) { + word = word.substring(0, optionIndex); + } + } + } else if (optionUsed3 == 'c') { + optionIndex = word.search(/(er|en)$/); + if (optionIndex != -1) { + if (optionIndex >= r1Index) { + word = word.substring(0, optionIndex); + } + } + } else if (optionUsed3 == 'd') { + optionIndex = word.search(/(lich|ig)$/); + if (optionIndex != -1) { + if (optionIndex >= r2Index) { + word = word.substring(0, optionIndex); + } + } + } + } + } + + /* + Finally, + turn U and Y back into lower case, and remove the umlaut accent from a, o and u. + */ + word = word.replace(/U/g, 'u'); + word = word.replace(/Y/g, 'y'); + word = word.replace(/ä/g, 'a'); + word = word.replace(/ö/g, 'o'); + word = word.replace(/ü/g, 'u'); + + return word; + }; +//} \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/en_stemmer.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/en_stemmer.js new file mode 100644 index 000000000000..2117c1bfb305 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/en_stemmer.js @@ -0,0 +1,234 @@ +// Porter stemmer in Javascript. Few comments, but it's easy to follow against the rules in the original +// paper, in +// +// Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14, +// no. 3, pp 130-137, +// +// see also http://www.tartarus.org/~martin/PorterStemmer + +// Release 1 +// Derived from (http://tartarus.org/~martin/PorterStemmer/js.txt) - cjm (iizuu) Aug 24, 2009 + +var stemmer = (function(){ + var step2list = { + "ational" : "ate", + "tional" : "tion", + "enci" : "ence", + "anci" : "ance", + "izer" : "ize", + "bli" : "ble", + "alli" : "al", + "entli" : "ent", + "eli" : "e", + "ousli" : "ous", + "ization" : "ize", + "ation" : "ate", + "ator" : "ate", + "alism" : "al", + "iveness" : "ive", + "fulness" : "ful", + "ousness" : "ous", + "aliti" : "al", + "iviti" : "ive", + "biliti" : "ble", + "logi" : "log" + }, + + step3list = { + "icate" : "ic", + "ative" : "", + "alize" : "al", + "iciti" : "ic", + "ical" : "ic", + "ful" : "", + "ness" : "" + }, + + c = "[^aeiou]", // consonant + v = "[aeiouy]", // vowel + C = c + "[^aeiouy]*", // consonant sequence + V = v + "[aeiou]*", // vowel sequence + + mgr0 = "^(" + C + ")?" + V + C, // [C]VC... is m>0 + meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$", // [C]VC[V] is m=1 + mgr1 = "^(" + C + ")?" + V + C + V + C, // [C]VCVC... is m>1 + s_v = "^(" + C + ")?" + v; // vowel in stem + + return function (w) { + var stem, + suffix, + firstch, + re, + re2, + re3, + re4, + origword = w; + + if (w.length < 3) { return w; } + + firstch = w.substr(0,1); + if (firstch == "y") { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) { w = w.replace(re,"$1$2"); } + else if (re2.test(w)) { w = w.replace(re2,"$1$2"); } + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) { w = w + "e"; } + else if (re3.test(w)) { re = /.$/; w = w.replace(re,""); } + else if (re4.test(w)) { w = w + "e"; } + } + } + + // Step 1c + re = new RegExp("^(.+" + c + ")y$"); + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + w = stem + "i"; + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) { + w = stem; + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) { + w = stem; + } + } + + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + + if (firstch == "y") { + w = firstch.toLowerCase() + w.substr(1); + } + + // See http://snowball.tartarus.org/algorithms/english/stemmer.html + // "Exceptional forms in general" + var specialWords = { + "skis" : "ski", + "skies" : "sky", + "dying" : "die", + "lying" : "lie", + "tying" : "tie", + "idly" : "idl", + "gently" : "gentl", + "ugly" : "ugli", + "early": "earli", + "only": "onli", + "singly": "singl" + }; + + if(specialWords[origword]){ + w = specialWords[origword]; + } + + if( "sky news howe atlas cosmos bias \ + andes inning outing canning herring \ + earring proceed exceed succeed".indexOf(origword) !== -1 ){ + w = origword; + } + + // Address words overstemmed as gener- + re = /.*generate?s?d?(ing)?$/; + if( re.test(origword) ){ + w = w + 'at'; + } + re = /.*general(ly)?$/; + if( re.test(origword) ){ + w = w + 'al'; + } + re = /.*generic(ally)?$/; + if( re.test(origword) ){ + w = w + 'ic'; + } + re = /.*generous(ly)?$/; + if( re.test(origword) ){ + w = w + 'ous'; + } + // Address words overstemmed as commun- + re = /.*communit(ies)?y?/; + if( re.test(origword) ){ + w = w + 'iti'; + } + + return w; + } +})(); diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/fr_stemmer.js b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/fr_stemmer.js new file mode 100644 index 000000000000..34f974313259 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docs/search/stemmers/fr_stemmer.js @@ -0,0 +1,299 @@ +/* + * Author: Kasun Gajasinghe + * E-Mail: kasunbg AT gmail DOT com + * Date: 09.08.2010 + * + * usage: stemmer(word); + * ex: var stem = stemmer(foobar); + * Implementation of the stemming algorithm from http://snowball.tartarus.org/algorithms/french/stemmer.html + * + * LICENSE: + * + * Copyright (c) 2010, Kasun Gajasinghe. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * + * THIS SOFTWARE IS PROVIDED BY KASUN GAJASINGHE ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KASUN GAJASINGHE BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +var stemmer = function(word){ +// Letters in French include the following accented forms, +// â à ç ë é ê è ï î ô û ù +// The following letters are vowels: +// a e i o u y â à ë é ê è ï î ô û ù + + word = word.toLowerCase(); + var oriWord = word; + word = word.replace(/qu/g, 'qU'); //have to perform first, as after the operation, capital U is not treated as a vowel + word = word.replace(/([aeiouyâàëéêèïîôûù])u([aeiouyâàëéêèïîôûù])/g, '$1U$2'); + word = word.replace(/([aeiouyâàëéêèïîôûù])i([aeiouyâàëéêèïîôûù])/g, '$1I$2'); + word = word.replace(/([aeiouyâàëéêèïîôûù])y/g, '$1Y'); + word = word.replace(/y([aeiouyâàëéêèïîôûù])/g, 'Y$1'); + + var rv=''; + var rvIndex = -1; + if(word.search(/^(par|col|tap)/) != -1 || word.search(/^[aeiouyâàëéêèïîôûù]{2}/) != -1){ + rv = word.substring(3); + rvIndex = 3; + } else { + rvIndex = word.substring(1).search(/[aeiouyâàëéêèïîôûù]/); + if(rvIndex != -1){ + rvIndex +=2; //+2 is to supplement the substring(1) used to find rvIndex + rv = word.substring(rvIndex); + } else { + rvIndex = word.length; + } + } + +// R1 is the region after the first non-vowel following a vowel, or the end of the word if there is no such non-vowel. +// R2 is the region after the first non-vowel following a vowel in R1, or the end of the word if there is no such non-vowel + var r1Index = word.search(/[aeiouyâàëéêèïîôûù][^aeiouyâàëéêèïîôûù]/); + var r1 = ''; + if (r1Index != -1) { + r1Index += 2; + r1 = word.substring(r1Index); + } else { + r1Index = word.length; + } + + var r2Index = -1; + var r2 = ''; + if (r1Index != -1) { + r2Index = r1.search(/[aeiouyâàëéêèïîôûù][^aeiouyâàëéêèïîôûù]/); + if (r2Index != -1) { + r2Index += 2; + r2 = r1.substring(r2Index); + r2Index += r1Index; + } else { + r2 = ''; + r2Index = word.length; + } + } + if (r1Index != -1 && r1Index < 3) { + r1Index = 3; + r1 = word.substring(r1Index); + } + + /* + Step 1: Standard suffix removal + */ + var a1Index = word.search(/(ance|iqUe|isme|able|iste|eux|ances|iqUes|ismes|ables|istes)$/); + var a2Index = word.search(/(atrice|ateur|ation|atrices|ateurs|ations)$/); + var a3Index = word.search(/(logie|logies)$/); + var a4Index = word.search(/(usion|ution|usions|utions)$/); + var a5Index = word.search(/(ence|ences)$/); + var a6Index = word.search(/(ement|ements)$/); + var a7Index = word.search(/(ité|ités)$/); + var a8Index = word.search(/(if|ive|ifs|ives)$/); + var a9Index = word.search(/(eaux)$/); + var a10Index = word.search(/(aux)$/); + var a11Index = word.search(/(euse|euses)$/); + var a12Index = word.search(/[^aeiouyâàëéêèïîôûù](issement|issements)$/); + var a13Index = word.search(/(amment)$/); + var a14Index = word.search(/(emment)$/); + var a15Index = word.search(/[aeiouyâàëéêèïîôûù](ment|ments)$/); + + if(a1Index != -1 && a1Index >= r2Index){ + word = word.substring(0,a1Index); + } else if(a2Index != -1 && a2Index >= r2Index){ + word = word.substring(0,a2Index); + var a2Index2 = word.search(/(ic)$/); + if(a2Index2 != -1 && a2Index2 >= r2Index){ + word = word.substring(0, a2Index2); //if preceded by ic, delete if in R2, + } else { //else replace by iqU + word = word.replace(/(ic)$/,'iqU'); + } + } else if(a3Index != -1 && a3Index >= r2Index){ + word = word.replace(/(logie|logies)$/,'log'); //replace with log if in R2 + } else if(a4Index != -1 && a4Index >= r2Index){ + word = word.replace(/(usion|ution|usions|utions)$/,'u'); //replace with u if in R2 + } else if(a5Index != -1 && a5Index >= r2Index){ + word = word.replace(/(ence|ences)$/,'ent'); //replace with ent if in R2 + } else if(a6Index != -1 && a6Index >= rvIndex){ + word = word.substring(0,a6Index); + if(word.search(/(iv)$/) >= r2Index){ + word = word.replace(/(iv)$/, ''); + if(word.search(/(at)$/) >= r2Index){ + word = word.replace(/(at)$/, ''); + } + } else if(word.search(/(eus)$/) != -1){ + var a6Index2 = word.search(/(eus)$/); + if(a6Index2 >=r2Index){ + word = word.substring(0, a6Index2); + } else if(a6Index2 >= r1Index){ + word = word.substring(0,a6Index2)+"eux"; + } + } else if(word.search(/(abl|iqU)$/) >= r2Index){ + word = word.replace(/(abl|iqU)$/,''); //if preceded by abl or iqU, delete if in R2, + } else if(word.search(/(ièr|Ièr)$/) >= rvIndex){ + word = word.replace(/(ièr|Ièr)$/,'i'); //if preceded by abl or iqU, delete if in R2, + } + } else if(a7Index != -1 && a7Index >= r2Index){ + word = word.substring(0,a7Index); //delete if in R2 + if(word.search(/(abil)$/) != -1){ //if preceded by abil, delete if in R2, else replace by abl, otherwise, + var a7Index2 = word.search(/(abil)$/); + if(a7Index2 >=r2Index){ + word = word.substring(0, a7Index2); + } else { + word = word.substring(0,a7Index2)+"abl"; + } + } else if(word.search(/(ic)$/) != -1){ + var a7Index3 = word.search(/(ic)$/); + if(a7Index3 != -1 && a7Index3 >= r2Index){ + word = word.substring(0, a7Index3); //if preceded by ic, delete if in R2, + } else { //else replace by iqU + word = word.replace(/(ic)$/,'iqU'); + } + } else if(word.search(/(iv)$/) != r2Index){ + word = word.replace(/(iv)$/,''); + } + } else if(a8Index != -1 && a8Index >= r2Index){ + word = word.substring(0,a8Index); + if(word.search(/(at)$/) >= r2Index){ + word = word.replace(/(at)$/, ''); + if(word.search(/(ic)$/) >= r2Index){ + word = word.replace(/(ic)$/, ''); + } else { word = word.replace(/(ic)$/, 'iqU'); } + } + } else if(a9Index != -1){ word = word.replace(/(eaux)/,'eau') + } else if(a10Index >= r1Index){ word = word.replace(/(aux)/,'al') + } else if(a11Index != -1 ){ + var a11Index2 = word.search(/(euse|euses)$/); + if(a11Index2 >=r2Index){ + word = word.substring(0, a11Index2); + } else if(a11Index2 >= r1Index){ + word = word.substring(0, a11Index2)+"eux"; + } + } else if(a12Index!=-1 && a12Index>=r1Index){ + word = word.substring(0,a12Index+1); //+1- amendment to non-vowel + } else if(a13Index!=-1 && a13Index>=rvIndex){ + word = word.replace(/(amment)$/,'ant'); + } else if(a14Index!=-1 && a14Index>=rvIndex){ + word = word.replace(/(emment)$/,'ent'); + } else if(a15Index!=-1 && a15Index>=rvIndex){ + word = word.substring(0,a15Index+1); + } + + /* Step 2a: Verb suffixes beginning i*/ + var wordStep1 = word; + var step2aDone = false; + if(oriWord == word.toLowerCase() || oriWord.search(/(amment|emment|ment|ments)$/) != -1){ + step2aDone = true; + var b1Regex = /([^aeiouyâàëéêèïîôûù])(îmes|ît|îtes|i|ie|ies|ir|ira|irai|iraIent|irais|irait|iras|irent|irez|iriez|irions|irons|iront|is|issaIent|issais|issait|issant|issante|issantes|issants|isse|issent|isses|issez|issiez|issions|issons|it)$/i; + if(word.search(b1Regex) >= rvIndex){ + word = word.replace(b1Regex,'$1'); + } + } + + /* Step 2b: Other verb suffixes*/ + if (step2aDone && wordStep1 == word) { + if (word.search(/(ions)$/) >= r2Index) { + word = word.replace(/(ions)$/, ''); + } else { + var b2Regex = /(é|ée|ées|és|èrent|er|era|erai|eraIent|erais|erait|eras|erez|eriez|erions|erons|eront|ez|iez)$/i; + if (word.search(b2Regex) >= rvIndex) { + word = word.replace(b2Regex, ''); + } else { + var b3Regex = /e(âmes|ât|âtes|a|ai|aIent|ais|ait|ant|ante|antes|ants|as|asse|assent|asses|assiez|assions)$/i; + if (word.search(b3Regex) >= rvIndex) { + word = word.replace(b3Regex, ''); + } else { + var b3Regex2 = /(âmes|ât|âtes|a|ai|aIent|ais|ait|ant|ante|antes|ants|as|asse|assent|asses|assiez|assions)$/i; + if (word.search(b3Regex2) >= rvIndex) { + word = word.replace(b3Regex2, ''); + } + } + } + } + } + + if(oriWord != word.toLowerCase()){ + /* Step 3 */ + var rep = ''; + if(word.search(/Y$/) != -1) { + word = word.replace(/Y$/, 'i'); + } else if(word.search(/ç$/) != -1){ + word = word.replace(/ç$/, 'c'); + } + } else { + /* Step 4 */ + //If the word ends s, not preceded by a, i, o, u, è or s, delete it. + if (word.search(/([^aiouès])s$/) >= rvIndex) { + word = word.replace(/([^aiouès])s$/, '$1'); + } + var e1Index = word.search(/ion$/); + if (e1Index >= r2Index && word.search(/[st]ion$/) >= rvIndex) { + word = word.substring(0, e1Index); + } else { + var e2Index = word.search(/(ier|ière|Ier|Ière)$/); + if (e2Index != -1 && e2Index >= rvIndex) { + word = word.substring(0, e2Index) + "i"; + } else { + if (word.search(/e$/) >= rvIndex) { + word = word.replace(/e$/, ''); //delete last e + } else if (word.search(/guë$/) >= rvIndex) { + word = word.replace(/guë$/, 'gu'); + } + } + } + } + + /* Step 5: Undouble */ + //word = word.replace(/(en|on|et|el|eil)(n|t|l)$/,'$1'); + word = word.replace(/(en|on)(n)$/,'$1'); + word = word.replace(/(ett)$/,'et'); + word = word.replace(/(el|eil)(l)$/,'$1'); + + /* Step 6: Un-accent */ + word = word.replace(/[éè]([^aeiouyâàëéêèïîôûù]+)$/,'e$1'); + word = word.toLowerCase(); + return word; +}; + +var eqOut = new Array(); +var noteqOut = new Array(); +var eqCount = 0; +/* +To test the stemming, create two arrays named "voc" and "COut" which are for vocabualary and the stemmed output. +Then add the vocabulary strings and output strings. This method will generate the stemmed output for "voc" and will +compare the output with COut. + (I used porter's voc and out files and did a regex to convert them to js objects. regex: /");\nvoc.push("/g . This + will add strings to voc array such that output would look like: voc.push("foobar"); ) drop me an email for any help. + */ +function testFr(){ + var start = new Date().getTime(); //execution time + eqCount = 0; + eqOut = new Array(); + noteqOut = new Array(); + for(var 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�lJnlbk@ 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/readme.xml b/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/readme.xml new file mode 100644 index 000000000000..ea4896976a01 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/readme.xml @@ -0,0 +1,1030 @@ + + + + + + + + +]> + + README: Web-based Help from DocBook XML + + + 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. + + + Except as contained in this notice, the names of individuals credited with + contribution to this software shall not be used in advertising or otherwise to promote + the sale, use or other dealings in this Software without prior written authorization + from the individuals in question. + + + Any stylesheet derived from this Software that is publicly distributed will be + identified with a different name and the version strings in any derived Software will + be changed so that no possibility of confusion between the derived package and this + Software will exist. + + + + Warranty: + 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 DAVID CRAMER, KASUN GAJASINGHE, OR ANY + OTHER CONTRIBUTOR 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 package is maintained by Kasun Gajasinghe, + kasunbg AT gmail DOT com and David Cramer, + david AT thingbag DOT net and with + contributions by Arun Bharadwaj and Visitha Baddegama. Please + direct support questions to the DocBook-apps + mailing list. + This package also includes the following software written and copyrighted by others: + + Files in template/common/jquery are + copyrighted by JQuery under the MIT License. + The file jquery.cookie.js Copyright (c) 2006 Klaus Hartl under + the MIT license. + + jquery + + + + Some files in the template/search and indexer directories were + originally part of N. Quaine's htmlsearch DITA plugin. + The htmlsearch DITA plugin is available from the files page of the DITA-users yahoogroup. The + htmlsearch plugin was released under a BSD-style + license. See indexer/license.txt + for details. + htmlsearch + + + DITA + htmlsearch plugin + + + + Stemmers from the Snowball + project released under a BSD license. + + + Code from the Apache Lucene search + engine provides support for tokenizing Chinese, Japanese, and Korean content released + under the Apache 2.0 license. + + + Code that provides weighted search results and some + other improvements was graciously donated by SyncRO Soft + Ltd., the publishers of the oXygen XML + Editor. + + + TagSoup, released under the Apache 2.0 + license, makes it possible to index html instead of just + xhtml output. + + + Cosmetic improvements provided by OpenStack. + + Webhelp for DocBook was first developed as a Google Summer of Code project. + + + 2008-2012 + Kasun Gajasinghe + David Cramer + + + David + Cramer + david AT thingbag DOT net + + + Kasun + Gajasinghe + kasunbg AT gmail DOT com + + January 2012 + + + + + + Overview of the package. + + + Introduction + A common requirement for technical publications groups is to produce a Web-based help + format that includes a table of contents pane, a search feature, and an index similar to what + you get from the Microsoft HTML Help (.chm) format or Eclipse help. If the content is help for + a Web application that is not exposed to the Internet or requires that the user be logged in, + then it is impossible to use services like Google to add search. + features + + + Features + + Sophisticated CSS-based page layout + + + Client-side search. + search + features + + + + Provides full content search of the documentation. Shows the search results with + links to chunked pages, and a small description. + + + Search results scoring/rating - The results are weighted according to how many + times the words in search query appears in it, is it bold or not, is in index terms + etc. The score out of 5 is shown by small colored boxes after each + search-result. + + + Search results can include brief descriptions of the target. + search + description + + + + Stemming support for English, French, and German. Stemming support can be added + for other languages by implementing a stemmer. + search + stemming + + + + Support for Chinese, Japanese, and Korean languages using code from the Lucene search + engine. + + + Search highlighting shows where the searched term appears in the results. + + search + highlighting + + + + + + Table of contents (TOC) pane with collapsible toc tree. + + + Auto-synchronization of content pane and TOC. + + + Nicely placed small forward, backward, top links + + + TOC and search pane implemented without the use of a frameset. + + + An Ant script and sample Makefile to generate output. + You can use the ant build file by importing it into your + own or use it as a model for integrating this output + format into your own build system. Alternatively, you can + use the build scripts as a template for creating your own + script. You can also generate webhelp from DocBook using + the Docbkx Maven plugin. + + + + + Using the package + The following sections describe how to + install and use the package on Windows with the sample Ant build + script. In an environment where unix shell command are + available, you can also use the + Makefile.sample as a starting point for + creating your build script. To use + Makefile.sample you must have + xsltproc and java + available in your PATH. +
        + + + Installation instructions + + + Generating webhelp output using the Ant build.xml + file + + To install the package + + The examples in this procedure assume a Windows + installation, but the process is the same in other + environments, mutatis + mutandis. In an environment where unix + shell command are available, you can also use the + Makefile.sample as a starting point + for creating your build script. To use + Makefile.sample you must have + xsltproc and java + available in your PATH. You can also use + the Docbkx Maven plugin to generate webhelp. + + + If necessary, install Java + 1.6 or higher. + + + Confirm that Java is installed and in your PATH by typing the + following at a command prompt: java -version + + To build the indexer, you must have the JDK. + + + + + + If necessary, install Apache + Ant 1.8.0 or higher. See Ant installation instructions. + + + Unzip the Ant binary distribution to a convenient location on your system. For + example: c:\Program Files. + + + Set the environment variable ANT_HOME to the top-level Ant + directory. For example: c:\Program Files\apache-ant-1.8.0. + See How To Manage + Environment Variables in Windows XP for information on setting + environment variables. + + + + Add the Ant bin directory to your PATH. For + example: c:\Program Files\apache-ant-1.8.0\bin + + + Confirm that Ant is installed by typing the following at a command prompt: + ant -version + + If you see a message about the file tools.jar being + missing, you can safely ignore it. + + + + + + Download Saxon + 6.5.x and unzip the distribution to a convenient location on your file system. + You will use the path to saxon.jar in below. + The build.xml has only been tested with Saxon 6.5, though + it could be adapted to work with other XSLT processors. However, when you generate + output, the Saxon jar must not be in your + CLASSPATH. + + + + Download Xerces2 + Java and extract it to a convenient location on + your file system. You will need the + xercesImpl.jar and + xml-apis.jar from this distribution + in in . + + + In a text editor, edit the + build.properties file in the + webhelp directory and make the changes indicated by the comments. + You must set appropriate values for + xslt-processor-classpath, + xercesImpl.jar, and + xml-apis.jar. + See the DocBook reference + documentation for detailed information about the + available webhelp and other parameters. Note that not all + DocBook parameters are passed in to the xsls by the + build.xml by default. You may need + to modify the build.xml to pass in + some DocBook + parameters. +# The path (relative to the build.xml file) to your input document. +# To use your own input document, create a build.xml file of your own +# and import this build.xml. +input-xml=docsrc/readme.xml + +# The directory in which to put the output files. +# This directory is created if it does not exist. +output-dir=docs + +# If you are using a customization layer that imports webhelp.xsl, use +# this property to point to it. +stylesheet-path=${ant.file.dir}/xsl/webhelp.xsl + +# If your document has image directories that need to be copied +# to the output directory, you can list patterns here. +# See the Ant documentation for fileset for documentation +# on patterns. +#input-images-dirs=images/**,figures/**,graphics/** + +# By default, the ant script assumes your images are stored +# in the same directory as the input-xml. If you store your +# image directories in another directory, specify it here. +# and uncomment this line. +#input-images-basedir=/path/to/image/location + +# Modify the follosing so that they point to your local +# copy of the jars indicated: +# * Saxon 6.5 jar +# * Xerces 2: xercesImpl.jar +# * xml-commons: xml-apis.jar +xslt-processor-classpath=/usr/share/java/saxon-6.5.5.jar +xercesImpl.jar=/usr/share/java/xercesImpl.jar +xml-apis.jar=/usr/share/java/xml-apis.jar + +# For non-ns version only, this validates the document +# against a dtd. +validate-against-dtd=true + +# The extension for files to be indexed (html/htm/xhtml etc.) +html.extension=html + +# Set this to false if you don't need a search tab. +webhelp.include.search.tab=true + +# indexer-language is used to tell the search indexer which language +# the docbook is written. This will be used to identify the correct +# stemmer, and punctuations that differs from language to language. +# see the documentation for details. en=English, fr=French, de=German, +# zh=Chinese, ja=Japanese etc. +webhelp.indexer.language=en + +# Enables/Disables stemming +# Stemming allows better querying for the search +enable.stemming=true + +# Set admon.graphics to 1 to user graphics for note, tip, etc. +admon.graphics=0 +suppress.footer.navigation=0 + + + Test the package by running the command ant + webhelp -Doutput-dir=test-ouput at the command + line in the webhelp directory. It should generate a copy + of this documentation in the doc directory. Type start + test-output\index.html to open the output in a + browser. Once you have confirmed that the process worked, + you can delete the test-output directory. + + + To process your own document, simply refer to this package from another + build.xml in arbitrary location on your system: + + + Create a new build.xml file that defines the name of your + source file, the desired output directory, and imports the + build.xml from this package. For example: + <project> + <property name="input-xml" value="path-to/yourfile.xml"/> + <property name="input-images-dirs" value="images/** figures/** graphics/**"/> + <property name="output-dir" value="path-to/desired-output-dir"/> + <import file="path-to/docbook-webhelp/build.xml"/> +</project> + + + From the directory containing your newly created build.xml + file, type ant webhelp to build your document. + + + + +
        +
        + Using and customizing the output + To deep link to a topic inside the help set, simply link directly to the page. This help + system uses no frameset, so nothing further is necessary. + See Chunking into + multiple HTML files in Bob Stayton's DocBook XSL: The Complete + Guide for information on controlling output file names and which files are + chunked in DocBook. + + When you perform a search, the results can include brief summaries. These are populated + in one of two ways: + + By adding role="summary" to a para or + phrase in the chapter or + section. + + + By adding an abstract to the chapterinfo or + sectioninfo element. + + + To customize the look and feel of the help, study the following css files: + + docs/common/css/positioning.css: This handles the Positioning + of DIVs in appropriate positions. For example, it causes the + leftnavigation div to appear on the left, the header on top, and so on. + Use this if you need to change the relative positions or need to change the + width/height etc. + + + docs/common/jquery/theme-redmond/jquery-ui-1.8.2.custom.css: + This is the theming part which adds colors and stuff. This is a default theme comes + with jqueryui unchanged. You can get + any theme based your interest from this. (Themes are on right navigation bar.) Then + replace the css theme folder (theme-redmond) with it, and change the xsl to point to + the new css. + + + docs/common/jquery/treeview/jquery.treeview.css: This styles + the toc Tree. Generally, you don't have to edit this file. + + +
        + Recommended Apache configurations + If you are serving a long document from an Apache web + server, we recommend you make the following additions or + changes to your httpd.conf or + .htaccess file. AddDefaultCharSet UTF-8 # + + # 480 weeks + <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> # + Header set Cache-Control "max-age=290304000, public" + </FilesMatch> + + # 2 DAYS + <FilesMatch "\.(xml|txt)$"> + Header set Cache-Control "max-age=172800, public, must-revalidate" + </FilesMatch> + + # 2 HOURS + <FilesMatch "\.(html|htm)$"> + Header set Cache-Control "max-age=7200, must-revalidate" + </FilesMatch> + + # compress text, html, javascript, css, xml: + AddOutputFilterByType DEFLATE text/plain # + AddOutputFilterByType DEFLATE text/html + AddOutputFilterByType DEFLATE text/xml + AddOutputFilterByType DEFLATE text/css + AddOutputFilterByType DEFLATE application/xml + AddOutputFilterByType DEFLATE application/xhtml+xml + AddOutputFilterByType DEFLATE application/rss+xml + AddOutputFilterByType DEFLATE application/javascript + AddOutputFilterByType DEFLATE application/x-javascript + + # Or, compress certain file types by extension: + <Files *.html> + SetOutputFilter DEFLATE + </Files> + + + See Odd characters in HTML output in Bob + Stayton's book DocBook XSL: The Complete + Guide for more information about this + setting. + + + These lines and those that follow cause the + browser to cache various resources such as bitmaps and + JavaScript files. Note that caching JavaScript files + could cause your users to have stale search indexes if + you update your document since the search index is + stored in JavaScript files. + + + These lines cause the the server to compress html, + css, and JavaScript files and the brower to uncompress + them to improve download performance. + + +
        +
        +
        + Search indexing + Run ant index in the webhelp directory to index the content. Running + ant webhelp will do the indexing as part of the process as well. + Here's some detailed information about invoking the indexer. The indexing process is + pretty smooth, so probably you doesn't need to be concerned with following details. Webhelp + Ant script does all the needed bits. + + + Following should be in the CLASSPATH. + + + + webhelpindexer.jar, + lucene-analyzers-3.0.0.jar, + lucene-core-3.0.0.jar - These three are available in the + extensions/ directory of docsbook-xsl-1.76.1, and is automatically fetched to the + webhelp's Ant script. Go for a XSL snapshot if you can which contains the latest + version http://docbook.sourceforge.net/snapshot/ + + + xercesImpl.jar, xml-apis.jar - + These two comes by default with Ant 1.8.0 or prior versions. These are available + under /usr/share/java directory of Linux distributions as well. Else, you may have + to download, and put them to jre/lib/endorsed. + + + + + + The main class is com.nexwave.nquindexer.IndexerMain for the + version 1.76.1+. It's com.nexwave.nquindexer.IndexerTask for the + versions 1.76.0 and 1.76.1. + + + + Needs two parameters as command-line arguments: + + + + The folder where the files to be indexed reside + + + + + (Optional) language. defaults to "en". See build.properties for + details + + + + + + + We have changed the way we invoke the webhelp indexer from the Ant Task to + indexertask to direct invocation. This seems to have remove the + CLASSPATH issue some people were having. + + + + + + search + indexing + + + indexer + CLASSPATH + + To build the indexer, you must have installed the JDK version 1.5 or + higher and set the ANT_HOME environment variable. + + ANT_HOME + + + indexer + building + +
        +
        + Adding support for other (non-CJKV) languages + To support stemming for a language, the search mechanism requires a stemmer implemented + in both Java and JavaScript. The Java version is used by the indexer and the JavaScript + verison is used to stem the user's input on the search form. Currently the search mechanism + supports stemming for English and German. In addition, Java stemmers are included for the + following languages. Therefore, to support these languages, you only need to implement the + stemmer in JavaScript and add it to the template. If you do undertake this task, please + consider contributing the JavaScript version back to this project and to Martin Porter's + project. + + Danish + + + Dutch + + + Finnish + + + Hungarian + + + Italian + + + Norwegian + + + Portuguese + + + Romanian + + + Russian + + + Spanish + + + Swedish + + + Turkish + + + stemming + +
        +
        + Adding images + This section shows how to add images to WebHelp. For that, follow the simple procedure given. + + Put the images in a subdirectory of your source file directory. For example + docsrc/images. + + + Then refer to those images from your docbook document. + Following image is from webhelp/docsrs/images/sample.jpg. The docbook code is shown + below. + +
        + Sample Image + + + + + +
        +
        + + Example code for adding images. Note down the relative path used + <figure> + <title>Sample</title> + <mediaobject> + <imageobject> + <imagedata fileref="images/sample.jpg" format="JPG"/> + </imageobject> + </mediaobject> +</figure> + +
        + + The build.properties file controls what directories are copied + over from the source tree to the output + tree:# If your document has image directories that need to be copied +# to the output directory, you can list patterns here. +# See the Ant documentation for fileset for documentation +# on patterns. +input-images-dirs=images/**,figures/**,graphics/** + +
        +
        +
        + + Developer Docs + This chapter provides an overview of how webhelp is implemented. + The table of contents and search panes are implemented as divs and rendered as if they + were the left pane in a frameset. As a result, the page must save the state of the table of + contents and the search in cookies when you navigate away from a page. When you load a new + page, the page reads these cookies and restores the state of the table of contents tree and + search. The result is that the help system behaves exactly as if it were a frameset. +
        + Design + An overview of webhelp page structure. + DocBook WebHelp page structure is fully built on css-based design abandoning frameset + structure. Overall page structure can be divided in to three main sections + + Header: Header is a separate Div which include company logo, navigation + button(prev, next etc.), page title and heading of parent topic. + + + Content: This includes the content of the documentation. The processing of this + part is done by DocBook + XSL Chunking customization. Few further css-styling applied from + positioning.css. + + + Left Navigation: This includes the table of contents and search tab. This is + customized using jquery-ui styling. + + + Tabbed Navigation: The navigation pane is organized in to two tabs. Contents + tab, and Search tab. Tabbed output is achieved using JQuery Tabs plugin. + + + Table of Contents (TOC) tree: When building the chunked html from the docbook + file, Table of Contents is generated as an Unordered List (a list made from + <ul> <li> tags). When page loads in the browser, we apply + styling to it to achieve the nice look that you see. Styling for TOC tree is done + by a JQuery UI plugin called + TreeView. We can generate the tree easily by following javascript code: + +//Generate the tree +$("#tree").treeview({ +collapsed: true, +animated: "medium", +control: "#sidetreecontrol", +persist: "cookie" +}); + + + + + Search Tab: This includes the search feature. + + + + + + design + +
        +
        + Search + Overview design of Search mechanism. + The serching is a fully client-side implementation of querying texts for content + searching. There's no server involved. So, the search queries by the users are processed by + JavaScript inside the browser, and displays the matching results by comparing the query with + a simplified 'index' that too resides in JavaScript. Mainly the search mechanism has two + parts. + + Indexing: First we need to traverse the content in + the docs folder and index the words in it. This is done + by webhelpindexer.jar in + xsl/extentions/ folder. You can + invoke it by ant index command from the + root of webhelp of directory. The source of + webhelpindexer is now moved to it's own location at + trunk/xsl-webhelpindexer/. + Checkout the Docbook trunk svn directory to get this + source. Then, do your changes and recompile it by simply + running ant command. My assumption is that + it can be opened by Netbeans IDE by one click. Or if you + are using IntelliJ Idea, you can simply create a new + project from existing sources. Indexer has extensive + support for features such as word scoring, stemming of + words, and support for languages English, German, + French. For CJK (Chinese, Japanese, Korean) languages, + it uses bi-gram tokenizing to break up the words (since + CJK languages does not have spaces between + words). + When ant index is run, it generates five output files: + + htmlFileList.js - This contains an array named + fl which stores details all the files indexed by the indexer. + Further, the doStem in it defines whether stemming should be used. It defaults + to false. + + + htmlFileInfoList.js - + This includes some meta data about the indexed + files in an array named fil. It + includes details about file name, file (html) + title, a summary of the content. Format would look + like, fil["4"]= "ch03.html@@@Developer + Docs@@@This chapter provides an overview of how + webhelp is implemented."; + + + + index-*.js (Three index files) - These three files + actually stores the index of the content. Index is added to an array named + w. + + + + + Querying: Query processing happens totally in client side. Following JavaScript + files handles them. + + nwSearchFnt.js - This handles the user query and + returns the search results. It does query word tokenizing, drop unnecessary + punctuations and common words, do stemming if docbook language supports it, + etc. + + + {$indexer-language-code}_stemmer.js - This includes the + stemming library. nwSearchFnt.js file calls + stemmer method in this file for stemming. ex: var stem = + stemmer(foobar); + + + + + + + + search + +
        + New Stemmers + Adding new Stemmers is very simple. + Currently, only English, French, and German stemmers are integrated in to WebHelp. But + the code is extensible such that you can add new stemmers easily by few steps. + What you need: + + You'll need two versions of the stemmer; One written in JavaScript, and another + in Java. But fortunately, Snowball contains Java stemmers for number of popular + languages, and are already included with the package. You can see the full list in + Adding support for other (non-CJKV) languages. + If your language is listed there, Then you have to find javascript version of the + stemmer. Generally, new stemmers are getting added in to Snowball Stemmers in + other languages location. If javascript stemmer for your language is + available, then download it. Else, you can write a new stemmer in JavaScript using + SnowBall algorithm fairly easily. Algorithms are at Snowball. + + + Then, name the JS stemmer exactly like this: + {$language-code}_stemmer.js. + For example, for Italian(it), name it as, + it_stemmer.js. Then, copy it to + the + docbook-webhelp/template/search/stemmers/ + folder. (I assumed + docbook-webhelp is the root + folder for webhelp.) + Make sure you changed the + webhelp.indexer.language property + in build.properties to your + language. + + + + + Now two easy changes needed for the indexer. + + + Open + docbook-webhelp/indexer/src/com/nexwave/nquindexer/IndexerTask.java + in a text editor and add your language code to the + supportedLanguages String Array. + + Add new language to supportedLanguages array + change the Array from, + +private String[] supportedLanguages= {"en", "de", "fr", "cn", "ja", "ko"}; + //currently extended support available for + // English, German, French and CJK (Chinese, Japanese, Korean) languages only. + + To, + +private String[] supportedLanguages= {"en", "de", "fr", "cn", "ja", "ko", "it"}; + //currently extended support available for + // English, German, French, CJK (Chinese, Japanese, Korean), and Italian languages only. + + + + + Now, open + docbook-webhelp/indexer/src/com/nexwave/nquindexer/SaxHTMLIndex.java + and add the following line to the code where it initializes the Stemmer (Search + for SnowballStemmer stemmer;). Then add code to initialize the + stemmer Object in your language. It's self understandable. See the example. The + class names are at: + docbook-webhelp/indexer/src/com/nexwave/stemmer/snowball/ext/. + + Initialize correct stemmer based on the + <code>webhelp.indexer.language</code> specified + + SnowballStemmer stemmer; + if(indexerLanguage.equalsIgnoreCase("en")){ + stemmer = new EnglishStemmer(); + } else if (indexerLanguage.equalsIgnoreCase("de")){ + stemmer= new GermanStemmer(); + } else if (indexerLanguage.equalsIgnoreCase("fr")){ + stemmer= new FrenchStemmer(); + } +else if (indexerLanguage.equalsIgnoreCase("it")){ //If language code is "it" (Italian) + stemmer= new italianStemmer(); //Initialize the stemmer to italianStemmer object. + } + else { + stemmer = null; + } + + + + + + + + That's all. Now run ant build-indexer to compile and build the java code. + Then, run ant webhelp to generate the output from your docbook file. For any + questions, contact us or email to the docbook mailing list + docbook-apps@lists.oasis-open.org. + + stemmer + +
        +
        +
        + + + + Frequently Asked Questions + + + FAQ + + + + On what browsers and operating systems WebHelp has tested extensively? + + + We tested it with versions of most browsers including Firefox 3.x+, IE 7+, Chrome, + Safari, and iPod/iPhone. The JavaScript codes are mostly jquery plugins, so you’d want + to check the jquery support matrix for details. + + + + + Apart from this demo, where can I find other demos or production deployments of + WebHelp? + + + There are four production deployments provided in WebHelp wiki currently. + + + + + When building the webhelp output, I'm getting the following error. What's the reason + for this? + [xslt] : Warning! file:/C:/Users/kasun/docbook-xsl-1.77.0/xhtml/autoidx.xsl: + line 596: Attribute 'href' outside of element. +[xslt] : Warning! file:/C:/Users/kasun/docbook-xsl-1.77.0/xhtml/autoidx.xsl: + line 596: Attribute 'href' outside of element. + ---- + + + This happens if you haven't done the step 3 and 4 of webhelp build guide "Generating + webhelp output" in the documentation. Basically, you need to correctly set the following + folder + paths.xslt-processor-classpath=/usr/share/java/saxon-6.5.5.jar +xercesImpl.jar=/usr/share/java/xercesImpl.jar +xml-apis.jar=/usr/share/java/xml-apis.jar + + + + + Does WebHelp Indexer can index HTML transformation as well? + + + Yes, WebHelp supports HTML transformations as well in addition to XHTML. + + + + + I need more information about webhelp-indexer. Where can I find it? + + + The DocBook Webhelp Indexer is based on the HTMLSearch plugin for DITA. See HTMLSearch documentation for more information. + + + + + FAQ + + + + +
        diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/xinclude-test.xml b/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/xinclude-test.xml new file mode 100644 index 000000000000..77ef4f88ee5e --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/docsrc/xinclude-test.xml @@ -0,0 +1,13 @@ + + + Test section +
        + Some search words for testing + arsenal, arsenic, buy, say, by, vary, try, sky, nucleus, day, key, currency, currencies, build.xml +
        +
        + Some search words for testing (inflected) + arsenal, arsenic, buys, says, varies, tries, skies, nuclei, days, keys, currencies, build.xml +
        +
        \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/browserDetect.js b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/browserDetect.js new file mode 100644 index 000000000000..c6a2c73a0da9 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/browserDetect.js @@ -0,0 +1,116 @@ +var BrowserDetect = { + init: function () { + this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; + this.version = this.searchVersion(navigator.userAgent) + || this.searchVersion(navigator.appVersion) + || "an unknown version"; + this.OS = this.searchString(this.dataOS) || "an unknown OS"; + }, + searchString: function (data) { + for (var i=0;ip{ font-weight: bold; } + +p.breadcrumbs { + display: inline; + margin-bottom: 0px; + margin-top: 33px; +} + +p.breadcrumbs a { + padding-right: 12px; + margin-right: 5px; + text-decoration: none; + color: #575757; + text-transform: uppercase; + font-size: 10px; +} + +p.breadcrumbs a:first-child {background: url(../images/breadcrumb-arrow-white.png) no-repeat right center;} + +p.breadcrumbs a:hover {text-decoration: underline;} + +#star ul.star { + LIST-STYLE: none; + MARGIN: 0; + PADDING: 0; + WIDTH: 85px; + /* was 100 */ + HEIGHT: 20px; + LEFT: 1px; + TOP: -5px; + POSITION: relative; + FLOAT: right; + BACKGROUND: url('../images/starsSmall.png') repeat-x 0 -25px; +} +#star li { + PADDING: 0; + MARGIN: 0; + FLOAT: right; + DISPLAY: block; + WIDTH: 85px; + /* was 100 */ + HEIGHT: 20px; + TEXT-DECORATION: none; + text-indent: -9000px; + Z-INDEX: 20; + POSITION: absolute; + PADDING: 0; +} +#star li.curr { + BACKGROUND: url('../images/starsSmall.png') left 25px; + FONT-SIZE: 1px; +} + +table.navLinks {margin-right: 20px;} + +table.navLinks td a { + text-decoration: none; + text-transform: uppercase; + color: black; + font-size: 11px; +} + +a.navLinkPrevious { + padding-left: 12px; + background: url(../images/previous-arrow.png) no-repeat left center; +} + +a.navLinkNext { + padding-right: 12px; + background: url(../images/next-arrow.png) no-repeat right center; +} + +a#showHideButton { + padding-left: 20px; + background: url(../images/sidebar.png) no-repeat left center; +} + + +.filetree li span a { color: #777; } + +#treediv { -webkit-box-shadow: #CCC 0px 1px 2px 0px inset; } + +.legal, .legal *{ + color: #555; + text-align: center; + padding-bottom: 10px; +} + +.internal { color : #0000CC;} + +.writeronly {color : red;} + +.remark, .remark .added, .remark .changed, .remark .deleted{ background: yellow;} + +tr th, tr th .internal, tr th .added, tr th .changed { + background: #00589E; + color: white; + font-weight: bold; + text-align: left; +} + +.statustext{ + position:fixed; + top:105px; + width: 0%; + height: 0%; + opacity: .3; + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -o-transform: rotate(90deg); + white-space: nowrap; + color: red; + font-weight: bold; + font-size: 2em; + margin-top: 30px; +} + +#toolbar { + width: 100%; + height: 33px; + position: fixed; + top: 93px; + z-index: 99; + left: 280px; + color: #333; + line-height: 28px; + padding-left: 10px; +} + +#toolbar-left { + position: relative; + left: 0px; +} + +body p.breadcrumbs { + margin: 0px; + padding: 0px; + line-height: 28px; +} + +/*body #content { + position: static; + margin-top: 126px; + top: 0px; +}*/ + +body.sidebar #toolbar{left: 0px;} + +body.sidebar #toolbar-left{left: 0px;} + +div#toolbar-left img {vertical-align: text-top;} + +div.note *, div.caution *, div.important *, div.tip *, div.warning * { + background: inherit !important; + color: inherit !important; + border: inherit !important; +} + +#content table thead, #content table th{ + background: gray; + color: white; + font-weight: bold; +} + +#content table caption{font-weight: bold;} + +#content table td, #content table {border: 1px solid black;} + +#content table td, #content table th { padding: 5px;} + +#content table {margin-bottom: 20px;} + +*[align = 'center']{ text-align: center;} + +#content .qandaset>table, #content .qandaset>table td, #content .calloutlist table, #content .calloutlist table td, #content .navfooter table, #content .navfooter table td { + border: 0px solid; +} + +#sidebar { display: none } + +@media print { + + body * { + visibility: hidden; + } + + #content, #content * { + visibility: visible; + } + + #sidebar, .navfooter { + display: none; + } + + #content { + margin: 0 0 0 0; + } + +} + diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/caution.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/caution.png new file mode 100644 index 0000000000000000000000000000000000000000..5b7809ca4a9c8d778087522e5ce04b6e90099595 GIT binary patch literal 1250 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbQ|Pftew|C&U%V<=|it5MYpyU{F+K zFf?Rva$<;zVn|MA$j)XcE@r5%W@u>vqT-$&hMpcE*)wGd!;~q-Q>IkUnZqz=PVt;M zK*p3gbLK2v%CK~4^3tV1#?q}@8MbbX+PXD)>(;G%_cH9=n|$sZ!?|yxmE{-7;w@N47?rU=3X_NkV zU|o{PnRTZ;lXp4>+)hZU_|Lw%*va*6=<@jI@BP^`_OsZ?pZg-2AaGf|;i2L0<>du@ zeRrO4er03}pLSxdREd>pap^;~&E+}=JYKy#vHnLI=Z$}pPyA_`zG;G~<$`Br2do;7 z$Heivv0AeyJYVI({@6?X6r+V~XS2Cs!|bddDqJz@2lKf$~4dA1c%lfOT+5KMUSWi#X5(9ePxx_W1Bsf2+N)z4*}Q$iB}K{RAP literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/important.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/important.png new file mode 100644 index 0000000000000000000000000000000000000000..12c90f607a1b27ddde0a7d922ae255e8c90e883e GIT binary patch literal 722 zcmV;@0xkWCP)Gdz_qOoSb{LwMwNgp7=gl$4aErG%}mjHRWNrKOy`y@b8JoTa6ut*xc4t*y1SwY|N)#>U3Z&d%1> z*52OU=jZ3|@9+2b_y7O@tTMkk%M`~Kg@u8&dg_P^_0l3yQb639!jLZt^Lx<-O17UeeJ z-|=!77W(jGx&e#?FOku-gKofoU0$~4M+dhLFueEauP`}l7LV=;lsOdn%WHure=x;k`m0(bF&MU#) z-qv#^n8(MjB|ykioqII#+`g4no-MU=BK|Sahu_3M_-d*=7hq=~t?^}A)G7 zbairN0An*{V`DL9V>K}|HDobmIW;*pIW=W9HaTQ6F*7kTGI9=S@Bjb+07*qoM6N<$ Ef=i}M4FCWD literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/note.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/note.png new file mode 100644 index 0000000000000000000000000000000000000000..d0c3c645ab9af6318035b026dd86944b9ddc9114 GIT binary patch literal 490 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY0Bp8m$B&h%?rX+877Y2q^y~;)m42&$EE{-7; zw^Ao5PC9JB<666~wbh%Oo7tJ0_rGWfi({a(qjR96>_P4H$tJl=Pxd^1p6`8M?=jE( z!hchf6<8Mi`NHe6`iia69>!lxe4C2-S>+Wvj;l63k!MNSb9|1+f-i>irDi|a^uLl% z^#-f2#pQ2lC%m~9m9JWJZL3|T8FRX>A78<>cU{Z6XGFG336=OLGkw25|29|RG_k%U z>j|M}Ih2i#-w+9_ll{>(OzfJ4N{OX={Q&zNgO}j31DC;|ya^r9Fjd348&p+!^cT+^sws+=& zCu*T*mRNK3PE;$BNx$Fa_9(Y=&DoXLMFRd#U31O)<`W^F&-o=xbIqK-c?mr!bmn>! zky6TW;ML~4nXw$T{yra=OteL6G!=B;0=?;6;u=vBoS#-wo>-L1;Gm(b>6x3Dp6Z*J zo|&AjV4`QFXQ5zesc&GRZ(yj9T$EW{Qt6OeSzMBtte0A>mr`1gpI4%noS!>!m*Ngk zP=bxiOwUU!DFvFBnrfM1VQy}0X_lO7WM-b2nq**TZkb|inr2~`WR#dJWc*7VsEZGz hD*$LMgOO>4k%_i}w!yxSoa=!y44$rjF6*2UngF(YpwIvS literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/warning.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/admon/warning.png new file mode 100644 index 0000000000000000000000000000000000000000..1c33db8f34a8b42b373179b46a2d8d8a10e061a9 GIT binary patch literal 1241 zcmeHH+e?!H6#vDtmgHCxG{Q}12(7`~)|MMe^RnTlY0JD#q1sIwW1DTCqzzwWg@Q=t zBC2Iceu@w4LHM97Gb5%*E%9MN*%m}jvs!{N@Pd8$H}vS?TsRzlzr#5kPPe|YG%fXL zDu6VdR$WC$&Oc)^X#ZjK-7LU>{!F!o39xr+d_Vw5fMTEwpb-s#9q<5Nzz6gIepyU?Lctpr{ZK zVzWaWPAC)#17S8h%;AIuf(Q_yeIybEqS0s^i1YdJcsv0ln9M{Xkpz;-I_^=P))~D~!!Hvpq{Dl8O{rN@cECkt>#DncX%I(O&3i_YgL-$m$VU zT3cLBLS%M1`o{TBX}S|Tbhc)vk!Yp)%rdDd&my(RPsxl%lU$)tC?(1~WuEwClUQn! n$Q8O{Mxt@ukkcT{K0> literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/1.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/1.png new file mode 100755 index 0000000000000000000000000000000000000000..de682c628feee885b97fd19e77b016518d833711 GIT binary patch literal 396 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=92~rKK68R45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWk%<(RmX6r@{8<}R!o-G--zwYdTlP5b5@8;1{=w*AcsQTNRLe=)iUl{`QE`z75pUXO@geCx4;f9R> literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/10.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/10.png new file mode 100755 index 0000000000000000000000000000000000000000..96c6ce45275c754c86964f523e57bb2ca5507877 GIT binary patch literal 524 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$N%nMc45_%)J87f$VF!_8`x4j_g4RWzt>|@iO6xonCpLUuhigLc3Jb+U%Op*^%iLyO4_(X;pN6- z=a#Hm^`=rTB~q_P5)HwY|d8XT*w^=@u zSiV--p1!#&MsKHy@TcQO>_47BbD2s2LA=92~rKJj#M45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWC>mIVh^7_bp?vVw0Ac8FkGr=O>_47BbD2s2LA=930$iScxC45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWu;5ShzZF-HKw%&(Ci= zKi__F#+A#LnX{Q1Wv$B$B&4JcEs1e3ld7n!Y^>a~XOD#~N71)ON4pbaWYyS|806*U zoij5voeK*MV|bQ)WU}+UbmrcJAECGvBVZi8DU2$xScp!J|iq49efdw9T3& z6_BCi{Wh_2S%*lDpnd(nngWmgRbRREj-5Ec;l&{=c~OYLP(f@;Re~n_6uEq+jm!eY z4?T-!I_%-FU3*BV(lAJgz49qrkWxKEFbBgty{H#GlO<(=fzROS>gTe~DWM4fIlZ{! literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/13.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/13.png new file mode 100755 index 0000000000000000000000000000000000000000..b4878f1a451337e8e34562ba148f4b8669dbbafc GIT binary patch literal 520 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$iT8AI45_%)J87f$;Q)bS`?pED9L)6<@taey*G&cvlxG%uf$~RZ!px!#yrs(!{N|KWn3Uov-5ZqPv zLGQ`bEpBhw_dhHwe}C`pZ?79y1Pi_A2up2ruQ;N8QQgipNi)2})8dF>*H_m&0{%5C zo^;LYWd5V~uFmmHXTR6CJ>sr`PZT&FSe&y8zHH*7Cd|XeyybRo#k_WnEVZdxqa~r7vo!eLJ*%Rovco*|#lmM%k0+X>Kp3Z{yj} zom19d!1vow!LQ@5y-vBWOO>_47BbD2s2LA=930$G4ynC45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWBqMPL8CfP}<}4avv(*kWU2Q#57OY#I+56h3lkd-N!&t^WVN#45%PeTI#kX1)LZ z{Y&6s{{R1fdO`}z@du(}8Bda~a)h?5<7D|};23;_o9z*!hN4f3i#NlOhKPVyjZ0+$ zs`hXm;d40CdVHCWLR`zdu*A+i5}Fg64?SQDQmSVN=3p>A>#6*xIoSgkq70s{elF{r G5}E)R1*_Zu literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/15.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/15.png new file mode 100755 index 0000000000000000000000000000000000000000..f6a76d51667ed2ea608facddd705cb079d9150e0 GIT binary patch literal 522 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$N%VAa45_%)JIT=daDc$^|DBCd8xsyR zsGbb6N-H?~OhI+a?8&k|8apgJ*x8rYFtG>AaLKxI#O^8)d?mF@lv8$#g2j>)(NC;< z#D9AQCA~b@|NY(F*mqCw#XH>V>(omWWZUR}rZaqzyNgZW36WT#{v(`SZ`*gM#?9C~ zUGr0?^Pl`Rzga)Jwp@Bu#ox6k!ECnU^{=JNbWTU;P1l%y`n9p6z`Tsg-OYLxSf&G|7V^1m;Mc0w&Kr6dteMOc)I$z JtaD0e0ssM<)1m+X literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/16.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/16.png new file mode 100755 index 0000000000000000000000000000000000000000..c5ef6359aff17dae242a9f9b5b07d37492c5e2d5 GIT binary patch literal 539 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$De`o245_%)JIOx#P=LtM{*BGkqO3z+ zOz0O-$=()Z)u9(O-ASYA#RbKZ7XdCut~zpb&9>MgVwGB;JwyM2zyzg*l3KD>B|27I z3%|3;`?@S;uY0)nPWiq2!paXWHgYr-cnqizE%Fd8zieDgW5l ze=>zBG}QIwrv|$$yZQW8D?_xBQk;!u9!W4bkhS$tfkn$>ittqpVD zf1h7XAn9?*^ohRPa@ljQmoC)k(m1>1>*KtssgV~-Z8Oq0M{e|;rn^@7O>_47BbD2s2LA=930$G4gbA45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gW?*}&7>JKP8>LQjxULeq0mxTLm?|WTXN6dy^?nI|9YG?f)^5jUtj}M6@4{d!ehO>_47BbD2s2LA=930$DfM)545_%)JIOx#P=LtM{`$6{S(g?% zwR`Myn9#*2I6cTZBz8;iw47M0DSWb4PmNg$3#LpnRlq>o})cD8xLPn<2RG#*B^`C5M#GZHV1}#5QrW zt5#B#YTt(FHNSa3`dX|k*t6Y7t@ur)oX+W}_d3&0OYpE|Y`>jhHoHKEec$`|pqG|s z&xL4Bed4#AIdWRE?ytXgCccMDtXdaoNbt3vNZYI)QsuR&+rU@&Yn5#GQKhsw=bv*l zHPo*U)7F{p9k?q=_I&nMsd௱J?yghEpb|-VpoRA}>5tWxeXQuIvD5d;Gpf0>c9xIYoipjdSHJpu$iFlY+O>_47BbD2s2LA=930$De`o245_%)JIOHPkb^|){7z@httA~7 z6gN8yth{mbWRR7}+&2oYE4pJBP2rQZvb17XH&@*nAiFEPpqy9H*+|6d%F&}u-gkce zf8?pO^2abg($Weo=AX(PI$`CEgN8G#7n!wh>srX9Dv= z^G6)@-TwO(?Kq?F#k{wj=_6M?kNvR0HfvMg!xc7eOM@C0X%xhY?|UCVDfL+8vKqVf zWxHcntdg=?bpQS0n>k5VbCo8aTyQsU@x_ce6Ta$vblwuBJH<;?XZq;?gV|@-IqTfs z7PvO7we;x0%}EAV?|Z#xu(oO>_47BbD2s2LA=930$G4gbA45_%)I?2$xH9+QQ|1|-{i2^qS z{QMqWc&5@~vSqi)jg)R@l`jf{`jM4 z@AGdp@pTq)^|)MeD(~sXLh~mUe4BI*Cv7}nz!Q9M``wL#*B>3;y!v{n?7Zh|)m1%( zx;M004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#0004_ zNkl3-r5QX2JA`%WOg@};C`jCi~jij)ModkqKNNHgqLBt~eKv9U2T9g=b zod`A->8!-&I4lepOcCT7AzE5UW)@CPNkRrbc9xmhncaO7j?GWp5!ZxDc!?P?BAUdf zohUhqG~$6c$Itdf6o_ZuxEw_~q2PDp?l;6cVY+#|L?Y2_G#XG<74!KVxm*sD$po=j z482|t;cytHX`)yxVmux{Qq3!OydMsSDNfGk^H?sIs8lLwwOXjx>u9&z$Ye62WjdY4 zU@+j$ZkZn<5{Y0sor>USG(t2Q6@Ds}5*^t(oeq-8q&;?$3oo4)iO1vUcDuq?6b1YJ zUiiD+4uL?xPE%!Pk$C4yT ze21><;yV_L1vE{AVHhlgsB|KL|JW_7$L_*O>_47BbD2s2LA=930$iScxC45_%)J87fW;Q*1g|4U?Dd_qr__Nog*S`iY2k5iL=zix>?%}Kg^qDT9ql*xg$<*x~|zy6W{WDR>vFSEu8_J2kJ|XUJ6!g ze`=_BuH*2m6L$spudbPO>_47BbD2s2LA=930$@$+0wo zD*JBcv>EUS9ygRKd3Wda2c@>dieam-=FL;_T=4qWyWPIaH{GaEvTHdWtvB6XF5>dm zzKR>~zZ=fzopr06Xx?WB>pF literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/23.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/23.png new file mode 100755 index 0000000000000000000000000000000000000000..3909b9cd8fd0720f5672bbdaa4ae37ba82c4b72a GIT binary patch literal 589 zcmV-T0004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#0004` zNkl@;rh&}uquSANt<%`2sbVuys_h9v7;)!@rdAvv@QY;h-&@>IEX(AqvV>ld& zd!x~S-|vTE7)Yg3==b~ARMTa}i*~zx#L0<70^{)*xm*s_Y892&PDh+wE*F-|r5roTqwd>3gp;|m3{_RJSS&D~ z&xP`PXgumA!OCztoyh0&NG6k5uh$}Dv)Le<&5DUCl?uw`vUtt~_k8ery`qR0uv)FY zt#mLLz~}SHtHFhOG#VAlNT<`7OeP=6ykXufM>rftuh)~Wx@-XVbUJA>#!_KDAsB<%w{t-LO}Uqfd9lPyGN?9A0LSWV&@ObC5W4^UX><4x0#%OmuWM( bB@^EOG7*lLyH^aK00000NkvXXu0mjfdrk4= literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/24.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/24.png new file mode 100755 index 0000000000000000000000000000000000000000..963a9e770cca4a2c7c7d0628a131848672c9bc83 GIT binary patch literal 542 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$DfM)545_%)JIT=hP=LVk^%oAVP~8MvZ@g~%#R=Z-}gYXd}BmtEHUQf2FPej@wC zcP0`%ebH;heAI+5nDEA2Z;e`e%w>_rp#lpQ&qN`py_WozqO0O(Ne_%0(Y9 z++(O&#b@<6b7KU{@xleS->zfd9JSVrm8trmW$pWr(7n0aZzo8w=}bSpHs8^;&P7De z_v+```+6c=H;*PwT({>m$Gizf2kH+gd{;TAXunS}{lq`{xq5>3Z?7JCqLyB?>y&o- dr~Z`3=0&eE`Pvp`?*_&SgQu&X%Q~loCIDgE)%5@X literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/25.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/25.png new file mode 100755 index 0000000000000000000000000000000000000000..458a91990be481a831161da501d993f1fb4fb9ac GIT binary patch literal 564 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$>GpJS45_%)J86IRAqSD;`#Tx4HG>?z zj{3?pn^^4hXjhnNU8Nr? z=UeBJ?Y;klV)@Q$`*$BhH>|Y?RMl}(=j*V1DByc&y7*Lw3#x_gbCUMkam=oG;;SL> z#YN^}dEr;?M^g(-^YrJRH<#{ZD~WA?Ub!MfYlh$Qj-yEtdeb{xl` z+{xPWSpOF+ja#pNZPh9z8NO~l6JO`uciUd?s#)?m#GccyA;Y9AZ+myr#*VXTn?sc* zdL&rLbXj&RIby6o>7>f5uU0v?{|O$6T7TVR`Q;+(=MKkBd`qlkuVk4Tx~@E$)EJ`0 zIeg3KG*D!B_%t{6OB{an^LB{Ts5T43Ks literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/26.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/26.png new file mode 100755 index 0000000000000000000000000000000000000000..74b2507390edc1d45140ac991b9e73a26657cbea GIT binary patch literal 596 zcmV-a0;~OrP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#00052 zNklNP|PIxdf6<4i1k7aR_vB5gbx<5JZFw znjFOC4euWi5h6rP2pgW#7_NeJ&dnDusp!BD&g0(i-tV6GN%&qq;+i-kWWqsA35}=| zhPhF)h%Sj+!jGTpoluE;{;*j@55x(6FTVYPcp;wbY%d;<*K4&JWLd_1K1Vj2#b`8w z!{IkZQAeB;ehPxLHs zI-O{@+t_Zm!o_4V;U)RVDss78C=?3F=kuS_Ae(NtTfDj1Y>ETSV&Nku2$-$yEy5m2KJ`<O>_47BbD2s2LA=930$sq%Dj45_%)J85I~AqSE6`il)qMV9l4 z9z1wb(L+`yW{F4JnYph50*)+nejy;E#n|50zxUoUKHxt{h#t zqq}y!>Ll*mm(Bd|^xmJ2)wAbJnk%%u#ZBXg;6^2zLu&U9yJ;%L3i2P3tXs$Lq#iR* zMfs9&VblHY^8G4tobk^dhprC2y-7!-t4V?5Lf&@6`R6y@f6rRH{kG$@r|wdIKURF- z_kQ-;Fz)W7OtY3Py#9J&&`OS=%{N`NrXDJ=c(QWpgKiD6?s%c;&nq>idNoZs|NLTx ziBqR{>PMSfN345~Cp*gUu)QeTeNk0aaPHE}nI%@T5^aSM+9F&ho)*nGn|A1QM9nit zv)Qiu@3*geeIsvsdt23BzU!rr&G#f-3=S1te34^WX42j`ZrQC-yq8~^==uF9ztQ*j zPO8z&Cuy54Z6+>xpEKojs?PM&6#_Y$Vh#VVm@ZfM;d}nEb%#RV|BgGn507k?YP-|X jGRI!Eqvelo&L5VVV;QTDz7*I7j2Z?{S3j3^P6004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#00050 zNkl3-r5QX1Gix7g9MMP_>Ln0O;f&{gQoumpvz{WyEQUr^DKR~chu@)hU z`2iMQVXvZMI4mwgFh!K>43;92nZ=WfBq0MI?B32}-pq}J?_nqIiEBb8PKha@5EbIX zNR&*XTcSi<;OF=xvP6?F7L(|iILGh7)o+M5LbbBJP$*O>m&=f48Jeacl}ceS7$6u7 zqFSwr@6+iNnM?+~Uav};E?0bPx7#sJPN&nD&*vx<3aHg;7>z~j|aoyQ25~luh%QitJMm--A_-hu`lPZ*2924^F2O#bOcJ zY!>VFT0C+KEaDiC$A=d9-?C7NMx$aF`FtLW#p2*#GMNam@V1}qKDxXB_T_S^I~)#+ z*|sD}aJ$`TwOT@~swxtR1ZJ}tFM?M(T7dt=9k*{(VGpmw6>;{*%B6{?<6SkD{K2&3 gJax^q004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#00050 zNklcV7wL%}Lx4=Y&EW5C)+W55&6} zC|Q!Oh7ZJzvj0dqUG8|-YPBvnIF(9aGMS)QETUX4qup*Jolc`rC}6c(A)C!| z0q$(K@gjUa9|nVgm`B%jsH!S_{`Pu3;g3cm#9}dX>O>_47BbD2s2LA=930$3G{Sv45_%)I%%VKOM=9)`Noz?N>Wl% zvt;_6qxv5!EK=NYb>Yzm2UHcMm~PAD?b2oX&*+-Tb!6qjr)-vU^j@$PXJuIBdCY0O z=Wk-?x{ke0!S4Ow%a5pDR4?lk{pe*Qct13;J$sjuTxar@*X=u0WA;rn zwG9{D8^_=G*kM|#&UEh;tGZM?wW3qcT0gDOKjQe5#gXB#!GcUFv)R1ME@u`7tSmkx zcFKD02V-6~<}=SfKf3w7w#QBRo}G%^kx%YhyaZTY?BYBBdDb=7Y@6KdS7o~+)?fFy zEYh{eR2u<_B>$VGB9|$`njxgN@xNAoG!y< literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/30.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/30.png new file mode 100755 index 0000000000000000000000000000000000000000..c4dc404bc1cfeadb3f6e80671196d292e8eda1ed GIT binary patch literal 597 zcmV-b0;>IqP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#00053 zNkl+FR z${bd!72EAr==FLHhr=NgHASk;W&@kehFC0yLZKkm6h+zTj=V(d5l_a=Uatq2%O&(| zHiOx07MjQ9aw(7LoY)+VM$j}(toZ$Y?wru=b{o-XRA?S~{uQFD&x66>qEe|?LZOiO zR_^d>wZeEjMlP2_Hk%a}r&1|QCKEQox#^n${u5{H9_bwR;|p;_SpKlwB~khARcZ2T jgUR`KjSMD#lLtQmtF?>&>wXE800000NkvXXu0mjfFy-;> literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/4.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/4.png new file mode 100755 index 0000000000000000000000000000000000000000..1e42fb376bf0da3014c1b71496a3027daf578487 GIT binary patch literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$VeoWu45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWk%^r=YnIgE*Vor4#xN?x z@fMyo<2RAke=SI$GU0f98M_# zi3LlSwkn#MPJMWGw)u@Eu?|wa8*Uyubm&mQ>ub7ff`WoMQl&ErZiWR09&F%mSoGLL zV73DHzyJT`gB6vF&KSlpew@{~gKhdr1?LMUjR#oNGP)`bI@mC%wsiJna5hK?aC_OF zF)(NT=&Ml1kfdj0mdf-|>B|-_?0!c)I$z JtaD0e0s!H`mGl4r literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/5.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/5.png new file mode 100755 index 0000000000000000000000000000000000000000..635e7f816277da13e909e96b832ac8bb5e7d50d5 GIT binary patch literal 490 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$arAU?45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWL$+hvz+Zh-b8y_w; zG&=OQgEcd)(Q3W)%?x&S_O{a3*9==)TN5`|8VS5lZ2INN7U>orKmXyQqumxUXA~HY zJXP3U!njdnQ_t+#(uXIj`%5fZyjZfSxmohueEahsetu3*QMFN!=DpC%!_S{?QTa*5 z+0&ELxxC!`@SUB-7pK11kWkz`YnIfU+UMtFH_X4tc;Xm056gk|@%t~dt}}2{7H7S) ztF+tE)s^*;nyhTwRPFFZ+BccG=A3qrVgF>{^X1CQU>@)3dZ{12e@{Q&N@ ze}AouoIH-qV&GsXU}{k14XE0~*;TFZ?9k*VMvWDMRZ*>~pOTii@Ns>W_UQb>=%dK+ Y`mKN0%RTQafg#M`>FVdQ&MBb@0Dv*H*8l(j literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/6.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/6.png new file mode 100755 index 0000000000000000000000000000000000000000..521aedde2c46c55421e87a355b77c7d77238a929 GIT binary patch literal 526 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$N%eGb45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWij&rZ~=9KvP@ikAGBI4}o%6fQ-=VXbhs;UV~)th5j zH*FN^sGX2%Wo<2~<}>5Khfhzv+m`#!H##%JkU3H+#h9DhL?NJI#R?5(YisMncXk#_ z?yLLDWybO%Bt=zEVY$?T>_4BM^EY>OaXA+i867?~Rr}yMS7s}p8%_S+-rb2`UtLZ3 zc5$)0i$MIZr^U^ zjoh9myJ=Et&xIE|dSpJz$jI&f73kPzVZvfVI+ z*{k2Y@djhZ&JQX(eH7wa=7lA8?vc=(*!<`xTaZ#cLof$}O?6yAW0@5rFcug*UHx3v IIVCg!0PJ|aQUCw| literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/7.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/7.png new file mode 100755 index 0000000000000000000000000000000000000000..0d4b876a8cc1905944042956cc2c8e47b060fe3d GIT binary patch literal 437 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$;qi2F45_%4oZ`T$W-h@8V3<|8r= zHLM-w3?E$->X?F0bS%+i>iFFl(Zp!|gWS+VuTo*!!8G5L6qV+#E-vTdV&hF`XZZx!Ctg+2(K!+*LG zyf}n6sxdGz%wd?3n8)^Lw!<5SBQX_|V$=lmo%~mCaEa@ga>DWD8@3>&dWK*QhNZV1 VXB~Ynd=MB|44$rjF6*2UngBtSpxyug literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/8.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/8.png new file mode 100755 index 0000000000000000000000000000000000000000..50fa94d16db8ef19ab376affc9da83e57521ee03 GIT binary patch literal 509 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xag=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G%cl32+VA$AK^E+@dkk42gO>_47BbD2s2LA=930$3GsAs45_%)I?2%caDYgwe=>Wa0DC)+ zpJEBu(uGs_VqJK4q!+Gmc2|7#;K6x;<2tNIT{L!h7jP?;z{$vZO$J~+Srg9=`o3ATW<2sm`|TLKPrTl zTM4C0@wMNcJmZkTkrX4r)9gpqhUhL*y#IZBnwr_Ws=ayJ=WMe6Cs6xw^&$<9CWcKq zi*>xuq!~Y{yjSpT_qF3<$r5arOpaFAv^}<%;kUe3&g@n7?GwjR)Rt*v>2>?+&$9RHs^=a@+U0rJ3Szh4dsk!UJ}os#;LACNKZ~sxR($&5C?i~5 v@A7U^MNazE_CIbMmba_aTK-Hn|Hl-#D=GDt)vx2gKxgoD^>bP0l+XkKdAG}3 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/9.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/callouts/9.png new file mode 100755 index 0000000000000000000000000000000000000000..7190d5a9aaeccb11ce5c500d5eeadfb1299c78e8 GIT binary patch literal 537 zcmV+!0_OdRP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001 zb5ch_0Itp)=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#0004S zNklHU+e8LN@ zwH$?bBM#-oFbrXu=5n0N<&eo_l66xSH+My|*$kFtfiZ?cp@2?jE#;NB;59 zCh$BDj^iK*0=TY=`Ft)L;VP9dz<+eX-6NdC{rEu~5!-)Q?wWW^dR3VGPBJ-vyg)Mf bmq`2tvJ+juyP*^?00000NkvXXu0mjfx%}Vp literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/header-bg.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/header-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..f9efa280225828f2ccfc6c051ffcb6d668967dc6 GIT binary patch literal 619 zcmZ?wbhEHb6k$kVxXQrr_wV2D-@pI*_51thH{ZT}d;j6X&tJdZzI*rO%a`B3e}Dh+ z?_@ZZ0GpFe+j^Y-nB4GQky?|**%@Z-z7FI5Wv|Nm#8B~bjy0ybU;M1uU}!1n(@e}RXNnDU7wMLU;R z%)gK^#d&Si`s=-Ar{9+8KG;xUvu?)u7bR8)^LF3QpHSns{yO`QJ$3uP|M=g~*eKi5 z+ScAK)z#h8+v_%A0^{TRT6o;hpwoH;@B=L;=bykzOp=_^*StzNTs-8zPin>KIR z!n=LP&Rx4C_U_w%;6TUW!;;62pE!AP;+eDOoR}_Nx_srzvg_C9-nzwp_ul;n4_F^R zdHU=b_sdtW-@J)?|DNO1=PzHsvi$h@>-TT2fBzYn*+QHrBy4SF*Vl+Su_4h}O+fM5 zEQ^VaN4q7A(|C?eT)d!P!MRJtZPSEJlhx%{#GKre>g{fjXgAw)^RlyPe8tanPJHH> z*)iY#A?Mwur5P7%=6t{_Ev$x8UUy{IJ*D< literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/header-bg.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/header-bg.png new file mode 100755 index 0000000000000000000000000000000000000000..75202f9b37af36592e8f5bcb5badd5ac3f71d0d3 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^B0!wN!3HGTRtuZ~QWHE~978H@y*;y#_Yebv%f;Dk zjs`RM4lwB)U|@-!VA^p@iBqE~yUEE!RD!3;L@}q3=OVXb&Br&v8zZefTOJ>-47Kv? z-c>Ydn(tecwS3j;nbmeyp1Z$2QZe1WdUDCGa=)P8H5Q(Ce?L|EI{%<&3ofvqPkr;s d$^Y#CFcq0@`TrwZ))?qE22WQ%mvv4FO#lp^PX7P^ literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/highlight-blue.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/highlight-blue.gif new file mode 100644 index 0000000000000000000000000000000000000000..4fdabde69252ba43e8b658c74a72775caaf304f4 GIT binary patch literal 471 zcmZ?wbhEHb)L_tNI3mh0b>*rn_bz?>^5NvQ+|z#z(?15yRD zlY#Yrf@+_NCr7*Rnu7}!QgzNx-55}@F4$S|f`i~ggBz0NjqwI*2{Q9{vnE;=IjrB+ zDCD7$u;0?zfI%<#i1GTJdsHRM1Uh5*=AKsEeQ?SYjaMqdjg0|KjY4kRs^-=Wtu3wX zZqXd>y-od16RmlavwB*EXSDg-v-nSI_Fpi|n$>jqfB1PxT?^`t?fQfg*PWROT z?4=7Bj-NPj$bb8e1?SIiu}ay0;o4&VD^suExnz0EZN;6_?hnqjm6bhlW2}3)ao5bl z&nzEpx@W<5 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/highlight-yellow.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/highlight-yellow.gif new file mode 100644 index 0000000000000000000000000000000000000000..3e847e7e01623b08e9a7e7d823fcb97104e76194 GIT binary patch literal 331 zcmV-R0kr-{Nk%w1VJrYF0HOc@`{bSf|Nr^cZTH48_|8oJ^wtd=`2yXqN@dAW)FA{*9 z0^lo>f-$0TSwVV~Os3NTjY>HMo^?sUEofV-pivzGA!zUjgNA5FQ#EN!ZcP>Pwa!Lg z*&TUsLwr0%X>V dfG2i6;P)aBqN^Dbjd|Rq0Yr!k5L_hy06YHIk5T{t literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/loading.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..085ccaecaf5fa5c34bc14cd2c2ed5cbbd8e25dcb GIT binary patch literal 1553 zcma)+TTl~c6vwlh>nb99Af5rT)t{mCEg5urg=A(g z{C|6SPb~9Xage|wB`SrZk2FOMYM!buln2sX?5Y+T78iB(Zu9cS7|LZyZ++}u$^oi1 z_j@S}bW9OzU2R+RMy&~OT>X-oZ98$jq#ogNfJ!BM-42wHGZk*6s2KD}U*IA%epmxb zm}|6BK9YoIF;*xSL!+z@<64lB7->LTW2Vi4ostCA(z&2XniwNIv}fFo-`MbG;)u4G z^p@F!)|9HhZprHd_vXjDoxs6WkK-6P0@lfxnGT>*p(QHoUV=u1FAqb@b%*W=a3{`LsH5k^AvQNL>6fPpy#oU(&MuH(*aEX4b35*} zn4n7)`I2U%=+Z=?BVZQ?vjQFW4gD@~XSOO6b{qu81`4&LFuU2(ilxW+1|ZkNMnWe79C$gs zWT?Ele|HR{JGPe)5BTW>0Ey?-Ls6S#GoV0tbt6ku7B&*0 z;i9QM$W1Rj*rRIdceL)rAOSl+sDe3LkB87<%){;ZdHp6|SNlopDXRx< zxBDF9-lTo&v`8$humFygUij@qgT=Qzhj8{ym2-{Xciwqq_Xwk%=O3B-MNAL_6e`3U zyxwmXex4`g0^1RYw~Dth3av3Dl^AAlpO3mG!nLr#&ZZ7c_wUboI+deC+&%TFjK2Lm z!Y&f1h|T_On%RCV&=4bx`!>(YezqGVhl&QpED?N6GV)HmzJ9&rh$x*i?*@o9#6QI< z5ZI_MRX;0+pY8$`j)eF#TlUyG(eE%E7S!rj;mj^M5vhUicPm zVWQ2z+imFyg}SRABmOBY_@osR!>7Ov!ioK`NB6_Rv}7Ud?35ed5Sb@?yND?kv~RCa wqs^a3Sh>&&L4)!LKI?D2&k@))k(LESaga|C278ChSzn3NWVkcuNoY&{0f?~U_5c6? literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/logo.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..b111258c0ca80f948528d9fe96d1288b257c5a1d GIT binary patch literal 35061 zcmXt92RN5)yjCbPTSm5!y|PDSZ<3Y0_lWHAWh6U$6Os_JH`!#9tn8h=H|OV^>wMSM zr%U?xzR&wS_wQbBh>DUlCK?GE0s;c2tc-*jeC>u`|Dim9|0}(s%Y-jT7GjEG2neN7 z=vPL_2ndu2vJztI?rB@;ZfWXcGq-bY|CA<^w;S2aj5dDw<7I}d69 z!+s|-<#RfBsIYC*)Z_x7Xu!n3=OYpMo`VBfKw?^D;4_Fve+mKmO#x64qDK z(L7&%k%D43@z>(^5yBPzU|AQXgX^))>8U@s=Mqz4}f*`IPq zZTk1cL~Im`^M$S+qLqE!#f6_j27iAzLbv1c&-b&MiOu_gGn=;eRZv2|ZTdDJ`F+js zdc=v#iB{!T*K$5^xhuLH?ahL~C`Rl#GqRaM%Ig%alz{xga5|4v`*{D~9HKq~vj5Jk z;EoTKjcEcoGK&Ati?K~lk*npLX$kE(gx_dmpYzE57PFF;1MeMZozCiP-WD79R0saX z`b_v+)os?d>lWh|dH8<_WqlW?e+0&D_1tED3NpqSRnHy-o3%+tv7_B*Fik$4^=w`} z)O&No`AI5AMY(3T>C%3%k0kK^JtX(bF@l3mz3Jj7GI-e|rZYaL=~$2Y2ObccikTnQ z4ca<1-`+Ih#*n>WvivaTJsNQumBNlDd(vEOv!tQnySIb;6O;14n+vAIrW7t8Tz^VR z6tu`4!M@&-=8GihlLSNtZNpK(7*5if5bQWilS#7RKc_%F|?sE z3?XVxzDAmAriUogi&ShSDG|ryW8?cv<#P-qb8hbH_b`R2QAVuC-qswgvdD>L zp<~EwD{2}v&(fcp%EnyXN@Tihd`EVWw4oV2meZ37{F8RLNHa(%6T^V{dC)5HYgF=4 zfmjh219C1;Tb%d8o06tUu07p2+Wg#n)hEdb@7zAB*&qZGy<860o37G)^krW*M%_Sf zCE~f1E;&*7hraIL1{A_^6n&ETPd9!R&x}wyk2Kzh6=^8T5Zx%fmJMRKNL9vtDmztg z7Hs>6h%levp9-?Sv5LztyLV&pBALsWBMr`@goPXuekU(PF_b9|RHW-A1#n13wWmpN zj5CNWN&DB^x4HzUrUM2gW#f2?_0~r6D{Aj~V&o5pxbggXjzrqUbp8cPqxgvAdEGFg z+0(A4`s1TxH0NH^b1x_wE9FL>jV(PK`O-74KFR7}p(N3us)p0Y>ExFzHC z4!Y${o1IL>4rhLTH6@o?GaRZh-enAOVvA`?c~_lbC9Z5qytf_o4mFM6va0l-Bt1d= zplv6{K0IM#c&;P5Yzx#4Ica&pDaGifulm}K92UF5pyU*}zidZ61BpZBj+Ub=2?;N`{^JoON=-J zp}faWqH+WlwDBiIGgT34QcUgZ@*?KcFzX ze@tp=jE#eY{C2(?ufSPtIwWS@fh*{K5Odlml}F1o^Cvaf_-NeL$34dhPet|0!Wk~G zkqFQ__D`3F@pYSJj1iB{TZEcm;MgW}Iuo{QExs{o7ZDpB;16_Qx#f zH6-@@G%+wR#6&!38D4xMKpg#NgN6uKG;Arfvh;pOweb13v6PY?aTHdh`@dejX3%oW zbu17_PfHXpy7_fU?}xAA6O_P~r<$=>h+$Cd_jy}gZY&>F426(18}r;cozG|<^*-a+ zcxAuSMLeV3o?FMW3j+iffwug&d!SqwnAHUc3#|jaU;vIY9h+}D*jQ&!viSo%d z2^TT<(ih3hCG941;uC4%G+!;(FV#1nzLY=nC7O_I-hFe+>sYrgqB;Cb( zYFMkcJ#)1bq?xhxPEh2&iUN_K(QH_+!Nq0xq4_#uYrerA`VA8$3Zk?P$5|?~ynFjk zer)Vn-_7mn#|BOAPL#q2sPccWPv-^;OPVg?y_+9m=J8Ra@p#YWp3U7ue0XT!xVoR- zsb^}6L=fMBau)R|hV~$eKGVi)FFLry*;Ci7;Js}mMNs5v=IF+k`ufWXwQF?WmS#MB zG-SuLhj>WHyfe;Tf8(@AMYT)4I|?Wh*Ahjp{SEf!9uPOro}AIDGT?{z^ccNW?Jtc-I{@x{EnnotWH%PSPL+<#48JARJSAM8dBsuK*zaPX+S z$v7C}Lp2S2js-QRl>fRV8v7Vr;R|Na$}=cYOmF1Hj@U2SjLq<6j5S<*UN_A>t)<>&WpQ4YIz$x8M4OnCoN(~WVX{jper zRe{YOd7q%SM6MKRw&ps4U4m;EMt~o`LYm0O?2nBlQ6j+sCS8$6)zelsb{#8ksbq0i z2ng0)1ZY)hMMTJBdn6PTFi=rZ1A~KOGcs?CwWy{i@} zI#_hAjVrFPD*qbs$t;AcG|atG-&9*FhrhD(M8f-GBQGv7(RnT1EyGp77j1&f*JM33 z6s@43fG;gk+D-HEwGzEZX4LGg{vsakxBTMHrTtGyNiv#lymg+0)Khc{&8-HQTP3;46PuTaZ<=0NoTSg3`#m&s!0_L{2Is;0l~vKd z-ZT7bN|=K2s4W{m|BV$sV`E#(3MRkkbb)`+ZPp{WqN0LJyerwiZDIcBd&Ic7I2AoT z#i%hkStkyiBEkr%0NV5Ij3WUu@~GfH34|AEN(0Fv=~%N~Sd}^v!(*3R4;=$sRc=o6Z>_1Td>-l-leY}j*QLdKi`w6 zJUdNP7PuW>i{fiR*{gW$P(AIjT{&KJ{O3)`$B%qwDX<{+jmH|Zez!h5wQCupN^Kh- zI*g5a{}gRaG^Oj+yW$X#MNF?yd$pqoOid4OxJ=mcP*c+kTXIWCOPf^cs1}Y*czSJY z?5tY)iU_1fuCH5G=&&3gAA>yjA{#rj;evvOyiJIn`}Aphd%MbO?VdAKyiaDyR-<2| zQ&W5QjM@g0DBIT#ODzU7{ww||%5!mXvHtJh;xDF>t4_DV!a^%cOG*)ujD@z~OxLL@ zyXnrG>&x2Pn@i=F_FdD;7VM70l3~S+zN`6b653_okQVZy3t+wXjz*QsZ70i0gqRo^ z7h~jEv%Y`F5X1f$7IrCXc|qk^KVv)BlpfEdx%jqry;LV8H1cb4RYG5%!pZJ*@aP6D zD{JJ*i7Q;o$I#I1>gvRnfQL(td_ShQ6;gR34i4VN#Kip2DVo@JHP!AkBBP%Co+!~0gKqPuI9deuTt+@DWWo0}p zJ}xdUd}<(4r2kwXJmrJK!`goZg?FOI9iE30lU}{sZl`&9sr&xo=%-YSvcS1UB%~n! zdh#22^^^5s#ZA$Py;?@Y-iRkZxJ6zKS#mcV4hV*m2_}TGH4%wn@11*p*DCcF+^Inf zZWDupHYjq*oT%qInM|`RZFqjLa`)p}c0AOrZB{lmZ3~X<=381H^c?Tm6&3M4d6b=< z!|%P0J^EGgCH}Rmh-YI)V7mk}Av%q8ME18IpDK=AbW&1@1$~8NLqaUMN#NGa%*<-^ zSmCZdnGpx6$%>2Lf6z!?q#V0cla;k-95c5}5RTJCXZ zZp%aZ*ub0PO_i-!&M>>>5G9>*hJu9!JzLWmb-8(eHawPqhgc)Of4Ao*>i=>c6z=Md zrkQN^6D?^t_~llz9+Db}K~j{0&Q?zpr1o6y^($?Q&8>Apnrs?%1Op4pD-)*<0?oal zmsn1R{k%Ejo5`GJXnq%?nOe1PpJp?}z@CSbD`jrJN-W5ErP5v27xPs9+xPEZN=l+W z?m5!RQa^i!n%En(eyFOg9U@iqwWug!Z_n|oQo5Xr0>*uIrxDuL)>fI1QS<@=DcI?e z@OQ$cXi6Gy1o-*+YlO*L`^>$wWlUb-MdRSaB_xdep6H&ZdT9xVNPsbPb=BP1*jS}- z47Mq)YWw#7kAE|6`QN{r{_c+M>+XLlB61@=?)Ac9baeEksVS{LrHY0|XB(DiUo?%h zBj1yT^VQV9Z+lrPs;VB$rSdz|Ddoj(mNaL;?h2@$^$g>k^Nzjy+7^tpwC@f_f9r2; z?B#BA=Hj9;onnfFlF}o#<||J45vIz@O7DXn`t@Va27NZVSk(W%ePb{-F{wQok*{4z zcyqQUdfOw<)+k|R^-QNI;qPBvsR)u|A8QY^mNOlNx~He-?sBhgPMgGcHew-W)t-0Wu^WYH>NO~KNMTLbeeGkEtRZwXEHa==o z&E?uhG^i=7jjn=i z<>feg6#H>oGRx;qDF)}fJE6UIM`t`$Rabv>7!~})jEsVU zKF!Zz3X@|A3k$;{si~=T|N3?RDtr5Np@!4(m?j=BuDGHiW(;kXI%9ru@oIJ$tMTTa zBBBT>m}MNP{oLH#jw|t+#yqJWTcuqeqoU}UnZqk>#yK5kg*wBD@zN;axFjji>9RhS z%f-!AleM#Bd93eFRj64)_w;Gd@87?7wR`cdog$f>U(3ZSqq^H_OdIvEM5de;9!h1@ zcsl&8iAH?*2;s9jqsLy$!*iY2m*WI1D6K!gKZNJrm&_G>yg5EPKHgQo+tfRfD<6QH zJScjb)}P878ykBl%;a%F)ypZ3j;7V@D-2L$`BMDHq-|dkKVG9!uv`%xi*Pz%i@3PB zO1`>;lq5_Fc~c1_6RD`xSY;6-fFrFUjoGX5W+YhSj~enYNYnN7zT|yXGcZtgH>I_X z_>kQyj**qs-rfO=`SYac%^d+FdLFv9(57AI@{BA!9fMc^KUXb;5=BB%a(H-B)<=&l zo`3+BWWKD+yhhaY%z=t?nGTfgVXoQT|iLq4ipf~ z%ah-2{-Hv-pCc7vyf%>jO`TEg)higNTQl{EKYsj}_exJsr=_Roa^EvVC@U|&*W{E| ztXH1^$aepx$MZ5VbpH{q@Q8 z`Sje)gEJ45#NOjdXD7EK?@t*opT1_XDP&(|`sI9IY6-p;%mzgsRmWubjV zpEb8y;Wmb6OiON>`XMcbp9>4ae*9p6J0O5wJsmM?Xn3&P^D$e-OcJ?jRzD>*C5g`p zR}vYyy|e3;p0=!;8!urPvb>iddG(t;ccHSuHJazo2_mH00E~!4y!psW6650Vaq)1m zk?z4$VCa>QkQ%WmrwXISd;4~x>K#+SLrif8_9639M_SR$D2)<2A)&N{1VSNlES}T| zkHgh06~^K0F8XiL4%-=-{5+FS3GJ$ZdkVuQw9*Kxn(D|#q}@5x|qugP$>_6aJYA4>%VDwQZgPUmrG5}88Z+W8C$iRl0t&;>({R{(`}u_#YF&O406uEi6kP? zlI-yu)%+jFCor?}i%PnNr{$fTI6MRHWe!T8>@8d^tt5J!rn~ujzj*tWb7f@(4tjCj zBHHZjJmOnAg|o@2eU}$mDvnDLyctKS451a3mC;E_?o+?^J%ogAx|asW-aT(b{#>`k z8#Y(7ee!0ILe#2Zq3dHQV3M7koqOZ#?saj$`DM#WhAa>kZxIUEzj5*L!_(99a4-Pp zk2n8BCq#=mo6wXxIl(sHauu}N*!b?gglRsQ+%})}GWu!A`cK9c7l92o0quHM7P;J* zj~`J|Qd5E2XB8D;{@2;rX?X70NS-$uqLy#^>vujJyy*0FMQa_B{r&xlH_SvYUs~DO z+&u%!cLF@#7tb&;F-qEp6wU*d+z02K5xTw|1mUEj8K;^>)I!w$DgUgGJcaM5QeJ&( z{cdgWVm5U_VFB>QmK-biB>j>^Ab>6cWFP{>u-DzlBmn0+Iy#d2&8McPqs@pL z^`mHI;o*K&NESCUdwRG2W@f7D0KrlZ;OF`>MKdu;d4Bj@x{`bEi2;t4YB8huztGSi z>`h=XhUdGI2|CbNwx)l7ObmSAGo2&CV;|%Ar{cL{b@HtkkiuH}h z8KPS;LS~FTYgk^?w=z8i8ih}(sNS#iCO-5Cr4U#sC@gFi9#;OZ`x}G!%a_r#AvHC8 zt!-_nn3$4}KP`R~p#XXH;ll#~0f9Zw#xyP;0sHFIgAuh1-&JCApCeUZLf?5vyGTfq z_-zP5elXYW2*7st2*w(n8I!E<5SNujg+E1D-`y3>-+n+B)3)%rEZhHAC>ju|XZiW2 zrl#1CBe}S6Gv>zF0L?il3;enqt^h7@>3_z zLxj~X_$9a6m)ut4w8Xc2b(rjSbKWPsD^yliM#O6m2ppXjBMwYjApH?gt)suXu-dR| zbUk~X+Rjx)2z#B(A9^~~>$XcsJD)7~SXS!j`uHe_T-pk;K2~OZ(8Cyy|gk(#A##m%rpQv`AKt@Ie%?WTsB=<<3kz-D z7i>~ec?So!>KRv3{ixuopSxg$nBJVPId312mpgYoLPJNNthd0*lA-|?Pe1%Dlp6Su z$<^6DkWO}(doVp|Mm?fZ&VhTuAZLW69JcxA$at6tGw6|c7C=L zl?)mLmIVH(1=o6~`We_#@E-~~`b&ICPcN@Kc&@5SfK>tfc*eqF))h(Cm&PBPolOl} z6F$+!#RaL~695Dx_}y_QB@GkL`kbGST0MPD);XHr*~q^4n6uA{SNJw+Ei<|KOuW(2 zfA;$FqlYrGcEZa0qcY}l`xyaykSwu8!}l;qdBW*4y<^~mei|~K$d=dKEc%TZNfe9E@5cK9Cb56Nbq5iNoV9hq?bYlbDS2luouWUYPR7RF zU?KIgHXe~qPc1mY21T4tEC@OaXyQ*FphPShv%WUA4GU7uk-Bp^U|+zrD$)qkDFR0J zq;M>B()KGz*QzQWPA;xz%*?c)9)^ZgKvz5ncn?Mid^f+S=qWX|Kd4wad3jkGnV$=e z*koji0A-Vtlfa2#%lc1me}&0c(=Cv$q(B#|qN5{cZce9Dbn?a1=XGB8-v4(2UiaCc zT92CfO~@g*I!yh;T3FjVA>{uF0S?W99P{Y4}r~Gu^jlFJpz)OSy`yHM( zcx$i^L@w58KxV=kZVg)7A1s%dxx9Oa^O!)Y>H@6lHW!NnW3FGV8ui0uiaM3Kn`^AY{^ z>(}3&lc>E?!$x`!Oc8vR)gSDxI}`8Kita>NQc_Zh-9xYo`R8M^)ySe2ziAYLuY`7E z&P@^!Y6y;#gand#IdMP>c10u#DykSZ5;qAZ4$QC|^>n3R@vIj)!;~oZhlht@CuL`6 zvlC&!Z-9rwZ@_%b8MgEnlz?$Z67e8iNgA9RGzd(@Ifm%OU0jZ2U9jd0Lt90Cp3$;a zR9Bo;*-vO>-QSbbPpll&a72@wvl5e(M0We@^bnLcvtHdD9zIyP$z~XtogG-q^cy%> z>8;%?u1{h&y1&#JAxKl_!i1fq^z?)p0oFo`nGj)Q zWCXCX;|U?5?h06QT^Yh&-2(%wT0X*Nxw)oML@nXYgP4Dqn3*xO6DChP9{(O2LuN6B z^!FJvgJFVPM@9atWS)174;nLIQ>rr(IIs0DvH9I_CF=R|n{-B+T~Ad$5%Ep}*Akq3 zmZG9S%gXl7c1l@Xw&o)cZ^YeYTWb-ap)#_vR1$?NFjHw6IS=NhJTK^568|jvOuM=# zT5$MW*ksIIB?^C0Vf|^=wqsg&29ZrxvY9bzYu#2(VJp04Ry*8Sq{t7_mfL%*2Ey ziw^JW3tu4T_=JSGpm7;Om)BM}%%-^ieAnxJt*L)rbk*(0sT5ara(cW!)QDx5Z&~bt z@WScXY+R_(Xz2qc?~HGo)&d6E=IPE%FCv!EUJ-5(EH%03I@QVUoS)SC8QtB%xILW@ zfE!sINRuBB%O>2(iqg{P z$jC>bp`kEx=>!~+%BQ!%g#@1(BKmt`KWC?VuYkZD?$lqS{XDrFg_gFqrnfiO4M&S% zTYsCJ#JSh8=4p21g73b6{-k`;FPsjn{&IjY z0T84{w-`czajM&HoD(v>|AqR^@8uKaUc7^%r%z%BL{h=+K(f_f(o0VV|3U&{ z6{>py!!jVO#`XP#EtHd6dvDJkLeK>M-(P#)-69=HKnmy8{x+j(JPL}a@fB(wffR64 z@vJ#CF>h}nsaRAm2ew=HeMwqb4Mh+X?nhX5fNbRcrmIsJxqi--f$6f&+}&K4gt%PPQ0wR%{TS{28rZXGYW7eYyMtM%?;+z{9^^P8%0FyXgIN9`bi@Y<;j2F|`4 zKE#0l`qD@hrx*NhpNEgwZOXA{%ZJpvW<_KodY*B8Yvh$;}OdaSK+r*U46kDUUO)C`F}I+Yr@D24;rO`EY7Z zT<`Wa=ri_I1t6-i!p0IR0$hfLx$2DPU{+1kd+|mnDynO|=HO-uV~-8_@`d(h?Rc`H%<}5$$jppl=4j7Cz{Aq%ZQobPO(M%b9~oCqqYhjC5Paedp5W1Kd;RHP6kA94 z{cs!{p@XYeOBwE-lLQ6A)29>Ck4VhPd`{LO;qFQ1GiL$gzWMfg_s+oI7|r9d`NRAG zlO#|nug$*tm4U&aMW)YP?h^uD?37K3@HRI>&0l*oG&BZgM)5e>&dhg&(F+Sim=Elm zw|PF8n+*@o4&1r-Acu0w3PM3Qo@~!4JHNsMBvs(sWRCNHVQtMQkj~2BgDZ&x{*zqp zUAh437_uu+kr1!K-~rxTQCY$%{h@;aCwuJ-3CB!Yt%O2FhB7dw~_;Gyhc_7nv8 zJu%9sED(cm_PKR^Tq`BXlU)4Y%9HzNU1ni^eJQ*HCxmH<9I)<`nJ&QDn{QL(VP z){e8)^UvJ-Qw#+%2Ol3fA~ye>TZ3a+h=bHJ_)S_G1Wu@0KCLiK07MaIXLr_SK3ZU_ zIs<-SP>|C?iLa!VCBuW9=#dy)G<3A9P`UbaSY)s~x=2VNbE9Kq3|)@H2jK5oFEzP~ zGM!Ai4!Ya00EmXi#)2BF69KYDMn+Yi#RJ+1*;gCP;XRhNkw?z~D|mf4r@gb2bJeT1 z=*B|qQHtI(m0#WVvT=X6BM5sJ3yZbB4`&cd8Ubf(zTS2K0~lQG`F(eA9OLEgL~){l zFF%vU_d7)>TIUbP$F-hcN9CslDUTz={KKMQOBn?PT56%R-*NaL5hi{ZA%Z(D<-qoj0V88~cQ>V5Cx*Vqxfw{BmXgQJp9{)jU{zphfWUAU z%J@9eyY2e$`O3WJXOK>);JiC)5p{Dus!xZo5f~YG#P0W3k72Zds+`$<$l4oD&KsGO zL<9(wUr->PGYk)uLWtAM)I1v1mz^$aWXjE&x@+=4Pk9VhzmR-KL1h)E< zn&z#^3@nTez`ymUTVSAF8+qyG9eB>rWz`#p8<)Z^ljHGO390kn0i+&MsQ{`H-< z1K<00S@3P(ou~((O6-;V))P3o(GE+s0Z&b=O&lbkyE~s!9-fUd77RI=m_Ufd+1R2$ zlo)X)TUuKiFLy@=Cif$NdR5WTmW2ogLIv=ykOg@m_W)(V<9EXk>7Mb_(Z-Qrx^G+i zqA^I6whvf&*$rtQE<9l@g4^}&xAiA8xzNy|4}p}S)KUTWs(U3pJosVOtb{dsfvvB~ zPWQ(TFLG;UxBjAR?lz|&|HgpvKbe=yKQ`@~7Kqb#@}kKxEw`SNU`pleS4f~RvoM)# z#5}#@Pb4J2V8ez$665xV+1SMRTS0N>hKq5j)|GT|S=l^-GepwUb@4|>E)aVH_fU(8 z-FI*7j%k07_;4NK^#swYdnM!Y9@@mi92{SAa~B|v-kRMWf7#yk3X(#GP#_rda#$D> zr7#BkztSW2dHMN?5{3o+uHeqltqRxXvUotBAXY+un&y0FdhPk)5rvY?f7&JAzI`q! zfu@0?voqK8%1W>oR{K)B0$T#^2v&Ak%%cB&iA=Vd^5?v~cyJF;Ik^7QouBWb#e8&p z3??&CMXsEZ;>uxvYLD<*nqRLWNgf`(J$m+FugR&%k(1M_m2HFqQC+{yUfvnc(fEMi zN1SOJHte9&-C@?>srZeJ4KaMl-`4Ng!+ZOA=M==nTTch7>+4g4&>zRd#^Q0C$}1}7 z<}{|;rSjkq6G%ej;B;@WIRefp*huORU85#y_?r3D^V{t!??^O=u7M_zY!hP@#`r*K z36FrX1?R(%iuvm5!RGm)2RJCD_LJi3F5Ga_U|YPW1VFNMuxWcj zDD~hOw% zkmC?d);2aCU>&;eHlCiX=R^?+dmgzBXeOAEdo7}V7Z&E`eI6a1+%p+V zAIoovolwOCNc{{m$>L3s1}OAes9VT_0QJP!nQP93h50;Yz2PhXUh|i{Jd^6_Qk^33 zc0Q};clY<3UDIc>Q_(+sX~{sGpU+JWvx4enl8BE$H|HhRlb<7hKD60)P0kHI_By4O z#U+WLvn0<C+2Mb2>P`a8QAQL6QtP31pzZ! z6#t9Kb3jJo6mJ;ZIRZ`HmQs^0J|O2wTo#W49$>cO^HpnVYLPg0!~Pjk=`#;ln_Qub2o9u{)`OIDoL6>rSRUn_vfemuub{7 z5C7COkS2w}e#w$?Jn)>9@k_Of;ObR1-}HX3b>8@)#g~$)tfz>%M5nNK`EFvny`!Do z;}^bhP7WaF$Lw{t11qbn+}h-d3T`^36bUddpxp#s0Z<>f0>H!UrmTB8!yjK2KINqL zUv8K1wB<2ItP)qf7hR#2-@bW#;X$tr=mTVB|J)m9KSaVWPd?(@8CacP>Ha*t&j(@5 zo$X;=nLWAz1{2kD7R;~?aT%G9bN6fWf@4P1it7&K3T$kiF)$0!7%ATBQK6t^oMl?9 zCAYO6ggwH4ULYa6*rzYGnMeX#XKx{x;w_k58JztFHwTY-?EiK{?ZF)y66d3tH%I9Q z6o8S`+S=VaD4nbFDI-JatsI&W4vs>G z5ZEOD^_%BFy+SPDp-K7VkBVv&^!C)ykZ_DuE^a1tZHTWvex6$qFB!$bBMr+bi2|v~ zOenvngIc6PT7kvH$|{vNn#D`>Ng{gEdCjtb$5RrjT*L;P+_pNw!f31-FuF|7#UHxQgQZn zKfd~^fSMAJB>r+3nbv#k`ExLo0Byvay?|8ruE5|%zMha&g&l{BLm&xx-K#vMT(CSM z2b5O((&aTZ9|H#fpXaU}B4J94azCOglEZS(5Mr{kZ3jPjRasOM>8Q?k{-!&kcm`9H zNZ6+Lf^>qcw>y=|`Rei zztusN4#KM@1V;>{T;_ex+B(vdz$hlXx)_%!QviYlaq8AoW2z4*QZT*z#l>_y1%e+v zp@ax8Fc9exIo}HnR~|XB&vP4JfIbDx%(yq`!%^J$_m7&6?t@801biC6uM^*szzE`{ z>c0`8;wVXw<`)=pO9zQV3nyQl5yoA2cOTf`oFHw$h}a9ER>i@=AQ4Kcs}q1@8y%OX z@cK0YnSpmph4TQF0MA__2sOC%Xqs>$4u4p$?40ZY%QrWF&q9AmB#0s8ioZaX(JLXdqVWJ}F$+OCFXSH)0k`L5q6@QwE@9~z(3G&Fb31MuHW z2EZ_OaaGe*4;Mo~!_=Apt0K(CLN!Qc$(< zvY?mBiH22uz{>M)V*>yjX}ej7TzM$l9RZ@zqmz?6!!Ki|p5J?q(y#7Re@ak*&vlFF zPX;+O9EE3QVA8_uxu$wKJ@w=Cgf@ZYO(%4GnxfBlc6L_T{Lazwnk?{t`Xv%5<&ARqZfSXE zcTeKckIW8>sTxs%@}Xj3i6|RUJHVnissE{=iT9WyN*Vv$_||tyM@I&&J!$OQn8L4~ ztekQ#cYOS(A?)SJ;O&4_2s&3L#-+fqSspX zZ5kj>QaLzL<9CUD^ZB*|9KVX{>cc{Gw&mD&n>AZyyTAR7W?U4TX5-kWY?t(f*SLIjBVZ^3LcC` zjj+*$7kK1K&CkcLr;0eXE!}e(TMIn*YfLx`sgAV3Z9a2Z_HIE3r73w17iP1SX{xlnO3Sck|}EaZF_wHPHzT%cqHX zY>Beoo2d7pa&-RNgyuxP(Pfn#(4n7$4j3|%|IMq)7miVf8V}uvyotkNM|aksG8A;i zr<8=wH%ywi6py80NdSZH;15(B@T=^~Tx3|Ck6X5;pU3UHu2@>KZylD-kRV=)<5e$- z`9y{gnpDHkXGDjj)bc$|O4sLj>^rVmCcR8u8bqmxcTH_$UdVPDguZwi;tHFfP~}(7i3KsNw`Z29YZ?mxx7O znbYspm)@$Ut=oU+CDL-g35v2JNYO%w$9H$7W7~i7GmYPw&-2KV{kN%`o7<4R^;Ct` zO&HUy{1rCDBwY6i>x=B{fD%B+2>x;)a&|c1<>htg?Sjhznr0U_3w) z``p-gZ9^~T<0A~Vaa!6Fb@0$(ElC98^rovX-;o6c!4L;hwWO(ka{B7Eb_mEeE^LEd z>vAA!`>%NV2hoDWTkNpr$ewMU*|u4v-bx>vCAM*eyswdg`1~~0{3`J!HqwVj^`~}pyZA3#rAULKIYTjq z@6XUr$g3^OwTQSpx#3LT<+U^Qu32N&0k|b#l9heH%&DtO8Hjw;++uFc_zn{jJk;NL zAK8vG{bR>X@4;IxSRyxjHIwD$xAK*5&wm9(MvC? z6_fyA6s-2Ac0mdZRa{Zo^IKL3VyK>RL{n*N6CHV8=&^zTiGTf?`}y->GL%*oz1KnD zpTHP_A_I~b-?KWjGY?!yUmP49_IRNw!z^2K-+T|)UBVxY5iYKcf9r4@hi7KCn=y{& z#elX2fKc8%j!8?Bfi4FrkFDXKzT`RFr`MtnTNuL7h+iA63^z~S+D}jX{yT9x66&XW zO|vtE+6skh2rmB=y$Ob97B6oiw1xTByJm)lezpdoUz7XZYuIZ=*Y)1-Xn-=oEn%sL zA0tLmXgl)#MypDlM{8^4&;d!gPY!DC34+*9$g)O8{0G-wCV*F(y}q?2fgSj{q$ea6 z@yf@@%3o9EH4hIV$a*`)e%VuB=#V&R6SoCFGTTYx*Rrd+ z4MkmSKAgOjO)zb~ESg#SRK4@}!d|)hSo$$UGeCtpvTUvT^5LpPB=6@ zP1-QJ(B5 z>+@pZ@1S5|(Q_JB6F^)BZOfrsvL;5`XKYM|yVR_YzYeMV`}dFNxhFSN=31}|z&(r3 zk-jq~q2+*fUz7WBe8R}=r0f=NAj5U@qjUUBGi~vskeK^FS1bQ~`TE5)NkPR5z~Q%p_t0UVcd?A;jv1rQKZvxR}q2L0yS~B@K9vGvJ|*U2Lr`5 zIAEZd^+wcdjf~PlyZCzUXx5_Yv}uxiMDXbg@&B;zGmI#|IC~+vZzwHHf%cHefBPfy zy?X@MXDB1GGLyERlcruJ<$~p-Ue`BC$%)Kjp|U^U7B{2R3tkQkTs90k&z-)WovMm} zw?IBzTzD=|&Zo*Sf9SE5DjehF6k>Ki_k_+wK>+|YIPj1vf_()osK55rKiFsU2bh_d z+N{f|5_^bw>f@V zR@sYmQ?q!+d-x(ELM>mbK-lDjnAFex7Hc=YTiG|}21@*RQC)X!GH7)RL!g|IL4LPV z%p=Pcxttt4SdLY`YZ4tZf}+`S zU3&VKwf$Yee}soE z)!CcftG&AcdRE!A{?jS?`s4F|>Wm%luP>89`2xF{bYA`8eCfKH<|NfgkgkBC&5gV8 zy?kJC(C>=Id2K-QvP6NGKeCTBO47=~!HX$DuKnH@x1!4gg0p%Jx0DsP8iJUQ9WjYX#ThsN4GTgtGmuc@>Py0@` zla7=*J%KHTFPI5m>Ami_@wu!4ps*5l4VR|yiMxgJo!`{pT7Wn$uJc;s9HSBw?O^lX zLGN6`YJxOly2wlh=B_-IEM08F$&^i=Uau2lvGnM~`0|gLS3q#9~<(kFI$rc$# zCtH)>bxQpu57%O4=x&c6qfn#C%b)E#_-dElVPNnkUek0z zUB&@kk=b!mWR;`E1-4RLzf?~7ooW6)JTmg_+-Xx+eC7rIU1P4G>;RGC z<(J8r;9UAO=ZF7fYTeZ$kN{YkNqp_%;F_1U~+;VVg6@bd# zGcza2m_fDm@IWf_F4`Yf#qbn9T%df6J={UyU31)kVW)I`5$MjSWg&WN!Ae+(AQzvc5h*H^Xtk6lY}fhj2| z-yAGI!)qJP0|N4AweCWZYFU)&a#YbWu+X%)A?zYNA6P^UP&CFiTms8jOfv^h9ab!3 z2y>kxl@E>un-2Oi5`5m|qScCfoct#fInj8X zZr$TVt>zC)S7!`@jCW}tJE|*4kCreDb-y!8bH~mgX71kBR8#Zc$0w6iB81A|-SgR+DVKJS`FHFIO~<#jPa>pf6ngPO0za|F z=cM(TaxU)IP?iW^Ld-Iy+0;5>*2@`dQ=0}{L1HrS?+XT6=FpZFG4uWuNq9-Z%WYRG zSIz0?g5m$^R_K%E15MrY0p%-(A~>yE1yGj4AS;ry;&5^$~H>Ln9D zsT;hXe`nJr6(CH0yP39KzY~#{Za4NV9|%CWEci`c{=>AK%uA+@U@@>+s>ece54{j%f2E}fy)b2X zDqJo5Q*AEYVdnL74=sO8qo$3ts6*E3lADvQ-mIihU%cggnS4yA1C4L)?Z19e1L=)$ ztcZ?_Ljv>JqqO)D(EJ`Tva+rs#iLLI&a_*1<|%O`Jb&G$r>6&h(dm^R9AoZ*2>Tjb z0_vpR;q4>X_2?NGBHB$xW5bplNdT$Sj;*e)F1H?MHazvei8Js0_||w)oVlF+akDWl z@Na%kZ^Lz5yxh`CW+T#d+o8=+!8}rCm)!7JNK~fJ`Sj^lqFQ(0*6DEsCy9?mxwiX|Dz0_?~A&N-zT= zT!t2*Dr^xXlr#J#-hw4j@vb`}eaY3G|F*lewW2oluoYpQ{=fj>&{6H8M`P-6w$1SK z4-N#Ke&d4C32=HxFiK|cxeJo7nio=s;ZVsIYZ9QN#`ms44GcIa8MdljpRq}~ph@3f zd~l#1KYmb(f{=+G+jQn{D%*)^y*Wz}5glwen7d-`FWmL6sjPIoxjF%~W20&JWB}X) z5|>LjRI@0aVExKb^<;TD3(Ia=0~zD}{A6>6i& zmvj?OVsGTbtCqK10;2Zd&zJuDOEmZm{ZuiXCMiPlq7QLmapJ1HeEn29QM!GHs8HSN zuS_2iQ3^Q)FJ7+;d>P-0t`8p$S1TmU9}(L64g=1TBdF`ZU#DEB4~r0J24Uxi-U9S7 zcM4XWzKWlpIM`gfyA@!hP$^K~`_==o1uH8p7jZJQqswy(#l{1J=f9a>F+;JX{K%nq zjJPhoeuYqxP9@BxS&lKIt8prupuGhalIx3b50_QlfZei?1_nqSlHNL1dOmC zFnfZ3A3kSXXF^0k^{hgknpAFu3@zSF$I`d{7wo}fX52L3+Hyui$jdyP$fM-8n>V^# zCcdc`RN?A4mpdB^(XtgfY#DcYqx$;oxH+-y<-d%@%aOaC40D-^`hI6?-}Gv*%e4EF znl8;@3@>LdhL3Yki9(}Lzph3&wSuhvbsc(X3n%F%GVH6CF`%YM~D ze0}&=r0L&Tk<91ltnN)tW#ljjwpSjQHmKtyt_8=($4MVl>&Jqg8JH!gzpzWXy1LG} zj6N^8BwN6|mV7tx*FLtg+Ju+nzZqLl)xk0y6cn_&v4NSLT6J^;n;M|S@b{OmU-4-t z0Fs002&|&O^T6)`7Ft$T7IpM*Ss51`KJeT3^e6(i08*t}qX!c-t<622JE5(wp%3z; zroyz+m(GV7Hrll)D$xyb% zYkYNa0`@G}3fE3R$tAb2Y-eMWbJT@LyTo}r0yRRWWo(QPti0fQp;Kc58V zGTr-OQpmopqocq}X5O3T037Xrk&%z;r>+klKB{SGwDD;fJvTRBlRGE%v6W8{+p=&| zPf;6KPE=|vE8XdGv+Qe-X2w&Jw`7bicnGI(*WB*(W-m9E z(=yR!L$A#zGqDuX0F7XW0TR|?#f!0T`TY5F7dIDbgyLIoQC7W1z-2cMwv;$jbu~Lq zr$~ewGQnf0w#f^KWC~X6wI2|B3Uv6d_4SZm5>`-a}uY3>p!W76nxqQ&P_br~VBICma7 zCbUjR9{y>Bv0~Bj{2HAW5e{ga&+p5)(Fl1uDQ-Q&jmQJI%V#!|2M0@gYVmg_xqDpSVg`&^m<(r^U)=>1JyBqC{hAYOIIg zh6aYIFam6t5QG|M1O=y%uXofnaiEBce99Dhjxp4wS_8fZg4|)s!#)I zddI-PgemdI<%klTi~-R@Whe@Lb36l|c(+@RID%GoJrU>`%|9ovFK#}T%+}w~Z{ESV zKCO6hvlbU8akiS}C*r=J-ZJXT23z7hAcm`5c+iw!CPEsWL8ann<#kyo3BIpEiHmPT z&r`v02KDCO$q_hU!WVbt=#z3(i&VSTU^*Y8CjeOBaPr$yF`M4dLn7Lm*|*Q1tE%ZL zGN*Z(z-?nr;1Uw*Zh00pb=iXXfASONL=5PDqLh}##LqMcpwudY+o4l3K( zMv4Z*7f^QK@|7Pr(dpFF($t`G>aYS^+#xFmPb1X9Q-lkrfEloqmbX3DRiKU&gs*#Gi{ZdXh%cxElSTb}=B9-L9VpP>cjroG zagoGeJ$P_`o*%Bca0XGWMRC(L-wTN&LYs+_wMRxb!e}{MJS^v0LZNx1bO}1mgpyXw zUt*t`e#tG!yvb52ID^T%(^CA96p9i|4zRf>(?3SY|2nz2i_rrj_@AJ0x&w_z`IXU$HQ3$~G<`1=Ei|wNzh)m^!`BZhpG;h-_%{h%P}PaGLy|6>BK`-!&Gk z5peGSJ8znk)0Zih1_}n&WQnZdZv@`lDTF^XW){wKY0Q(FLam$?0b26 zc~CM&L5-rM6y=D;o7N8yiOMV&?XIIZIXO9@uyNh9gruY}HjcQ3Ov8pa^!{RHiN~HOHeR;*lM-CKMiS}g8_xrs4NgFUr%q(f7+~! zH#)Je8O%KLVXdg8plsqjbVayaN8arv{5pCV`u+R&;ImF}@%9L9q)QtbQbHMpDgi(j z5*)XbxF9t;A4w7~7e?O8>}(nU6QO%Vu{Ub}hI@st`AuIzIK$$m(O14=o(yWhD}{ z+kNYQCqhOF&NXG6TylM|RJL*r3lYqoAi!hf;OJa)Qq|IuFbCla%ra5Vnxz)kb9FbU?Y^nrjR!kygO^8j zj~*9((er_8lHT3f?q%$P-M##{DLO95gv8`m? z0z_!Q!F>Y%?RkeRY`hqC5fj8| z{jyqGNs@sY%!%NX!$(I22xauzP+D3VP_}g3aSDtO)X!@ZYv$ZVP{!klqR#W6bvpS;`ZeJEs>!uKgw--4GOu z>BlrYAHx5VmBXLWLQ?@_C}Qb#WK>iHNsP~yde&$7&Ky2Vn6O=dBYAp$M9TH~gMMw_eohVEamQjkVDpzxBTyN)EfsIY34+3PR@5AH`{SSUd473Z8jpXwB5OL2MhZF zA}cEngeSGN$(A<<#2?x9LS>8Bhnj<6mjY8ls0On+fWpWT2jGuX<M7ovbchvaFsM&dtF}^NC0UY1B)o^Mo-|p1Iq-}$fPW}aD1x`9N4y1PohAOqIq+e{81S*F(bHsqL~f}KN~ zRTid8WcmufaOCKwOz|+MAm`6Mor-v~4J?=@fR=%El?k-k+i4CkGC}jgdVrH4Pe(#Y zNfhc18lt6^D0W&BbReQOcekZ;#%X&8v;&)|0sMn%3Dr142E}1wEW4`eVOT3orI)kD zrG9I37T*|A6of0RD`N`R6Re$@Lkk9z?h6~V)!5|swudcd+}SS~Nk~W}=@URw6TD=} zNz!J^zv5O8pff3zaSlSu&@Y8T#O*(eezF0BhExy<#H~8}OC%rKe!jUri(?k}J9WXZ zc_neNFL1NBN=12oHt2tx6UAZFwCchN_P&M>_o#g0A+o{oc-qo=LdQ~7UH!3-B%BDO zU=XTd8su2SMfa!4)8kndM^rn^hKjNX0BG%V^=J|I_v*qo`<(phk3a)*!oCFq=FV@` zb1!cu7Phsn<{*v92{kp{p5I;QXgPSWq6hpj^YQRVhTAv<0Slr;@S{X!+R?+d`B2?n zPOO0E-bS~V-@T%`rV1)T3Uo;(rtV~sT(!Pbu{1}RYff+lky2d|N06AZ)oEPSuVlSPOR^O zCl^OfgBW-Fcl-|*3zdM2tp0iYO zx-8s|;uW?t zPScBqCrO*7@f^pf|XYYM{P2V~{sKyVH7?t7I2Xha|;hsg-w6hcBm zkd27!geN@awB{uPPwES5Txzly{J2i&&&YtTqOXE8GtA^Uzjgw@LxfmdCr|N0e2*Dy zs(>V`;MNq5TLVM`n;=Rd-sSf4J+KC4O^x7-;@pw|E^QPT&9R>=|EX z`Y9xul9J2P7Wo5);8psJ{eQa3sr?p69P#h>ZT9^9e6X4Uesyqg05&2jOg$JGFnCEy zJA>ruKEp*hdc+T$*XbeEjXZNk$EKrkm+al>=va&o@kw#FnEKfGq`HQ-{L|Mo@K8R6K$V3B@%|15 za%{|j#Af3?)F>*Li$U}*r>BQ!9v3Y%gC#lIm!kY5hh%VA57eKFN4ta=A;G^l=bkSt zF5;NU$JgcPsnD%E3PN}oJnSyQ8UN{pNYTLacIE5)rJ_Gdl3EfvuDT)@A+2{ zF|yQiR**1{$YEY}!_FCoTejb+l5JRJ{jjv@m<;eE>+NlYC-{AOwec}YhN)aOvrSnb z6siCLi*7mL)&2SmKxP2Ng7Bd(a5@_2XQU-gYHDb33ULK27)#O-sT-<31v@Hz4kG)T zpskBpFm!onNiUfRH73WvTcPvAg=xt#nb^o902mp#6q3Zy$e|5o$9#t!Hy{f7FFINf zWWI3alp(U4o8Mqce{@YNEiEmm$T6K+guHavC{ar}y2hCBBV?vr;aesinOK(Z0w z?1zEqcJ|#joFt&zU;A2AlKL_GS~VxPHW{Q~%GpJl$k4^murSpwGtrYdXS(uML0H%3 z7tgQ(a#;AYZ_{d?G|cNv4}*h?yQ`|Y9#X2BtpPwKr1VJ_k8{IC)nI-covM_2w{eRoWU|GN&W7Bu@$j^ccH8Px`#uV`}KP&?7slf?p<6- z-LrL9QVL!BwLdgBrwnmQS(mE}Oy}>Mt8fBWSmHf+2ZnvauHNDY-BQD)83=K2tk4un zF-q+hYXag2RvxjXZP?;qf`kd^f!{$w)*f_|k4S87RRm&S<+)aQ)F zDBE+Ay(2UXLR>qnxR>1OlGBr+8E^@4HUIqij?)I9BEVT*(|=YgL^@)w?%YwH+6gq$ zVkMHMMZ_!SS*3FY^+ZO#ng4HY`<8&hWsaqRd$+Q%g7_ zzo8)m!VguowUbjWi61T{r{~reDV^#AVhKdc7f-Z%_YmD{|6JS;>jwQkA`?I%vnTyP z%8)rhO-=KgTExTrm(0uW->V>q)-bq-nMg_UN8eC-uHxB$-^|~923(}_ScXc0qdh2! zkg2FEz#zWfUv6i(x{$y!Q)AlZs6&Nd58;geY0fo^9-fR5B9VW9OCfEIOH{OPvhn;C z%;!6HcF5h=YZd+G?Fuqf(v45Rv`lyZ!Y9S&5P=6P(8wRrCqz;E6M7DB_kP}nEgTf% zSlC#=NbX}lD07+S{y~XzSn+4E@y{=a0gMO9P;^3$RP%6-9I1a2`5BC}fR}h>#5Q=J zsH}*xL72n~17AK($YbW zW^n4Dfi^EaIk^P}J7qHwUm#Aabo+7q_U^Ro3&yy*^78Yh6OtaBhLy|Ht~=ix<^Axx z=pvX+b-$LG8J!;$8WVfZT*Q=^{&n7TFjH*KZPpGTE|?CH$)8A-H?+;sOOMXZ&gnAK zdq97YAmg+q^_?F8AFs{&QQet_3RfwKJrB~g8oZA={g+c`Rdg$Od)Wk!TJp=F+in}f7HDo$zn8CLorW{v$$f~7C^A2-U)KRt}rKx zO?SS#rgJ$^0(d=Mq~$!YHIB@gNN=)uU@(u28>T?W2e(`2efyFAut*c;)?_E)l&?RC*#27n#7s=4QarNeCk4P4Q<1-G0iCGb_Y11xDB8%#;!q7qT)u%AmKqlk=J2;1U$G{BNGcMg7~));XY|G zFzV{7s{>s7u|w<^&oDIC0RHhd52q>fLu*HeE0V5U_7psop~gcvHNb zUP)6RhRmwQkND+O2csA~K}%PKW7dl056A&m6kNE6ayww}4R;DEfke~dVBJR6AShwG zAsco0P1UYvmiQGHY}~!ES!ZVUMZBAp;nMZ)k7EjQxaudb&l?u&Hy#n&Yo9QL zoUi`w0_q0xtwUz*>ti5d_vVhBFSIU}lG;E?>Yu>C`NBJM*cK^@gp}#l z*P7q7o0p$Op@+1d`ie^}aav}0(nGkf>-Ltbss( z5EBE;IuJJ9W)Kt`Ayv5g@#fIqYWMfANgT1@aqD)t6dybQHZU?W3jJ4O_sFY3+?2|! z4EKK6@Ft|ye0;A=2NISPT`S{TzSW83=%|dW?DXU@pJO|9c>NnW$v=RC?J*uoGj+4% zyUQPs`7>gv`1F+f+i^j{1n^B-`_xJZhdQ;01Crtl9KZAy# z4It+@(MwKfS#_6@EQ0PwAbR>L{$KD#+b0Iqi9n5iZvHGOicdxgeuW=FoFt@8_d$%X zx0L_&RXk6XeXmNTgd$Y=0iA|am>dAQaG!T27IFK#x|b~-9TNkMYV~;5VZ%A=g1lzV zr(&-yozD{c5$xuWkjulz_e_x7LXd?C`}C^CMT{~E4=aR(oa9%h#5LCo(d*j1%8!b9 zNEfVIJ)Y&}cHL`zdz2lwI@lCJXZ=!JJAB$C8{)SnCNx*MNyX#B{$^5wNN7AUaf+2_ z%f_bQ8Kul;RS3U;2pNk$drK=1l8WJQ&Ek$7CoZUlQJ^-j7!;MJ#>I6bzx7u0zeIVu zV8$(=?I3Lh%-}6}-M0MdFJJzIT?W_;U=#>P>T;YJN!l_VYESRDWv3CLqjGnSdZZ5w zs07^q;eBEcNGfcumzS5(Z`~*M7vRUWj9$QRn>R4H{1L1lj^PvAeX2;HP)8Yo( zgH0J(Czg*&gdL9r=3O!_2^leP$OV6nYZ<}xcQHiFkkqRKbGcj`<&`$K)I^CvuXNM- zLr^?an|7XF?$lt~4Z)|SBOmZN&B@7qDj(|ra|%w$?#(+)GLgh~H$eUhL6#sd&01rpX)R1g4dw`pR&!3T&H zD1Bj}8?wCr8K{LWH!awO)3hP3oR2RNfu>#Dm&_G3JgnN$*%|V=2_^(+1X!tqqT8(4 zRKmgY_64P-94k%7Kkoqcj8r;5*`92A@nP=Yu^l7sYNNx##oW4guSO6`jz2I0=A#ttSbXj2Fivn6-4;}OmoLR zIXm;&>S57oG`S1Q3#S=C+N9IPQctOSFZoDfP-0AXGsQq+cP|7oNs`D#ypUWAER)b= zAyE|o_=1KSSXqG?_decfHRhyFQbe#2#%Hwus4~a&?>cAL$n1mh3~KI>k&~KPoj!YI zqG=fkfTJHiCW7(_OpPu2bcu??kd5N+-z2&Hf)2l>li6PO66M@Nu?36Zok5Qzh&8UR>4^waPT6Me@ei07UthipgS6>fYN zeaVGAa7W%KDk=)jO-BswGLWEia&xy(W%=MI&BkO5Bn;Nu8==Ryl1!;BUuaZCbJwN!6IQGHse-%$~7BWB)p#@gjVMtx0zeEqH52;T4)OYio~ zaARaW&(@M4sbjd)?SXY-Bq&hB^sC=KmbjT7)OH_!Mz{Pnp!(`x)=ji-PIh%Z8ld8` zIj`G$62~;PFw3k<8xJCll?~MOdQVRUEuum|YX(9j7)U_*$@oF>@5RE2pvNBdMFn;Q zepxawIWWzGCIK`Q7QB2*F2YQuUnGl$fe?@t#7F+tzEr-bK-=Joag!9;R!5cRT)d*u z?Y6Q>N6o?>zvJV>zGxPm9ZBO1Cp@6<-<)>l|03k2G;m4Ni4j^OmcHgB^eQp2Yt0Gz z7A>wu0*vJ_mjE=@2`2+?8AP4Iunz18G{vPOQ5{PClD}X=MyA}j)qzt7$sfIgr54l= zcnGffFWAa z*ZX<4+jqm)|>)4JI%#;TNB z_H07lCnG_}<0R-gNIwc#Y#iwVVP3c5<>u#?bv^F*QdHV0E*`7T-uW@9GnLPVk%=u2 zI5nsTA6a$(Wlji#1ArWaN06lK!L9J(1&&>3ECd)sQQSZ*-iVvZJYD~tz+(#10RZN( z(1IjMQ&LlfpDM8f9xdQ64sb4LU!W)lAKS5irU50lkPwq{o3lZ&{)9Jn=k|tkX-0iX z`s*4omM1Fo2^z1oa>lI$UG}KKVnB~jMrL^a;2EGsD1V-?67)W@_WJ%E{5l0qrEx&Y z_#F;OSDL$?IhdYf@1Hp=>WoN?owSq~c;B%49##p|^rfo$FZGODl9_XJ6_~If5Aut1 zK5-RLoZHv$@B`(dTBy;N!E+Bb&wcIas_hAQD~JgsHv?9Q+&E`vdu!)aAZWJ3m@Uy{ z=Pt41{xf1#eYF-P2n>MKbWo#hZEdSE69NgrBPb{jj$VkwSuVG|Jh}|Qyni z5(fSPg5|k!Hv1$4=W0gojt^W?!X@#=;SI8ZD4`&YiLf zzYZ*8Ich~Zb=D7$Bklv0UC7A6kSQOZl@#{RSNHd(3mHNi3k(nx6m8|_(ExkgFG0xW zsCtZS{D}-~{#7Z=Nj#H~fU!ZHs3-)OFkI+1Q!dy({}UW02LCUt zorPqrc~-L!AVA!AYg?ZHIZ(##U8S>6iUP^`(?b*pR)sb4F(Jl25Z`4>BTAdQy9GbW z-@h;ChVqSPZbO%+*zUQJAqSpzkpKGaQZuMp9MgPc;apGS@rr-RU3o~{bh&9T>32S3 zlxiEAupnL1aI6a@*~r&QZV!Cn2+N=!#Oyjvlx@q(tZ9lNt(%0g-cC@F~=w=ATa<34ETkF0`}y#L2;t6X8#_P1iN%~Cczw2Q;#`&U={8%_jYxmgQONd5p;|rNFD?| z`dJ7uU@0EH;t=(Zth#2LoS+*9s*jA!1eyYp#ekNM!y5?x3kSV8>xVNKh5uGr@Zba@ z*J%yr@vzJwm_*sZgi8?JEzS;1#8(!Ul>cUhpr+{CyIVx2XAKG!X^l>ewKX<)pY@Ku zFs;^hR8fXU=4FuvojMb!4NYa$36#KSW#W?#9)B7?HsTOYettAsJo~sX$Un3gNNJ5s zWKm^I)Oe+VuJE0HrM`0o^udtV0Ek>$f&%CWfO8jE^a!e{wtqqv1Ij5>Qz6OUi#65N)LQr^4Z@@f+tysTHxKdlE>xKlzm!{eQI;n0toQdScd0Xh zEjny=rFnawv)0?4-b14>m(^xen2#@{b34y-Lxp2Zb_}p*F$1XUxgi zrwMv|C$J5?=1RNGE!{3pXNqcH29PAT|B1V_@Z;2;Hd^`k9vSYucB{;bwNii2gn`qO z8cXNe8+b>QqIx6PoWWS@Ix_k8E2sa0=-<<2Vp1~7_4hH4Jl6;PWoZ*ZRH4o3FFq)K zh;?h&G5H>q$Gg;-nZ8?Gh@YD-<+f)|tQI`pKs*3+T=tC!>e3LP)z8}7p=n}6kSFQk z2G7uB7-NRTTI560ET)Q--*4~!*&opX+3jC3Z{Q<8fdKQ}V%+HF>aT!1Ktf>%B!SD) zjQjp_p^GqEZMU>VOEKgIk&xh$tAg+dmoimPrpnb7vV+R)wl#^&w>fqALtk52g+owo z7AQ=lzyk=1w$(Vn3U&seh_|dnIaO7BhhryRP#;>3h=_@E1}v&YG6vqvJnUi}OBd$q zv;tcMp;~P;J%LEI0}=%Px@8TI0n$KQfAR+jb6%cjhh494WY9lnC0prU6m?te?z|pj zI{#NyBknQj-soocRv}xJjwr!(SgLJNPBZ2h<>gDlLI-%V6w0{P-5 z059wPS%dJ9!;N2P6!$UY00q#UD#Z|?S@DT27ub0oA39W}YKy7}Cw}%fez#x71&XI7 z<9J}msqvzaBF1i8Rc{}*f^lmg`50Uxow}Yiz=finj@1Rl7l3I{%VA%O0fKsJND>Bq z>k5#tCDTyL=8OsOe;(c5ubt0*uMip*8qR>16aadkYsYlax_!> zHZ;ImfB#3Jd*qMUxNL6@Ktr?X!MX(~34%>T-!@e!;fYRSzB2s^aHoZw?KQf^P{A%i1V*lPOZ~UIZg1?Qi|cZ~bx|v3T{BkuYr^Ln&}&GQqx99F<^gz`7J;s1 zIs6%H>EXu!@1Mcn^T6Jn`lxe6)djgk(| zlJY>v10yI7V18VVK)r`U4yZ~p0BS9Wa85IxG-Xomoc0!|S)hLaGW01!W)N6eEl4|i zt>WbDjon36IXC2y0-nz8_D_?}e?2#lk{!qaVopj>r04p5Bx70@?QO~%xw!p=5bJXv z(KaY4K|`XLC&iqI52_@CZn%|z3D<@Dc;d?LC^5!W$)%Wx|n>O8S0fU8w>l zn%9i`LsNpcgJNtiX}R3Kp}$rldY@Ot`fsA=Sn;FgNMq%o_n^?#%7Q^LWf2j*bVo!} ziip;T*on`g*y2fsvrFUdrAkGhpy$GltSF@%ple=Kb*)RcOtJPo$br@ieeo(D`*tqg zB98(tDo`zeMQ4Ky2VSOSSSs*<1jHnJN1c>+OtI2OTwZbzV!-RpsL8QgP0D`tOp*M- z4!dN32lnVTg8T4-I26jbd!U>O#`QT4edKs{U=9cNb8Rh&dQZ<7D51b$3%@-87o~?} zPBG95qZN?X{G_ZZT{aoj4{JSLEzj-lYZht%=>`AQE_FP5yWDUBNHwyR1955!fkQfS zYLY5Ftjz3OMbv`Mm`d--BTsR!w!49 zwW<&-MFX3P@zhH5jGlc!ea@YdNR04qI$)8@ypF6deKu5VXa2hl?vk$lUTKJUrS}nE zU0p{BrY6A%;0cZBR)DZtct=xfDc$ZfT09LctsICu1Oe1%MydC7=z;GbZd&KD%vKvS zy!=Fl_I6Nnyh?vpF4zqKCxrY3Y7Pz#u_{mxLqJP#zeP}egMlG-^)x3eA?b7aj^>dM zfgzlpzF*NEh*v7mKn$sstrj({JiNj3bSN1rNrwM{G$l+iPmxLlxre-4JCVpPGGEB7M?(c7R@+a9V-JLraElDfwX8F-bX&Dcf zsaDQw*Cg!cwPszbdVKi|Z#YCiez>Aheev%Z=}Lsmdx6FaJ@&Tuh@tL$0{^O=-NrK$ z(Ny2xb+VJc;}T9$hH~D?=E$nNHuP%!;NkguaZBHs17+qZ6^`zXjf)o{6Q)VQ53Ao0iE-;iyRry}9y zOANMZIXd-D%x)TQ8bY)1yHcz^p{*!X{OVz>``=D150$!~mIp~Wy(2KEame>@OI62{ zTfc7rQCV*ug(yr^_nr!+kuXtGCzB3tP`paF{`H6En~PW>^ZMq~I`dD~@N8I!MIH25 z{Rq*1>xfQm{Bp>#f|2dW@+?!=5oLtryJF**iTHoo5+A(c-ij;LFm<>#c{J4L)$dFT zzBul~RL_5yes@_W<#XPCP`MJqi@ynrfk`~-N0!$QD~V5n0!D39@``+{JEzmyT+gcO z$ORP=5eNoib!F>qr)rMJDQnkp+?z&3j@VLNpZf($Rk$~@UJi_^-)#|+6f9TB@M^4W z)aHMixbf~&Wz?;_;ti6rZ+9~BU%Y+7=+Kw^_1ok3!^7--@uvF~0ud$z%1fPu=J#^& zGJka|-TLI^hL#r-9QeAhVKZG&e0k;Wvoq$Wd=h;U;@lrkKQ#`s;3m#k)Yxp0VQ!G$ z5xX-nXpk1| z>a<;OPDD)^lbx4+Uu;7nay#0q+qz=l_R?~AD6NOhpdLj*Y}S^MuBM@Nb((_3?toC| z*i^8~a)y!8l|chR$g>cOhPV7EXtyElHb%hh@7C|8AyXDcrioV3H_zjCZ25yGGg)`Iyl^wk=UTWJl-J8#sXKoe zqiSIHcPOC2!87b0T5F!Ul8bJTp_q-WIe9@`Rtt;7^=A9R;ruebR^6~|zq0HT#d$v^C@@gZ&&a5fNO2zp~2Ld5r>hu=N}KoPJ|5`YX*)PMRIcFj^A6$)_wPd9p04w z>X!GkJgU4|2PyJ`fi><8o@YDr4!rWT2AY~>8n_zFf*EyZVcXcxpP6vskmN;k_4t^I z`<)cKPi|-HIZRINUMn^CE&FM8 z2An41#N;m0ymaoKLYcEBvBMzj2HhLdj8EfiY^;kzUio~ihln7d_l)HQP5Y})DvalB zgR|E|^Ctakj{3q{qq`SdNz6fS?Yom%Z2wR`Gxj&RK zbVzF^zA082ni2P3*~mmk3sn1#l{jVWkfpJteNc|UT#r37Q$J}d&bgL`&y?Us?U zH)S>|jy@}zu4(3CBJ@oKTPpo^d+!rna8S|f6 zd{CY6Sk~~5T{xh=WtHt_XIPPKKO!Kc9N0NcX3c57Y(2fY^YOCbVY7Aj2RQ#KzAmo~7Jb6k!2OryIxfmRC4#H+>al7M zy{~w+{aK70uZ$haC-#~opVGRrH}Z-K&zYh+O>DO_aDL>{GZWmJik^rJy1;hhVV?cc zM#rvz@4xQQ$YW2RKkGV_@`r5pO2YeZJ9Qp@fyOHFK;79%Q^m@+t<8c=Kh2!sW$k%~ zF8|BbGl>_}p8NyL@H$94yOVkE#hd}Dg2*6AdJL}PE z^eP=TLnXOw`LklS>1N@=fJ&5A>OhWQxcTpZ;k=Rf<+#W{uMBR>e2>ee&ROqHv>K&P zNhoE%HY1`4>TpE={bIwV22!oY#1Ba z;X&HOf{y`rrX)8)W@SHg2*=37-Z`DYo3S7Q!IG0v#aCqm36LLe-^#;kTJYvQ-3pkT zaNZNVOF>0WT5>aYWJAfp$}-G_c$$kPw;;&dxVsl%hi?@g7%H0i`c3QkER`#f@GIgl z4ijOrXEvsoq!B8Ab*rsI+TWYXxMQJnoj;pA(E;`Fsk;gs@&q0r)T>}B7K_9m*TGrgt4-?=%KjisBc|vX1|v# z1(;S%8ff+Y{HV-ey0G%iBZuX-)R zob{yM#yOU+e)x80in&~xwjZ|7Ndrm0(4PLCC@<}<6yas`LFSH-W=zDsP$ddrEV zlBIbMroXZ8;c#Uy(`G9glZ|=Zwry~IcC?LI5^eYt$p2VM!M+nJ@jWm6_oKG_T1w1B z`jh>c1tWfR;VQNim&TaSi{{Ka_jLON&k^>mN7*cU7>Bs;7_RJjWDk>HR4;U0G)l~k~EqL_RVNHXt zp|F%aL&tk&QFDfk40f#s0sKdvH+BhgXtFR)5Pp>CcW~(kW&w4*hz$n>JLDT!A~tAb uu{`2*V3nW1I#D!_;gQn}&KC>{2N>!FRd(cyzWN5Vl)=;0&t;ucLK6V+=s$P> literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/previous-arrow.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/previous-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..347bc53474ce6f9246e45a2784623ac3c55203fa GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^AT|dF8<0HkD{mW+k}PqJC<)F_D=AMbN@Z|N$xljE z@XSq2PYp^(7*cU7>Bs;7_RM+{CQNw1Fo``;OomIOA;eyQoxxDq zqleYEkzs-s!=tK_vpODKLJPP=Hrzbak`ij8=UULpEv8e!aHP*6O-Z2sz)AtOhAwdi tO;?4yBLSV-6%OYZAAQ~MfRV$1!EulJ!>J6GyMcBxc)I$ztaD0e0sv`WKHvZV literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/search-icon.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/search-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..715f62d08b07f857b5866aadab38c9275c1c7513 GIT binary patch literal 340 zcmeAS@N?(olHy`uVBq!ia0vp^;y^6L!3HE_wj8emQjEnx?oJHr&dIz4a@dl*-CY>| zgW!U_%O?XxI14-?iy0WWg+Z8+Vb&Z8pdfpRr>`sf9Y#@6Www1Qyw!k0S3F%DLp+YZ zy<+I?6ez>`Aztf}Sn4}APCv){3l|=>Yl)V3lbRE=XyLww>=g=mre-ad1o$;s=E~eD z+1Y%=dExh#rt)dr&+9GQtIt35Z{zvT^t|GLxm`j3W0RKkh6mMWWjy3Aj!_ZROK!09 ztNWn5M@?|QQ%lvEHI1z2$~vEH`%o!!e`u6{1-oD!M<4CsTk literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/showHideTreeIcons.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/showHideTreeIcons.png new file mode 100644 index 0000000000000000000000000000000000000000..c1ec1f96a4c519610064feea6de06358e9f6e38a GIT binary patch literal 726 zcmV;{0xA88P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2igY> z6BZ`#&b%i800LG?L_t(Y$L-b2ZW2)($MNr6N{|8D3Y1Hs4@EXeks5%$)hVFkKicx7iruNhXt=oZtVGoO9+s+TNG1A|i+gzW?(r z;&VCo>%25YWQu^ooPi>ZYKsMQ;c$770xZ9<{Y za&RV{W_@jq+J2p0|9r0P^L-zuT0<$HaIF053r`_&Cm&Q{H+i}n| zol>cYVHoql>ual|Qz?#HE!v&VQa5(ux>Ov8(8>zsVgXIlX2aP`n!#Ym;n8uR&t)_k zQLER9MlBNY8?)il(=L`3A(==7fXLs^cFj7>-y*CeEhVB^3=@cQL(EGFNSj+i#gA^xvn=?v5V2@-~JyT1jz=0 z-v`KkSQhRWhVf$AEbx3$xCy)l?!;ozMYp;QyaDb$+P#1H11-^gON17#t^fc407*qo IM6N<$g5CR900000 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/sidebar.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/sidebar.png new file mode 100644 index 0000000000000000000000000000000000000000..5492671871c1fdb7c149bf233e34ebddd074c777 GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp@K+MU(1SHcW3~hmwWQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8U{4pvkcwMLbBxo^O;mQ5C}5VBp8e!WN?S`y%iQnt-qwGU z>u7lMf5n5>*VhX;sx9C%(%2aC{q^zkm`nHf)ixVQbn@6YFfcQ; Xxf$LLJ^5Y}Xgq_btDnm{r-UW|fBilp literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/starsSmall.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/images/starsSmall.png new file mode 100644 index 0000000000000000000000000000000000000000..490a27b9255075c8ce355aa3e36f89c82038b794 GIT binary patch literal 1032 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").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
        a",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="
        "+""+"
        ",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="
        t
        ",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
        ",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( +a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

        ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
        ";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,"
        ","
        "],thead:[1,"","
        "],tr:[2,"","
        "],td:[3,"","
        "],col:[2,"","
        "],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
        ","
        "]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f +.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
        ").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/jquery-ui-1.8.2.custom.min.js b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/jquery-ui-1.8.2.custom.min.js new file mode 100644 index 000000000000..fec53e8e08a1 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/jquery-ui-1.8.2.custom.min.js @@ -0,0 +1,321 @@ +/*! + * jQuery UI 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + */ +(function(c){c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.2",plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=0)&&c(a).is(":focusable")}})}})(jQuery); +;/*! + * jQuery UI Widget 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Widget + */ +(function(b){var j=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add(this).each(function(){b(this).triggerHandler("remove")});return j.call(b(this),a,c)})};b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend({},c.options);b[e][a].prototype= +b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.substring(0,1)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==undefined){h=i;return false}}):this.each(function(){var g= +b.data(this,a);if(g){d&&g.option(d);g._init()}else b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){this.element=b(c).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(c)[this.widgetName],a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create(); +this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a,e=this;if(arguments.length===0)return b.extend({},e.options);if(typeof a==="string"){if(c===undefined)return this.options[a];d={};d[a]=c}b.each(d,function(f, +h){e._setOption(f,h)});return e},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a= +b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery); +;/*! + * jQuery UI Mouse 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Mouse + * + * Depends: + * jquery.ui.widget.js + */ +(function(c){c.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(b){return a._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(a._preventClickEvent){a._preventClickEvent=false;b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&& +this._mouseUp(a);this._mouseDownEvent=a;var b=this,e=a.which==1,f=typeof this.options.cancel=="string"?c(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault(); +return true}}this._mouseMoveDelegate=function(d){return b._mouseMove(d)};this._mouseUpDelegate=function(d){return b._mouseUp(d)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);c.browser.safari||a.preventDefault();return a.originalEvent.mouseHandled=true}},_mouseMove:function(a){if(c.browser.msie&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&& +this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=a.target==this._mouseDownEvent.target;this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX- +a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery); +;/* + * jQuery UI Position 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Position + */ +(function(c){c.ui=c.ui||{};var m=/left|center|right/,n=/top|center|bottom/,p=c.fn.position,q=c.fn.offset;c.fn.position=function(a){if(!a||!a.of)return p.apply(this,arguments);a=c.extend({},a);var b=c(a.of),d=(a.collision||"flip").split(" "),e=a.offset?a.offset.split(" "):[0,0],g,h,i;if(a.of.nodeType===9){g=b.width();h=b.height();i={top:0,left:0}}else if(a.of.scrollTo&&a.of.document){g=b.width();h=b.height();i={top:b.scrollTop(),left:b.scrollLeft()}}else if(a.of.preventDefault){a.at="left top";g=h= +0;i={top:a.of.pageY,left:a.of.pageX}}else{g=b.outerWidth();h=b.outerHeight();i=b.offset()}c.each(["my","at"],function(){var f=(a[this]||"").split(" ");if(f.length===1)f=m.test(f[0])?f.concat(["center"]):n.test(f[0])?["center"].concat(f):["center","center"];f[0]=m.test(f[0])?f[0]:"center";f[1]=n.test(f[1])?f[1]:"center";a[this]=f});if(d.length===1)d[1]=d[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(a.at[0]==="right")i.left+=g;else if(a.at[0]==="center")i.left+= +g/2;if(a.at[1]==="bottom")i.top+=h;else if(a.at[1]==="center")i.top+=h/2;i.left+=e[0];i.top+=e[1];return this.each(function(){var f=c(this),k=f.outerWidth(),l=f.outerHeight(),j=c.extend({},i);if(a.my[0]==="right")j.left-=k;else if(a.my[0]==="center")j.left-=k/2;if(a.my[1]==="bottom")j.top-=l;else if(a.my[1]==="center")j.top-=l/2;j.left=parseInt(j.left);j.top=parseInt(j.top);c.each(["left","top"],function(o,r){c.ui.position[d[o]]&&c.ui.position[d[o]][r](j,{targetWidth:g,targetHeight:h,elemWidth:k, +elemHeight:l,offset:e,my:a.my,at:a.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(j,{using:a.using}))})};c.ui.position={fit:{left:function(a,b){var d=c(window);b=a.left+b.elemWidth-d.width()-d.scrollLeft();a.left=b>0?a.left-b:Math.max(0,a.left)},top:function(a,b){var d=c(window);b=a.top+b.elemHeight-d.height()-d.scrollTop();a.top=b>0?a.top-b:Math.max(0,a.top)}},flip:{left:function(a,b){if(b.at[0]!=="center"){var d=c(window);d=a.left+b.elemWidth-d.width()-d.scrollLeft();var e=b.my[0]==="left"? +-b.elemWidth:b.my[0]==="right"?b.elemWidth:0,g=-2*b.offset[0];a.left+=a.left<0?e+b.targetWidth+g:d>0?e-b.targetWidth+g:0}},top:function(a,b){if(b.at[1]!=="center"){var d=c(window);d=a.top+b.elemHeight-d.height()-d.scrollTop();var e=b.my[1]==="top"?-b.elemHeight:b.my[1]==="bottom"?b.elemHeight:0,g=b.at[1]==="top"?b.targetHeight:-b.targetHeight,h=-2*b.offset[1];a.top+=a.top<0?e+b.targetHeight+h:d>0?e+g+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(a,b){if(/static/.test(c.curCSS(a,"position")))a.style.position= +"relative";var d=c(a),e=d.offset(),g=parseInt(c.curCSS(a,"top",true),10)||0,h=parseInt(c.curCSS(a,"left",true),10)||0;e={top:b.top-e.top+g,left:b.left-e.left+h};"using"in b?b.using.call(a,e):d.css(e)};c.fn.offset=function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(){c.offset.setOffset(this,a)});return q.call(this)}}})(jQuery); +;/* + * jQuery UI Resizable 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Resizables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(d){d.widget("ui.resizable",d.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1E3},_create:function(){var b=this,a=this.options;this.element.addClass("ui-resizable");d.extend(this,{_aspectRatio:!!a.aspectRatio,aspectRatio:a.aspectRatio,originalElement:this.element, +_proportionallyResizeElements:[],_helper:a.helper||a.ghost||a.animate?a.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&d.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(d('
        ').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), +top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle= +this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!d(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne", +nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var e=0;e
        ');/sw|se|ne|nw/.test(g)&&f.css({zIndex:++a.zIndex});"se"==g&&f.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[g]=".ui-resizable-"+g;this.element.append(f)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor== +String)this.handles[i]=d(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=d(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}d(this.handles[i])}};this._renderAxis(this.element);this._handles=d(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();d(this.element).addClass("ui-resizable-autohide").hover(function(){d(this).removeClass("ui-resizable-autohide");b._handles.show()},function(){if(!b.resizing){d(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(c){d(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()}; +if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=false;for(var c in this.handles)if(d(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(), +e=this.element;this.resizing=true;this.documentScroll={top:d(document).scrollTop(),left:d(document).scrollLeft()};if(e.is(".ui-draggable")||/absolute/.test(e.css("position")))e.css({position:"absolute",top:c.top,left:c.left});d.browser.opera&&/relative/.test(e.css("position"))&&e.css({position:"relative",top:"auto",left:"auto"});this._renderProxy();c=m(this.helper.css("left"));var g=m(this.helper.css("top"));if(a.containment){c+=d(a.containment).scrollLeft()||0;g+=d(a.containment).scrollTop()||0}this.offset= +this.helper.offset();this.position={left:c,top:g};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:c,top:g};this.sizeDiff={width:e.outerWidth()-e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio: +this.originalSize.width/this.originalSize.height||1;a=d(".ui-resizable-"+this.axis).css("cursor");d("body").css("cursor",a=="auto"?this.axis+"-resize":a);e.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,e=this._change[this.axis];if(!e)return false;c=e.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize", +b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false},_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var e=this._proportionallyResizeElements,g=e.length&&/textarea/i.test(e[0].nodeName);e=g&&d.ui.hasScroll(e[0],"left")?0:c.sizeDiff.height; +g={width:c.size.width-(g?0:c.sizeDiff.width),height:c.size.height-e};e=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var f=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(d.extend(g,{top:f,left:e}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}d("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop", +b);this._helper&&this.helper.remove();return false},_updateCache:function(b){this.offset=this.helper.offset();if(k(b.left))this.position.left=b.left;if(k(b.top))this.position.top=b.top;if(k(b.height))this.size.height=b.height;if(k(b.width))this.size.width=b.width},_updateRatio:function(b){var a=this.position,c=this.size,e=this.axis;if(b.height)b.width=c.height*this.aspectRatio;else if(b.width)b.height=c.width/this.aspectRatio;if(e=="sw"){b.left=a.left+(c.width-b.width);b.top=null}if(e=="nw"){b.top= +a.top+(c.height-b.height);b.left=a.left+(c.width-b.width)}return b},_respectSize:function(b){var a=this.options,c=this.axis,e=k(b.width)&&a.maxWidth&&a.maxWidthb.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(f)b.width=a.minWidth;if(h)b.height=a.minHeight;if(e)b.width=a.maxWidth;if(g)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height, +l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(f&&l)b.left=i-a.minWidth;if(e&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(g&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left=null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=d.browser.msie&&d.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+ +a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+c}},se:function(b,a,c){return d.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return d.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return d.extend(this._change.n.apply(this, +arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return d.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){d.ui.plugin.call(this,b,[a,this.ui()]);b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});d.extend(d.ui.resizable, +{version:"1.8.2"});d.ui.plugin.add("resizable","alsoResize",{start:function(){var b=d(this).data("resizable").options,a=function(c){d(c).each(function(){d(this).data("resizable-alsoresize",{width:parseInt(d(this).width(),10),height:parseInt(d(this).height(),10),left:parseInt(d(this).css("left"),10),top:parseInt(d(this).css("top"),10)})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else d.each(b.alsoResize,function(c){a(c)}); +else a(b.alsoResize)},resize:function(){var b=d(this).data("resizable"),a=b.options,c=b.originalSize,e=b.originalPosition,g={height:b.size.height-c.height||0,width:b.size.width-c.width||0,top:b.position.top-e.top||0,left:b.position.left-e.left||0},f=function(h,i){d(h).each(function(){var j=d(this),l=d(this).data("resizable-alsoresize"),p={};d.each((i&&i.length?i:["width","height","top","left"])||["width","height","top","left"],function(n,o){if((n=(l[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(/relative/.test(j.css("position"))&& +d.browser.opera){b._revertToRelativePosition=true;j.css({position:"absolute",top:"auto",left:"auto"})}j.css(p)})};typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?d.each(a.alsoResize,function(h,i){f(h,i)}):f(a.alsoResize)},stop:function(){var b=d(this).data("resizable");if(b._revertToRelativePosition&&d.browser.opera){b._revertToRelativePosition=false;el.css({position:"relative"})}d(this).removeData("resizable-alsoresize-start")}});d.ui.plugin.add("resizable","animate",{stop:function(b){var a= +d(this).data("resizable"),c=a.options,e=a._proportionallyResizeElements,g=e.length&&/textarea/i.test(e[0].nodeName),f=g&&d.ui.hasScroll(e[0],"left")?0:a.sizeDiff.height;g={width:a.size.width-(g?0:a.sizeDiff.width),height:a.size.height-f};f=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(d.extend(g,h&&f?{top:h,left:f}:{}),{duration:c.animateDuration,easing:c.animateEasing, +step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};e&&e.length&&d(e[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});d.ui.plugin.add("resizable","containment",{start:function(){var b=d(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof d?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement= +d(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:d(document),left:0,top:0,width:d(document).width(),height:d(document).height()||document.body.parentNode.scrollHeight}}else{var e=d(a),g=[];d(["Top","Right","Left","Bottom"]).each(function(i,j){g[i]=m(e.css("padding"+j))});b.containerOffset=e.offset();b.containerPosition=e.position();b.containerSize={height:e.innerHeight()-g[3],width:e.innerWidth()-g[1]};c=b.containerOffset; +var f=b.containerSize.height,h=b.containerSize.width;h=d.ui.hasScroll(a,"left")?a.scrollWidth:h;f=d.ui.hasScroll(a)?a.scrollHeight:f;b.parentData={element:a,left:c.left,top:c.top,width:h,height:f}}}},resize:function(b){var a=d(this).data("resizable"),c=a.options,e=a.containerOffset,g=a.position;b=a._aspectRatio||b.shiftKey;var f={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))f=e;if(g.left<(a._helper?e.left:0)){a.size.width+=a._helper?a.position.left-e.left: +a.position.left-f.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?e.left:0}if(g.top<(a._helper?e.top:0)){a.size.height+=a._helper?a.position.top-e.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?e.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-f.left:a.offset.left-f.left)+a.sizeDiff.width);e=Math.abs((a._helper?a.offset.top-f.top:a.offset.top- +e.top)+a.sizeDiff.height);g=a.containerElement.get(0)==a.element.parent().get(0);f=/relative|absolute/.test(a.containerElement.css("position"));if(g&&f)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(e+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-e;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=d(this).data("resizable"),a=b.options,c=b.containerOffset,e=b.containerPosition, +g=b.containerElement,f=d(b.helper),h=f.offset(),i=f.outerWidth()-b.sizeDiff.width;f=f.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(g.css("position"))&&d(this).css({left:h.left-e.left-c.left,width:i,height:f});b._helper&&!a.animate&&/static/.test(g.css("position"))&&d(this).css({left:h.left-e.left-c.left,width:i,height:f})}});d.ui.plugin.add("resizable","ghost",{start:function(){var b=d(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25, +display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=d(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=d(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});d.ui.plugin.add("resizable","grid",{resize:function(){var b= +d(this).data("resizable"),a=b.options,c=b.size,e=b.originalSize,g=b.originalPosition,f=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-e.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-e.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(f)){b.size.width=e.width+h;b.size.height=e.height+a}else if(/^(ne)$/.test(f)){b.size.width=e.width+h;b.size.height=e.height+a;b.position.top=g.top-a}else{if(/^(sw)$/.test(f)){b.size.width=e.width+h;b.size.height= +e.height+a}else{b.size.width=e.width+h;b.size.height=e.height+a;b.position.top=g.top-a}b.position.left=g.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery); +; +/* + * jQuery UI Selectable 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Selectables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), +selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
        ")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({"z-index":100,position:"absolute",left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting"); +b.unselecting=true;f._trigger("unselecting",c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f= +this;this.dragged=true;if(!this.options.disabled){var d=this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({"z-index":100,position:"absolute",left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting"); +b.unselecting=true;f._trigger("unselecting",c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f= +this;this.dragged=true;if(!this.options.disabled){var d=this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom").addClass("ui-autocomplete").appendTo("body",c).mousedown(function(){setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(d,b){b=b.item.data("item.autocomplete"); +false!==a._trigger("focus",null,{item:b})&&/^key/.test(d.originalEvent.type)&&a.element.val(b.value)},selected:function(d,b){b=b.item.data("item.autocomplete");false!==a._trigger("select",d,{item:b})&&a.element.val(b.value);a.close(d);d=a.previous;if(a.element[0]!==c.activeElement){a.element.focus();a.previous=d}a.selectedItem=b},blur:function(){a.menu.element.is(":visible")&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");e.fn.bgiframe&&this.menu.element.bgiframe()}, +destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();e.Widget.prototype.destroy.call(this)},_setOption:function(a){e.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource()},_initSource:function(){var a,c;if(e.isArray(this.options.source)){a=this.options.source;this.source=function(d,b){b(e.ui.autocomplete.filter(a,d.term))}}else if(typeof this.options.source=== +"string"){c=this.options.source;this.source=function(d,b){e.getJSON(c,d,b)}}else this.source=this.options.source},search:function(a,c){a=a!=null?a:this.element.val();if(a.length").data("item.autocomplete", +c).append(""+c.label+"").appendTo(a)},_move:function(a,c){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](c);else this.search(null,c)},widget:function(){return this.menu.element}});e.extend(e.ui.autocomplete,{escapeRegex:function(a){return a.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")},filter:function(a,c){var d=new RegExp(e.ui.autocomplete.escapeRegex(c), +"i");return e.grep(a,function(b){return d.test(b.label||b.value||b)})}})})(jQuery); +(function(e){e.widget("ui.menu",{_create:function(){var a=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(e(c.target).closest(".ui-menu-item a").length){c.preventDefault();a.select(c)}});this.refresh()},refresh:function(){var a=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", +-1).mouseenter(function(c){a.activate(c,e(this).parent())}).mouseleave(function(){a.deactivate()})},activate:function(a,c){this.deactivate();if(this.hasScroll()){var d=c.offset().top-this.element.offset().top,b=this.element.attr("scrollTop"),f=this.element.height();if(d<0)this.element.attr("scrollTop",b+d);else d>f&&this.element.attr("scrollTop",b+d-f+c.height())}this.active=c.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",a,{item:c})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id"); +this._trigger("blur");this.active=null}},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prev().length},last:function(){return this.active&&!this.active.next().length},move:function(a,c,d){if(this.active){a=this.active[a+"All"](".ui-menu-item").eq(0);a.length?this.activate(d,a):this.activate(d,this.element.children(c))}else this.activate(d,this.element.children(c))},nextPage:function(a){if(this.hasScroll())if(!this.active|| +this.last())this.activate(a,this.element.children(":first"));else{var c=this.active.offset().top,d=this.element.height(),b=this.element.children("li").filter(function(){var f=e(this).offset().top-c-d+e(this).height();return f<10&&f>-10});b.length||(b=this.element.children(":last"));this.activate(a,b)}else this.activate(a,this.element.children(!this.active||this.last()?":first":":last"))},previousPage:function(a){if(this.hasScroll())if(!this.active||this.first())this.activate(a,this.element.children(":last")); +else{var c=this.active.offset().top,d=this.element.height();result=this.element.children("li").filter(function(){var b=e(this).offset().top-c+d-e(this).height();return b<10&&b>-10});result.length||(result=this.element.children(":first"));this.activate(a,result)}else this.activate(a,this.element.children(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()").addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary;if(d.primary||d.secondary){b.addClass("ui-button-text-icon"+(e?"s":""));d.primary&&b.prepend("");d.secondary&&b.append("");if(!this.options.text){b.addClass(e?"ui-button-icons-only":"ui-button-icon-only").removeClass("ui-button-text-icons ui-button-text-icon"); +this.hasTitle||b.attr("title",c)}}else b.addClass("ui-button-text-only")}}});a.widget("ui.buttonset",{_create:function(){this.element.addClass("ui-buttonset");this._init()},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c);a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){this.buttons=this.element.find(":button, :submit, :reset, :checkbox, :radio, a, :data(button)").filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass("ui-corner-left").end().filter(":last").addClass("ui-corner-right").end().end()}, +destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");a.Widget.prototype.destroy.call(this)}})})(jQuery); +;/* + * jQuery UI Dialog 1.8.2 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Dialog + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.button.js + * jquery.ui.draggable.js + * jquery.ui.mouse.js + * jquery.ui.position.js + * jquery.ui.resizable.js + */ +(function(c){c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:"center",resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");var a=this,b=a.options,d=b.title||a.originalTitle||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("
        ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ +b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("
        ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g), +h=c('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("").addClass("ui-dialog-title").attr("id", +e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"); +a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!== +b.uiDialog[0])d=Math.max(d,c(this).css("z-index"))});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.attr("scrollTop"),scrollLeft:d.element.attr("scrollLeft")};c.ui.dialog.maxZ+=1;d.uiDialog.css("z-index", +c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;d.next().length&&d.appendTo("body");a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target=== +f[0]&&e.shiftKey){g.focus(1);return false}}});c([]).add(d.find(".ui-dialog-content :tabbable:first")).add(d.find(".ui-dialog-buttonpane :tabbable:first")).add(d).filter(":first").focus();a._trigger("open");a._isOpen=true;return a}},_createButtons:function(a){var b=this,d=false,e=c("
        ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,function(){return!(d=true)});if(d){c.each(a, +function(g,f){g=c('').text(g).click(function(){f.apply(b.element[0],arguments)}).appendTo(e);c.fn.button&&g.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging"); +b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,originalSize:f.originalSize,position:f.position,size:f.size}}a=a===undefined?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position"); +a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop", +f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0];a=a||c.ui.dialog.prototype.options.position;if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(e,g){if(+b[e]===b[e]){d[e]=b[e];b[e]= +g}})}else if(typeof a==="object"){if("left"in a){b[0]="left";d[0]=a.left}else if("right"in a){b[0]="right";d[0]=-a.right}if("top"in a){b[1]="top";d[1]=a.top}else if("bottom"in a){b[1]="bottom";d[1]=-a.bottom}}(a=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position({my:b.join(" "),at:b.join(" "),offset:d.join(" "),of:window,collision:"fit",using:function(e){var g=c(this).css(e).offset().top;g<0&&c(this).css("top",e.top-g)}});a||this.uiDialog.hide()},_setOption:function(a, +b){var d=this,e=d.uiDialog,g=e.is(":data(resizable)"),f=false;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):e.removeClass("ui-dialog-disabled");break;case "draggable":b?d._makeDraggable():e.draggable("destroy");break; +case "height":f=true;break;case "maxHeight":g&&e.resizable("option","maxHeight",b);f=true;break;case "maxWidth":g&&e.resizable("option","maxWidth",b);f=true;break;case "minHeight":g&&e.resizable("option","minHeight",b);f=true;break;case "minWidth":g&&e.resizable("option","minWidth",b);f=true;break;case "position":d._position(b);break;case "resizable":g&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title", +d.uiDialogTitlebar).html(""+(b||" "));break;case "width":f=true;break}c.Widget.prototype._setOption.apply(d,arguments);f&&d._size()},_size:function(){var a=this.options,b;this.element.css({width:"auto",minHeight:0,height:0});b=this.uiDialog.css({height:"auto",width:a.width}).height();this.element.css(a.height==="auto"?{minHeight:Math.max(a.minHeight-b,0),height:"auto"}:{minHeight:0,height:Math.max(a.height-b,0)}).show();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight", +this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.2",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&& +c(document).bind(c.ui.dialog.overlay.events,function(d){return c(d.target).zIndex()>=c.ui.dialog.overlay.maxZ})},1);c(document).bind("keydown.dialog-overlay",function(d){if(a.options.closeOnEscape&&d.keyCode&&d.keyCode===c.ui.keyCode.ESCAPE){a.close(d);d.preventDefault()}});c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize)}var b=(this.oldInstances.pop()||c("
        ").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&& +b.bgiframe();this.instances.push(b);return b},destroy:function(a){this.oldInstances.push(this.instances.splice(c.inArray(a,this.instances),1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var b=0;c.each(this.instances,function(){b=Math.max(b,this.css("z-index"))});this.maxZ=b},height:function(){var a,b;if(c.browser.msie&&c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);b=Math.max(document.documentElement.offsetHeight, +document.body.offsetHeight);return a",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:'
      • #{label}
      • '},_create:function(){this._tabify(true)},_setOption:function(c,e){if(c=="selected")this.options.collapsible&& +e==this.options.selected||this.select(e);else{this.options[c]=e;this._tabify()}},_tabId:function(c){return c.title&&c.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+s()},_sanitizeSelector:function(c){return c.replace(/:/g,"\\:")},_cookie:function(){var c=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+v());return d.cookie.apply(null,[c].concat(d.makeArray(arguments)))},_ui:function(c,e){return{tab:c,panel:e,index:this.anchors.index(c)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var c= +d(this);c.html(c.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function e(g,f){g.css({display:""});!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}this.list=this.element.find("ol,ul").eq(0);this.lis=d("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);var a=this,b=this.options,h=/^#.+/;this.anchors.each(function(g,f){var j=d(f).attr("href"),l=j.split("#")[0],p;if(l&&(l===location.toString().split("#")[0]|| +(p=d("base")[0])&&l===p.href)){j=f.hash;f.href=j}if(h.test(j))a.panels=a.panels.add(a._sanitizeSelector(j));else if(j!="#"){d.data(f,"href.tabs",j);d.data(f,"load.tabs",j.replace(/#.*$/,""));j=a._tabId(f);f.href="#"+j;f=d("#"+j);if(!f.length){f=d(b.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else b.disabled.push(g)});if(c){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); +this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(b.selected===undefined){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){b.selected=g;return false}});if(typeof b.selected!="number"&&b.cookie)b.selected=parseInt(a._cookie(),10);if(typeof b.selected!="number"&&this.lis.filter(".ui-tabs-selected").length)b.selected= +this.lis.index(this.lis.filter(".ui-tabs-selected"));b.selected=b.selected||(this.lis.length?0:-1)}else if(b.selected===null)b.selected=-1;b.selected=b.selected>=0&&this.anchors[b.selected]||b.selected<0?b.selected:0;b.disabled=d.unique(b.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(b.selected,b.disabled)!=-1&&b.disabled.splice(d.inArray(b.selected,b.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); +if(b.selected>=0&&this.anchors.length){this.panels.eq(b.selected).removeClass("ui-tabs-hide");this.lis.eq(b.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[b.selected],a.panels[b.selected]))});this.load(b.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else b.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));this.element[b.collapsible?"addClass": +"removeClass"]("ui-tabs-collapsible");b.cookie&&this._cookie(b.selected,b.cookie);c=0;for(var i;i=this.lis[c];c++)d(i)[d.inArray(c,b.disabled)!=-1&&!d(i).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");b.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(b.event!="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+g)};this.lis.bind("mouseover.tabs", +function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(b.fx)if(d.isArray(b.fx)){m=b.fx[0];o=b.fx[1]}else m=o=b.fx;var q=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",function(){e(f,o);a._trigger("show", +null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},r=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};this.anchors.bind(b.event+".tabs", +function(){var g=this,f=d(this).closest("li"),j=a.panels.filter(":not(.ui-tabs-hide)"),l=d(a._sanitizeSelector(this.hash));if(f.hasClass("ui-tabs-selected")&&!b.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}b.selected=a.anchors.index(this);a.abort();if(b.collapsible)if(f.hasClass("ui-tabs-selected")){b.selected=-1;b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){r(g, +j)}).dequeue("tabs");this.blur();return false}else if(!j.length){b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this));this.blur();return false}b.cookie&&a._cookie(b.selected,b.cookie);if(l.length){j.length&&a.element.queue("tabs",function(){r(g,j)});a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";d.browser.msie&&this.blur()});this.anchors.bind("click.tabs", +function(){return false})},destroy:function(){var c=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(b,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this, +"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});c.cookie&&this._cookie(null,c.cookie);return this},add:function(c,e,a){if(a===undefined)a=this.anchors.length;var b=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,e));c=!c.indexOf("#")?c.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs", +true);var i=d("#"+c);i.length||(i=d(h.panelTemplate).attr("id",c).data("destroy.tabs",true));i.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);i.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);i.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");i.removeClass("ui-tabs-hide"); +this.element.queue("tabs",function(){b._trigger("show",null,b._ui(b.anchors[0],b.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(c){var e=this.options,a=this.lis.eq(c).remove(),b=this.panels.eq(c).remove();if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(c+(c+1=c?--h:h});this._tabify();this._trigger("remove", +null,this._ui(a.find("a")[0],b[0]));return this},enable:function(c){var e=this.options;if(d.inArray(c,e.disabled)!=-1){this.lis.eq(c).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=c});this._trigger("enable",null,this._ui(this.anchors[c],this.panels[c]));return this}},disable:function(c){var e=this.options;if(c!=e.selected){this.lis.eq(c).addClass("ui-state-disabled");e.disabled.push(c);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[c],this.panels[c]))}return this}, +select:function(c){if(typeof c=="string")c=this.anchors.index(this.anchors.filter("[href$="+c+"]"));else if(c===null)c=-1;if(c==-1&&this.options.collapsible)c=this.options.selected;this.anchors.eq(c).trigger(this.options.event+".tabs");return this},load:function(c){var e=this,a=this.options,b=this.anchors.eq(c)[0],h=d.data(b,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(b,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(c).addClass("ui-state-processing"); +if(a.spinner){var i=d("span",b);i.data("label.tabs",i.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){d(e._sanitizeSelector(b.hash)).html(k);e._cleanup();a.cache&&d.data(b,"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.error(k,n,c,b)}catch(m){}}}));e.element.dequeue("tabs");return this}}, +abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},url:function(c,e){this.anchors.eq(c).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.2"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(c,e){var a=this,b=this.options,h=a._rotate||(a._rotate= +function(i){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=b.selected;a.select(++k").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});c.wrap(b);b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(d,e){a[e]=c.css(e);if(isNaN(parseInt(a[e],10)))a[e]="auto"}); +c.css({position:"relative",top:0,left:0})}return b.css(a).show()},removeWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent().replaceWith(c);return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=j.apply(this,arguments);a={options:a[1],duration:a[2],callback:a[3]};var b=f.effects[c];return b&&!f.fx.off?b.call(this,a):this},_show:f.fn.show,show:function(c){if(!c|| +typeof c=="number"||f.fx.speeds[c])return this._show.apply(this,arguments);else{var a=j.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(!c||typeof c=="number"||f.fx.speeds[c])return this._hide.apply(this,arguments);else{var a=j.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(!c||typeof c=="number"||f.fx.speeds[c]||typeof c=="boolean"||f.isFunction(c))return this.__toggle.apply(this, +arguments);else{var a=j.apply(this,arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c, +a,b,d,e){if((a/=e/2)<1)return d/2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+ +b},easeInQuint:function(c,a,b,d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2, +10*(a/e-1))+b},easeOutExpo:function(c,a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)* +a)+1)+b},easeInElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(b(this).offset()).appendTo("body")});return!0},_mouseStart:function(a){var c=this.options;this.helper=this._createHelper(a);this._cacheHelperProportions();b.ui.ddmanager&&(b.ui.ddmanager.current=this); +this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};b.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY= +a.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);c.containment&&this._setContainment();if(!1===this._trigger("start",a))return this._clear(),!1;this._cacheHelperProportions();b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,!0);b.ui.ddmanager&&b.ui.ddmanager.dragStart(this,a);return!0},_mouseDrag:function(a,c){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute"); +if(!c){var d=this._uiHash();if(!1===this._trigger("drag",a,d))return this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||"y"!=this.options.axis)this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||"x"!=this.options.axis)this.helper[0].style.top=this.position.top+"px";b.ui.ddmanager&&b.ui.ddmanager.drag(this,a);return!1},_mouseStop:function(a){var c=!1;b.ui.ddmanager&&!this.options.dropBehaviour&&(c=b.ui.ddmanager.drop(this,a));this.dropped&&(c=this.dropped,this.dropped= +!1);if((!this.element[0]||!this.element[0].parentNode)&&"original"==this.options.helper)return!1;if("invalid"==this.options.revert&&!c||"valid"==this.options.revert&&c||!0===this.options.revert||b.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var d=this;b(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){d._trigger("stop",a)!==false&&d._clear()})}else!1!==this._trigger("stop",a)&&this._clear();return!1},_mouseUp:function(a){!0=== +this.options.iframeFix&&b("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});b.ui.ddmanager&&b.ui.ddmanager.dragStop(this,a);return b.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var c=!this.options.handle||!b(this.options.handle,this.element).length?!0:!1;b(this.options.handle,this.element).find("*").andSelf().each(function(){this==a.target&&(c= +!0)});return c},_createHelper:function(a){var c=this.options,a=b.isFunction(c.helper)?b(c.helper.apply(this.element[0],[a])):"clone"==c.helper?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo("parent"==c.appendTo?this.element[0].parentNode:c.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){"string"==typeof a&&(a=a.split(" "));b.isArray(a)&&(a={left:+a[0],top:+a[1]|| +0});"left"in a&&(this.offset.click.left=a.left+this.margins.left);"right"in a&&(this.offset.click.left=this.helperProportions.width-a.right+this.margins.left);"top"in a&&(this.offset.click.top=a.top+this.margins.top);"bottom"in a&&(this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();"absolute"==this.cssPosition&&(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0], +this.offsetParent[0]))&&(a.left+=this.scrollParent.scrollLeft(),a.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&b.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var b=this.element.position();return{top:b.top- +(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(), +height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;"parent"==a.containment&&(a.containment=this.helper[0].parentNode);if("document"==a.containment||"window"==a.containment)this.containment=["document"==a.containment?0:b(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,"document"==a.containment?0:b(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,("document"==a.containment?0:b(window).scrollLeft())+b("document"==a.containment?document: +window).width()-this.helperProportions.width-this.margins.left,("document"==a.containment?0:b(window).scrollTop())+(b("document"==a.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){var a=b(a.containment),c=a[0];if(c){a.offset();var d="hidden"!=b(c).css("overflow");this.containment=[(parseInt(b(c).css("borderLeftWidth"),10)||0)+(parseInt(b(c).css("paddingLeft"), +10)||0),(parseInt(b(c).css("borderTopWidth"),10)||0)+(parseInt(b(c).css("paddingTop"),10)||0),(d?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(b(c).css("borderLeftWidth"),10)||0)-(parseInt(b(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(d?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(b(c).css("borderTopWidth"),10)||0)-(parseInt(b(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom]; +this.relative_container=a}}else a.containment.constructor==Array&&(this.containment=a.containment)},_convertPositionTo:function(a,c){c||(c=this.position);var d="absolute"==a?1:-1,g="absolute"==this.cssPosition&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,h=/(html|body)/i.test(g[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition? +0:("fixed"==this.cssPosition?-this.scrollParent.scrollTop():h?0:g.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():h?0:g.scrollLeft())*d)}},_generatePosition:function(a){var c=this.options,d="absolute"==this.cssPosition&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent, +g=/(html|body)/i.test(d[0].tagName),h=a.pageX,e=a.pageY;if(this.originalPosition){var f;this.containment&&(this.relative_container?(f=this.relative_container.offset(),f=[this.containment[0]+f.left,this.containment[1]+f.top,this.containment[2]+f.left,this.containment[3]+f.top]):f=this.containment,a.pageX-this.offset.click.leftf[2]&&(h=f[2]+this.offset.click.left), +a.pageY-this.offset.click.top>f[3]&&(e=f[3]+this.offset.click.top));c.grid&&(e=c.grid[1]?this.originalPageY+Math.round((e-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY,e=f?!(e-this.offset.click.topf[3])?e:!(e-this.offset.click.topf[2])?h:!(h-this.offset.click.left< +f[0])?h-c.grid[0]:h+c.grid[0]:h)}return{top:e-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollTop():g?0:d.scrollTop()),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollLeft():g?0:d.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"); +this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=!1},_trigger:function(a,c,d){d=d||this._uiHash();b.ui.plugin.call(this,a,[c,d]);"drag"==a&&(this.positionAbs=this._convertPositionTo("absolute"));return b.Widget.prototype._trigger.call(this,a,c,d)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});b.extend(b.ui.draggable,{version:"1.8.14"}); +b.ui.plugin.add("draggable","connectToSortable",{start:function(a,c){var d=b(this).data("draggable"),g=d.options,h=b.extend({},c,{item:d.element});d.sortables=[];b(g.connectToSortable).each(function(){var c=b.data(this,"sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",a,h))})},stop:function(a,c){var d=b(this).data("draggable"),g=b.extend({},c,{item:d.element});b.each(d.sortables,function(){this.instance.isOver? +(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(a),this.instance.options.helper=this.instance.options._helper,"original"==d.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",a,g))})},drag:function(a,c){var d=b(this).data("draggable"),g=this;b.each(d.sortables,function(){this.instance.positionAbs= +d.positionAbs;this.instance.helperProportions=d.helperProportions;this.instance.offset.click=d.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=b(g).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return c.helper[0]},a.target=this.instance.currentItem[0],this.instance._mouseCapture(a, +!0),this.instance._mouseStart(a,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",a),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(a)):this.instance.isOver&& +(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",a,this.instance._uiHash(this.instance)),this.instance._mouseStop(a,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",a),d.dropped=!1)})}});b.ui.plugin.add("draggable","cursor",{start:function(){var a=b("body"),c=b(this).data("draggable").options; +a.css("cursor")&&(c._cursor=a.css("cursor"));a.css("cursor",c.cursor)},stop:function(){var a=b(this).data("draggable").options;a._cursor&&b("body").css("cursor",a._cursor)}});b.ui.plugin.add("draggable","opacity",{start:function(a,c){var d=b(c.helper),g=b(this).data("draggable").options;d.css("opacity")&&(g._opacity=d.css("opacity"));d.css("opacity",g.opacity)},stop:function(a,c){var d=b(this).data("draggable").options;d._opacity&&b(c.helper).css("opacity",d._opacity)}});b.ui.plugin.add("draggable", +"scroll",{start:function(){var a=b(this).data("draggable");a.scrollParent[0]!=document&&"HTML"!=a.scrollParent[0].tagName&&(a.overflowOffset=a.scrollParent.offset())},drag:function(a){var c=b(this).data("draggable"),d=c.options,g=!1;if(c.scrollParent[0]!=document&&"HTML"!=c.scrollParent[0].tagName){if(!d.axis||"x"!=d.axis)c.overflowOffset.top+c.scrollParent[0].offsetHeight-a.pageY=k&&e<=l||f>=k&&f<=l||el)&&(g>=i&&g<=j||h>=i&&h<=j||gj);default:return!1}}; +b.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,c){var d=b.ui.ddmanager.droppables[a.options.scope]||[],g=c?c.type:null,h=(a.currentItem||a.element).find(":data(droppable)").andSelf(),e=0;a:for(;e').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})), +this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize", +"none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize());this.handles=a.handles||(!b(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){"all"== +this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw");var h=this.handles.split(",");this.handles={};for(var e=0;e');/sw|se|ne|nw/.test(f)&&i.css({zIndex:++a.zIndex});"se"==f&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(i)}}this._renderAxis=function(f){var f=f||this.element,c;for(c in this.handles){this.handles[c].constructor==String&&(this.handles[c]= +b(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var a=b(this.handles[c],this.element),d=0,d=/sw|ne|nw|se|n|s/.test(c)?a.outerHeight():a.outerWidth(),a=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");f.css(a,d);this._proportionallyResize()}b(this.handles[c])}};this._renderAxis(this.element);this._handles=b(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!c.resizing){if(this.className)var b=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);c.axis=b&&b[1]?b[1]:"se"}});a.autoHide&&(this._handles.hide(),b(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){b(this).removeClass("ui-resizable-autohide");c._handles.show()}},function(){if(!a.disabled&&!c.resizing){b(this).addClass("ui-resizable-autohide");c._handles.hide()}}));this._mouseInit()},destroy:function(){this._mouseDestroy(); +var c=function(c){b(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){c(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);c(this.originalElement);return this},_mouseCapture:function(c){var a= +!1,h;for(h in this.handles)b(this.handles[h])[0]==c.target&&(a=!0);return!this.options.disabled&&a},_mouseStart:function(c){var g=this.options,h=this.element.position(),e=this.element;this.resizing=!0;this.documentScroll={top:b(document).scrollTop(),left:b(document).scrollLeft()};(e.is(".ui-draggable")||/absolute/.test(e.css("position")))&&e.css({position:"absolute",top:h.top,left:h.left});b.browser.opera&&/relative/.test(e.css("position"))&&e.css({position:"relative",top:"auto",left:"auto"});this._renderProxy(); +var h=a(this.helper.css("left")),f=a(this.helper.css("top"));g.containment&&(h+=b(g.containment).scrollLeft()||0,f+=b(g.containment).scrollTop()||0);this.offset=this.helper.offset();this.position={left:h,top:f};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:h,top:f};this.sizeDiff={width:e.outerWidth()- +e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:c.pageX,top:c.pageY};this.aspectRatio="number"==typeof g.aspectRatio?g.aspectRatio:this.originalSize.width/this.originalSize.height||1;g=b(".ui-resizable-"+this.axis).css("cursor");b("body").css("cursor","auto"==g?this.axis+"-resize":g);e.addClass("ui-resizable-resizing");this._propagate("start",c);return!0},_mouseDrag:function(b){var c=this.helper,a=this.originalMousePosition,e=this._change[this.axis];if(!e)return!1;a= +e.apply(this,[b,b.pageX-a.left||0,b.pageY-a.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)a=this._updateRatio(a,b);a=this._respectSize(a,b);this._propagate("resize",b);c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(a);this._trigger("resize",b,this.ui());return!1},_mouseStop:function(c){this.resizing= +!1;var a=this.options;if(this._helper){var h=this._proportionallyResizeElements,e=h.length&&/textarea/i.test(h[0].nodeName),h=e&&b.ui.hasScroll(h[0],"left")?0:this.sizeDiff.height,e=e?0:this.sizeDiff.width,e={width:this.helper.width()-e,height:this.helper.height()-h},h=parseInt(this.element.css("left"),10)+(this.position.left-this.originalPosition.left)||null,f=parseInt(this.element.css("top"),10)+(this.position.top-this.originalPosition.top)||null;a.animate||this.element.css(b.extend(e,{top:f,left:h})); +this.helper.height(this.size.height);this.helper.width(this.size.width);this._helper&&!a.animate&&this._proportionallyResize()}b("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",c);this._helper&&this.helper.remove();return!1},_updateVirtualBoundaries:function(b){var a=this.options,h,e,f,a={minWidth:c(a.minWidth)?a.minWidth:0,maxWidth:c(a.maxWidth)?a.maxWidth:Infinity,minHeight:c(a.minHeight)?a.minHeight:0,maxHeight:c(a.maxHeight)?a.maxHeight:Infinity}; +if(this._aspectRatio||b)if(b=a.minHeight*this.aspectRatio,e=a.minWidth/this.aspectRatio,h=a.maxHeight*this.aspectRatio,f=a.maxWidth/this.aspectRatio,b>a.minWidth&&(a.minWidth=b),e>a.minHeight&&(a.minHeight=e),hb.width,j=c(b.height)&&a.minHeight&&a.minHeight> +b.height;i&&(b.width=a.minWidth);j&&(b.height=a.minHeight);e&&(b.width=a.maxWidth);f&&(b.height=a.maxHeight);var k=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,m=/sw|nw|w/.test(h),h=/nw|ne|n/.test(h);i&&m&&(b.left=k-a.minWidth);e&&m&&(b.left=k-a.maxWidth);j&&h&&(b.top=l-a.minHeight);f&&h&&(b.top=l-a.maxHeight);(a=!b.width&&!b.height)&&!b.left&&b.top?b.top=null:a&&(!b.top&&b.left)&&(b.left=null);return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var c= +this.helper||this.element,a=0;a');var a=b.browser.msie&&7>b.browser.version,h=a?1:0,a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-h+"px",top:this.elementOffset.top- +h+"px",zIndex:++c.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,c){return{width:this.originalSize.width+c}},w:function(b,c){return{left:this.originalPosition.left+c,width:this.originalSize.width-c}},n:function(b,c,a){return{top:this.originalPosition.top+a,height:this.originalSize.height-a}},s:function(b,c,a){return{height:this.originalSize.height+a}},se:function(c,a,h){return b.extend(this._change.s.apply(this,arguments),this._change.e.apply(this, +[c,a,h]))},sw:function(c,a,h){return b.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[c,a,h]))},ne:function(c,a,h){return b.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[c,a,h]))},nw:function(c,a,h){return b.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[c,a,h]))}},_propagate:function(c,a){b.ui.plugin.call(this,c,[a,this.ui()]);"resize"!=c&&this._trigger(c,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement, +element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});b.extend(b.ui.resizable,{version:"1.8.14"});b.ui.plugin.add("resizable","alsoResize",{start:function(){var c=b(this).data("resizable").options,a=function(c){b(c).each(function(){var c=b(this);c.data("resizable-alsoresize",{width:parseInt(c.width(),10),height:parseInt(c.height(),10),left:parseInt(c.css("left"),10),top:parseInt(c.css("top"),10),position:c.css("position")})})}; +"object"==typeof c.alsoResize&&!c.alsoResize.parentNode?c.alsoResize.length?(c.alsoResize=c.alsoResize[0],a(c.alsoResize)):b.each(c.alsoResize,function(b){a(b)}):a(c.alsoResize)},resize:function(c,a){var h=b(this).data("resizable"),e=h.options,f=h.originalSize,i=h.originalPosition,j={height:h.size.height-f.height||0,width:h.size.width-f.width||0,top:h.position.top-i.top||0,left:h.position.left-i.left||0},k=function(c,f){b(c).each(function(){var c=b(this),d=b(this).data("resizable-alsoresize"),i={}, +e=f&&f.length?f:c.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];b.each(e,function(b,c){var a=(d[c]||0)+(j[c]||0);a&&0<=a&&(i[c]=a||null)});b.browser.opera&&/relative/.test(c.css("position"))&&(h._revertToRelativePosition=!0,c.css({position:"absolute",top:"auto",left:"auto"}));c.css(i)})};"object"==typeof e.alsoResize&&!e.alsoResize.nodeType?b.each(e.alsoResize,function(b,c){k(b,c)}):k(e.alsoResize)},stop:function(){var c=b(this).data("resizable"),a=c.options, +h=function(c){b(c).each(function(){var c=b(this);c.css({position:c.data("resizable-alsoresize").position})})};c._revertToRelativePosition&&(c._revertToRelativePosition=!1,"object"==typeof a.alsoResize&&!a.alsoResize.nodeType?b.each(a.alsoResize,function(b){h(b)}):h(a.alsoResize));b(this).removeData("resizable-alsoresize")}});b.ui.plugin.add("resizable","animate",{stop:function(c){var a=b(this).data("resizable"),h=a.options,e=a._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName), +i=f&&b.ui.hasScroll(e[0],"left")?0:a.sizeDiff.height,f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-i},i=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null,j=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(b.extend(f,j&&i?{top:j,left:i}:{}),{duration:h.animateDuration,easing:h.animateEasing,step:function(){var f={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10), +top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};e&&e.length&&b(e[0]).css({width:f.width,height:f.height});a._updateCache(f);a._propagate("resize",c)}})}});b.ui.plugin.add("resizable","containment",{start:function(){var c=b(this).data("resizable"),g=c.element,h=c.options.containment;if(g=h instanceof b?h.get(0):/parent/.test(h)?g.parent().get(0):h)if(c.containerElement=b(g),/document/.test(h)||h==document)c.containerOffset={left:0,top:0},c.containerPosition={left:0,top:0}, +c.parentData={element:b(document),left:0,top:0,width:b(document).width(),height:b(document).height()||document.body.parentNode.scrollHeight};else{var e=b(g),f=[];b(["Top","Right","Left","Bottom"]).each(function(b,c){f[b]=a(e.css("padding"+c))});c.containerOffset=e.offset();c.containerPosition=e.position();c.containerSize={height:e.innerHeight()-f[3],width:e.innerWidth()-f[1]};var h=c.containerOffset,i=c.containerSize.height,j=c.containerSize.width,j=b.ui.hasScroll(g,"left")?g.scrollWidth:j,i=b.ui.hasScroll(g)? +g.scrollHeight:i;c.parentData={element:g,left:h.left,top:h.top,width:j,height:i}}},resize:function(c){var a=b(this).data("resizable"),h=a.options,e=a.containerOffset,f=a.position,c=a._aspectRatio||c.shiftKey,i={top:0,left:0},j=a.containerElement;j[0]!=document&&/static/.test(j.css("position"))&&(i=e);if(f.left<(a._helper?e.left:0))a.size.width+=a._helper?a.position.left-e.left:a.position.left-i.left,c&&(a.size.height=a.size.width/h.aspectRatio),a.position.left=h.helper?e.left:0;if(f.top<(a._helper? +e.top:0))a.size.height+=a._helper?a.position.top-e.top:a.position.top,c&&(a.size.width=a.size.height*h.aspectRatio),a.position.top=a._helper?e.top:0;a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;h=Math.abs(a.offset.left-i.left+a.sizeDiff.width);e=Math.abs((a._helper?a.offset.top-i.top:a.offset.top-e.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);i=/relative|absolute/.test(a.containerElement.css("position"));f&&i&&(h-=a.parentData.left); +h+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-h,c&&(a.size.height=a.size.width/a.aspectRatio));e+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-e,c&&(a.size.width=a.size.height*a.aspectRatio))},stop:function(){var a=b(this).data("resizable"),c=a.options,h=a.containerOffset,e=a.containerPosition,f=a.containerElement,i=b(a.helper),j=i.offset(),k=i.outerWidth()-a.sizeDiff.width,i=i.outerHeight()-a.sizeDiff.height;a._helper&&(!c.animate&&/relative/.test(f.css("position")))&& +b(this).css({left:j.left-e.left-h.left,width:k,height:i});a._helper&&(!c.animate&&/static/.test(f.css("position")))&&b(this).css({left:j.left-e.left-h.left,width:k,height:i})}});b.ui.plugin.add("resizable","ghost",{start:function(){var a=b(this).data("resizable"),c=a.options,h=a.size;a.ghost=a.originalElement.clone();a.ghost.css({opacity:0.25,display:"block",position:"relative",height:h.height,width:h.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof c.ghost?c.ghost: +"");a.ghost.appendTo(a.helper)},resize:function(){var a=b(this).data("resizable");a.ghost&&a.ghost.css({position:"relative",height:a.size.height,width:a.size.width})},stop:function(){var a=b(this).data("resizable");a.ghost&&a.helper&&a.helper.get(0).removeChild(a.ghost.get(0))}});b.ui.plugin.add("resizable","grid",{resize:function(){var a=b(this).data("resizable"),c=a.options,h=a.size,e=a.originalSize,f=a.originalPosition,i=a.axis;c.grid="number"==typeof c.grid?[c.grid,c.grid]:c.grid;var j=Math.round((h.width- +e.width)/(c.grid[0]||1))*(c.grid[0]||1),c=Math.round((h.height-e.height)/(c.grid[1]||1))*(c.grid[1]||1);/^(se|s|e)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c):/^(ne)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c,a.position.top=f.top-c):(/^(sw)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c):(a.size.width=e.width+j,a.size.height=e.height+c,a.position.top=f.top-c),a.position.left=f.left-j)}});var a=function(b){return parseInt(b,10)||0},c=function(b){return!isNaN(parseInt(b, +10))}})(jQuery); +(function(b){b.widget("ui.selectable",b.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var a=this;this.element.addClass("ui-selectable");this.dragged=!1;var c;this.refresh=function(){c=b(a.options.filter,a.element[0]);c.each(function(){var a=b(this),c=a.offset();b.data(this,"selectable-item",{element:this,$element:a,left:c.left,top:c.top,right:c.left+a.outerWidth(),bottom:c.top+a.outerHeight(),startselected:!1,selected:a.hasClass("ui-selected"),selecting:a.hasClass("ui-selecting"), +unselecting:a.hasClass("ui-unselecting")})})};this.refresh();this.selectees=c.addClass("ui-selectee");this._mouseInit();this.helper=b("
        ")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(a){var c=this;this.opos=[a.pageX,a.pageY];if(!this.options.disabled){var d= +this.options;this.selectees=b(d.filter,this.element[0]);this._trigger("start",a);b(d.appendTo).append(this.helper);this.helper.css({left:a.clientX,top:a.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var d=b.data(this,"selectable-item");d.startselected=!0;a.metaKey||(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",a,{unselecting:d.element}))});b(a.target).parents().andSelf().each(function(){var d= +b.data(this,"selectable-item");if(d){var h=!a.metaKey||!d.$element.hasClass("ui-selected");d.$element.removeClass(h?"ui-unselecting":"ui-selected").addClass(h?"ui-selecting":"ui-unselecting");d.unselecting=!h;d.selecting=h;(d.selected=h)?c._trigger("selecting",a,{selecting:d.element}):c._trigger("unselecting",a,{unselecting:d.element});return!1}})}},_mouseDrag:function(a){var c=this;this.dragged=!0;if(!this.options.disabled){var d=this.options,g=this.opos[0],h=this.opos[1],e=a.pageX,f=a.pageY;if(g> +e)var i=e,e=g,g=i;h>f&&(i=f,f=h,h=i);this.helper.css({left:g,top:h,width:e-g,height:f-h});this.selectees.each(function(){var i=b.data(this,"selectable-item");if(i&&i.element!=c.element[0]){var k=false;d.tolerance=="touch"?k=!(i.left>e||i.rightf||i.bottomg&&i.righth&&i.bottom *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var b=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh(); +this.floating=this.items.length?"x"===b.axis||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var b=this.items.length-1;0<=b;b--)this.items[b].item.removeData("sortable-item");return this},_setOption:function(a,c){"disabled"===a?(this.options[a]= +c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):b.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,c){if(this.reverting||this.options.disabled||"static"==this.options.type)return!1;this._refreshItems(a);var d=null,g=this;b(a.target).parents().each(function(){if(b.data(this,"sortable-item")==g)return d=b(this),!1});b.data(a.target,"sortable-item")==g&&(d=b(a.target));if(!d)return!1;if(this.options.handle&&!c){var h=!1;b(this.options.handle,d).find("*").andSelf().each(function(){this== +a.target&&(h=!0)});if(!h)return!1}this.currentItem=d;this._removeCurrentsFromItems();return!0},_mouseStart:function(a,c,d){c=this.options;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition= +this.helper.css("position");b.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder(); +c.containment&&this._setContainment();c.cursor&&(b("body").css("cursor")&&(this._storedCursor=b("body").css("cursor")),b("body").css("cursor",c.cursor));c.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",c.opacity));c.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",c.zIndex));this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()); +this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(d=this.containers.length-1;0<=d;d--)this.containers[d]._trigger("activate",a,this._uiHash(this));b.ui.ddmanager&&(b.ui.ddmanager.current=this);b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,a);this.dragging=!0;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);return!0},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute"); +this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageYb[this.floating?"width":"height"]?g+k>i&&g+ke&&c+lthis.containment[2]&&(h=this.containment[2]+this.offset.click.left),a.pageY-this.offset.click.top>this.containment[3]&&(e=this.containment[3]+this.offset.click.top)),c.grid))e=this.originalPageY+Math.round((e-this.originalPageY)/c.grid[1])*c.grid[1],e=this.containment?!(e-this.offset.click.topthis.containment[3])?e:!(e-this.offset.click.top< +this.containment[1])?e-c.grid[1]:e+c.grid[1]:e,h=this.originalPageX+Math.round((h-this.originalPageX)/c.grid[0])*c.grid[0],h=this.containment?!(h-this.offset.click.leftthis.containment[2])?h:!(h-this.offset.click.left li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,c=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");a.headers= +a.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){c.disabled||b(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){c.disabled||b(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){c.disabled||b(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){c.disabled||b(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); +if(c.navigation){var d=a.element.find("a").filter(c.navigationFilter).eq(0);if(d.length){var g=d.closest(".ui-accordion-header");a.active=g.length?g:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion", +function(b){return a._keydown(b)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);b.browser.safari||a.headers.find("a").attr("tabIndex",-1);c.event&&a.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(b){a._clickHandler.call(a,b,this);b.preventDefault()})},_createIcons:function(){var a= +this.options;a.icons&&(b("").addClass("ui-icon "+a.icons.header).prependTo(this.headers),this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected),this.element.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"); +this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");(a.autoHeight||a.fillHeight)&&c.css("height","");return b.Widget.prototype.destroy.call(this)},_setOption:function(a,c){b.Widget.prototype._setOption.apply(this,arguments);"active"==a&&this.activate(c);"icons"==a&&(this._destroyIcons(), +c&&this._createIcons());if("disabled"==a)this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!this.options.disabled&&!a.altKey&&!a.ctrlKey){var c=b.ui.keyCode,d=this.headers.length,g=this.headers.index(a.target),h=!1;switch(a.keyCode){case c.RIGHT:case c.DOWN:h=this.headers[(g+1)%d];break;case c.LEFT:case c.UP:h=this.headers[(g-1+d)%d];break;case c.SPACE:case c.ENTER:this._clickHandler({target:a.target},a.target),a.preventDefault()}return h? +(b(a.target).attr("tabIndex",-1),b(h).attr("tabIndex",0),h.focus(),!1):!0}},resize:function(){var a=this.options,c;if(a.fillSpace){if(b.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height();b.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){c-=b(this).outerHeight(!0)});this.headers.next().each(function(){b(this).height(Math.max(0,c-b(this).innerHeight()+b(this).height()))}).css("overflow", +"auto")}else a.autoHeight&&(c=0,this.headers.next().each(function(){c=Math.max(c,b(this).height("").height())}).height(c));return this},activate:function(b){this.options.active=b;b=this._findActive(b)[0];this._clickHandler({target:b},b);return this},_findActive:function(a){return a?"number"===typeof a?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):!1===a?b([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,c){var d=this.options;if(!d.disabled)if(a.target){var g=b(a.currentTarget|| +c),h=g[0]===this.active[0];d.active=d.collapsible&&h?!1:this.headers.index(g);if(!(this.running||!d.collapsible&&h)){var e=this.active,f=g.next(),i=this.active.next(),j={options:d,newHeader:h&&d.collapsible?b([]):g,oldHeader:this.active,newContent:h&&d.collapsible?b([]):f,oldContent:i},k=this.headers.index(this.active[0])>this.headers.index(g[0]);this.active=h?b([]):g;this._toggle(f,i,j,h,k);e.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header); +h||(g.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected),g.next().addClass("ui-accordion-content-active"))}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var i=this.active.next(), +j={options:d,newHeader:b([]),oldHeader:d.active,newContent:b([]),oldContent:i},f=this.active=b([]);this._toggle(f,i,j)}},_toggle:function(a,c,d,g,h){var e=this,f=e.options;e.toShow=a;e.toHide=c;e.data=d;var i=function(){if(e)return e._completed.apply(e,arguments)};e._trigger("changestart",null,e.data);e.running=0===c.size()?a.size():c.size();if(f.animated){d={};d=f.collapsible&&g?{toShow:b([]),toHide:c,complete:i,down:h,autoHeight:f.autoHeight||f.fillSpace}:{toShow:a,toHide:c,complete:i,down:h,autoHeight:f.autoHeight|| +f.fillSpace};f.proxied||(f.proxied=f.animated);f.proxiedDuration||(f.proxiedDuration=f.duration);f.animated=b.isFunction(f.proxied)?f.proxied(d):f.proxied;f.duration=b.isFunction(f.proxiedDuration)?f.proxiedDuration(d):f.proxiedDuration;var g=b.ui.accordion.animations,j=f.duration,k=f.animated;k&&(!g[k]&&!b.easing[k])&&(k="slide");g[k]||(g[k]=function(b){this.slide(b,{easing:k,duration:j||700})});g[k](d)}else f.collapsible&&g?a.toggle():(c.hide(),a.show()),i(!0);c.prev().attr({"aria-expanded":"false", +"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(b){this.running=b?0:--this.running;this.running||(this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""}),this.toHide.removeClass("ui-accordion-content-active"),this.toHide.length&&(this.toHide.parent()[0].className=this.toHide.parent()[0].className),this._trigger("change",null,this.data))}});b.extend(b.ui.accordion,{version:"1.8.14", +animations:{slide:function(a,c){a=b.extend({easing:"swing",duration:300},a,c);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),g=0,h={},e={},f,i=a.toShow;f=i[0].style.width;i.width(parseInt(i.parent().width(),10)-parseInt(i.css("paddingLeft"),10)-parseInt(i.css("paddingRight"),10)-(parseInt(i.css("borderLeftWidth"),10)||0)-(parseInt(i.css("borderRightWidth"),10)||0));b.each(["height","paddingTop","paddingBottom"],function(c,f){e[f]="hide";var i=(""+b.css(a.toShow[0],f)).match(/^([\d+-.]+)(.*)$/); +h[f]={value:i[1],unit:i[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(e,{step:function(b,c){"height"==c.prop&&(g=0===c.end-c.start?0:(c.now-c.start)/(c.end-c.start));a.toShow[0].style[c.prop]=g*h[c.prop].value+h[c.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:f,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide", +paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(b){this.slide(b,{easing:b.down?"easeOutBounce":"swing",duration:b.down?1E3:200})}}})})(jQuery); +(function(b){var a=0;b.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var c=this,a=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(a){if(!c.options.disabled&&!c.element.attr("readonly")){g=!1;var d= +b.ui.keyCode;switch(a.keyCode){case d.PAGE_UP:c._move("previousPage",a);break;case d.PAGE_DOWN:c._move("nextPage",a);break;case d.UP:c._move("previous",a);a.preventDefault();break;case d.DOWN:c._move("next",a);a.preventDefault();break;case d.ENTER:case d.NUMPAD_ENTER:c.menu.active&&(g=!0,a.preventDefault());case d.TAB:if(!c.menu.active)break;c.menu.select(a);break;case d.ESCAPE:c.element.val(c.term);c.close(a);break;default:clearTimeout(c.searching),c.searching=setTimeout(function(){c.term!=c.element.val()&& +(c.selectedItem=null,c.search(null,a))},c.options.delay)}}}).bind("keypress.autocomplete",function(b){g&&(g=!1,b.preventDefault())}).bind("focus.autocomplete",function(){c.options.disabled||(c.selectedItem=null,c.previous=c.element.val())}).bind("blur.autocomplete",function(b){c.options.disabled||(clearTimeout(c.searching),c.closing=setTimeout(function(){c.close(b);c._change(b)},150))});this._initSource();this.response=function(){return c._response.apply(c,arguments)};this.menu=b("
          ").addClass("ui-autocomplete").appendTo(b(this.options.appendTo|| +"body",a)[0]).mousedown(function(a){var d=c.menu.element[0];b(a.target).closest(".ui-menu-item").length||setTimeout(function(){b(document).one("mousedown",function(a){a.target!==c.element[0]&&(a.target!==d&&!b.ui.contains(d,a.target))&&c.close()})},1);setTimeout(function(){clearTimeout(c.closing)},13)}).menu({focus:function(b,a){var f=a.item.data("item.autocomplete");!1!==c._trigger("focus",b,{item:f})&&/^key/.test(b.originalEvent.type)&&c.element.val(f.value)},selected:function(b,e){var f=e.item.data("item.autocomplete"), +i=c.previous;c.element[0]!==a.activeElement&&(c.element.focus(),c.previous=i,setTimeout(function(){c.previous=i;c.selectedItem=f},1));!1!==c._trigger("select",b,{item:f})&&c.element.val(f.value);c.term=c.element.val();c.close(b);c.selectedItem=f},blur:function(){c.menu.element.is(":visible")&&c.element.val()!==c.term&&c.element.val(c.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");b.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"); +this.menu.element.remove();b.Widget.prototype.destroy.call(this)},_setOption:function(a,d){b.Widget.prototype._setOption.apply(this,arguments);"source"===a&&this._initSource();"appendTo"===a&&this.menu.element.appendTo(b(d||"body",this.element[0].ownerDocument)[0]);"disabled"===a&&(d&&this.xhr)&&this.xhr.abort()},_initSource:function(){var c=this,d,g;b.isArray(this.options.source)?(d=this.options.source,this.source=function(a,c){c(b.ui.autocomplete.filter(d,a.term))}):"string"===typeof this.options.source? +(g=this.options.source,this.source=function(d,e){c.xhr&&c.xhr.abort();c.xhr=b.ajax({url:g,data:d,dataType:"json",autocompleteRequest:++a,success:function(b){this.autocompleteRequest===a&&e(b)},error:function(){this.autocompleteRequest===a&&e([])}})}):this.source=this.options.source},search:function(b,a){b=null!=b?b:this.element.val();this.term=this.element.val();if(b.length").data("item.autocomplete",d).append(b("").text(d.label)).appendTo(a)},_move:function(b,a){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(b)||this.menu.last()&& +/^next/.test(b))this.element.val(this.term),this.menu.deactivate();else this.menu[b](a);else this.search(null,a)},widget:function(){return this.menu.element}});b.extend(b.ui.autocomplete,{escapeRegex:function(b){return b.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(a,d){var g=RegExp(b.ui.autocomplete.escapeRegex(d),"i");return b.grep(a,function(b){return g.test(b.label||b.value||b)})}})})(jQuery); +(function(b){b.widget("ui.menu",{_create:function(){var a=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){b(c.target).closest(".ui-menu-item a").length&&(c.preventDefault(),a.select(c))});this.refresh()},refresh:function(){var a=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", +-1).mouseenter(function(c){a.activate(c,b(this).parent())}).mouseleave(function(){a.deactivate()})},activate:function(b,c){this.deactivate();if(this.hasScroll()){var d=c.offset().top-this.element.offset().top,g=this.element.scrollTop(),h=this.element.height();0>d?this.element.scrollTop(g+d):d>=h&&this.element.scrollTop(g+d-h+c.height())}this.active=c.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",b,{item:c})},deactivate:function(){this.active&& +(this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null)},next:function(b){this.move("next",".ui-menu-item:first",b)},previous:function(b){this.move("prev",".ui-menu-item:last",b)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(b,c,d){this.active?(b=this.active[b+"All"](".ui-menu-item").eq(0),b.length?this.activate(d, +b):this.activate(d,this.element.children(c))):this.activate(d,this.element.children(c))},nextPage:function(a){if(this.hasScroll())if(!this.active||this.last())this.activate(a,this.element.children(".ui-menu-item:first"));else{var c=this.active.offset().top,d=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var a=b(this).offset().top-c-d+b(this).height();return 10>a&&-10a&&-10").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),d=this.options.icons,h=d.primary&&d.secondary,e=[];d.primary||d.secondary?(this.options.text&&e.push("ui-button-text-icon"+(h?"s":d.primary?"-primary":"-secondary")),d.primary&&a.prepend(""),d.secondary&&a.append(""),this.options.text||(e.push(h?"ui-button-icons-only": +"ui-button-icon-only"),this.hasTitle||a.attr("title",c))):e.push("ui-button-text-only");a.addClass(e.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){"disabled"===a&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a="ltr"===this.element.css("direction"); +this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"); +b.Widget.prototype.destroy.call(this)}})})(jQuery); +(function(b,a){var c={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},d={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},g=b.attrFn||{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0,click:!0};b.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(a){var c= +b(this).css(a).offset().top;0>c&&b(this).css("top",a.top-c)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");"string"!==typeof this.originalTitle&&(this.originalTitle="");this.options.title=this.options.title||this.originalTitle;var a=this,c=a.options,f=c.title||" ",i=b.ui.dialog.getTitleId(a.element),d=(a.uiDialog=b("
          ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ +c.dialogClass).css({zIndex:c.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(f){if(c.closeOnEscape&&f.keyCode&&f.keyCode===b.ui.keyCode.ESCAPE){a.close(f);f.preventDefault()}}).attr({role:"dialog","aria-labelledby":i}).mousedown(function(b){a.moveToTop(false,b)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(d);var g=(a.uiDialogTitlebar=b("
          ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(d), +l=b('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){l.addClass("ui-state-hover")},function(){l.removeClass("ui-state-hover")}).focus(function(){l.addClass("ui-state-focus")}).blur(function(){l.removeClass("ui-state-focus")}).click(function(b){a.close(b);return false}).appendTo(g);(a.uiDialogTitlebarCloseText=b("")).addClass("ui-icon ui-icon-closethick").text(c.closeText).appendTo(l);b("").addClass("ui-dialog-title").attr("id", +i).html(f).prependTo(g);b.isFunction(c.beforeclose)&&!b.isFunction(c.beforeClose)&&(c.beforeClose=c.beforeclose);g.find("*").add(g).disableSelection();c.draggable&&b.fn.draggable&&a._makeDraggable();c.resizable&&b.fn.resizable&&a._makeResizable();a._createButtons(c.buttons);a._isOpen=!1;b.fn.bgiframe&&d.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){this.overlay&&this.overlay.destroy();this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"); +this.uiDialog.remove();this.originalTitle&&this.element.attr("title",this.originalTitle);return this},widget:function(){return this.uiDialog},close:function(a){var c=this,f,d;if(!1!==c._trigger("beforeClose",a))return c.overlay&&c.overlay.destroy(),c.uiDialog.unbind("keypress.ui-dialog"),c._isOpen=!1,c.options.hide?c.uiDialog.hide(c.options.hide,function(){c._trigger("close",a)}):(c.uiDialog.hide(),c._trigger("close",a)),b.ui.dialog.overlay.resize(),c.options.modal&&(f=0,b(".ui-dialog").each(function(){if(this!== +c.uiDialog[0]){d=b(this).css("z-index");isNaN(d)||(f=Math.max(f,d))}}),b.ui.dialog.maxZ=f),c},isOpen:function(){return this._isOpen},moveToTop:function(a,c){var f=this.options;if(f.modal&&!a||!f.stack&&!f.modal)return this._trigger("focus",c);f.zIndex>b.ui.dialog.maxZ&&(b.ui.dialog.maxZ=f.zIndex);this.overlay&&(b.ui.dialog.maxZ+=1,this.overlay.$el.css("z-index",b.ui.dialog.overlay.maxZ=b.ui.dialog.maxZ));f={scrollTop:this.element.attr("scrollTop"),scrollLeft:this.element.attr("scrollLeft")};b.ui.dialog.maxZ+= +1;this.uiDialog.css("z-index",b.ui.dialog.maxZ);this.element.attr(f);this._trigger("focus",c);return this},open:function(){if(!this._isOpen){var a=this.options,c=this.uiDialog;this.overlay=a.modal?new b.ui.dialog.overlay(this):null;this._size();this._position(a.position);c.show(a.show);this.moveToTop(!0);a.modal&&c.bind("keypress.ui-dialog",function(a){if(a.keyCode===b.ui.keyCode.TAB){var c=b(":tabbable",this),d=c.filter(":first"),c=c.filter(":last");if(a.target===c[0]&&!a.shiftKey)return d.focus(1), +!1;if(a.target===d[0]&&a.shiftKey)return c.focus(1),!1}});b(this.element.find(":tabbable").get().concat(c.find(".ui-dialog-buttonpane :tabbable").get().concat(c.get()))).eq(0).focus();this._isOpen=!0;this._trigger("open");return this}},_createButtons:function(a){var c=this,f=!1,d=b("
          ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),j=b("
          ").addClass("ui-dialog-buttonset").appendTo(d);c.uiDialog.find(".ui-dialog-buttonpane").remove();"object"===typeof a&& +null!==a&&b.each(a,function(){return!(f=!0)});f&&(b.each(a,function(a,f){var f=b.isFunction(f)?{click:f,text:a}:f,d=b('').click(function(){f.click.apply(c.element[0],arguments)}).appendTo(j);b.each(f,function(b,a){if("click"!==b)if(b in g)d[b](a);else d.attr(b,a)});b.fn.button&&d.button()}),d.appendTo(c.uiDialog))},_makeDraggable:function(){function a(b){return{position:b.position,offset:b.offset}}var c=this,f=c.options,d=b(document),g;c.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close", +handle:".ui-dialog-titlebar",containment:"document",start:function(d,i){g="auto"===f.height?"auto":b(this).height();b(this).height(b(this).height()).addClass("ui-dialog-dragging");c._trigger("dragStart",d,a(i))},drag:function(b,f){c._trigger("drag",b,a(f))},stop:function(k,l){f.position=[l.position.left-d.scrollLeft(),l.position.top-d.scrollTop()];b(this).removeClass("ui-dialog-dragging").height(g);c._trigger("dragStop",k,a(l));b.ui.dialog.overlay.resize()}})},_makeResizable:function(c){function d(b){return{originalPosition:b.originalPosition, +originalSize:b.originalSize,position:b.position,size:b.size}}var c=c===a?this.options.resizable:c,f=this,i=f.options,g=f.uiDialog.css("position"),c="string"===typeof c?c:"n,e,s,w,se,sw,ne,nw";f.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:f.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:f._minHeight(),handles:c,start:function(a,c){b(this).addClass("ui-dialog-resizing");f._trigger("resizeStart",a,d(c))},resize:function(b,a){f._trigger("resize", +b,d(a))},stop:function(a,c){b(this).removeClass("ui-dialog-resizing");i.height=b(this).height();i.width=b(this).width();f._trigger("resizeStop",a,d(c));b.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var b=this.options;return"auto"===b.height?b.minHeight:Math.min(b.minHeight,b.height)},_position:function(a){var c=[],f=[0,0],d;if(a){if("string"===typeof a||"object"===typeof a&&"0"in a)c=a.split?a.split(" "): +[a[0],a[1]],1===c.length&&(c[1]=c[0]),b.each(["left","top"],function(b,a){+c[b]===c[b]&&(f[b]=c[b],c[b]=a)}),a={my:c.join(" "),at:c.join(" "),offset:f.join(" ")};a=b.extend({},b.ui.dialog.prototype.options.position,a)}else a=b.ui.dialog.prototype.options.position;(d=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(b.extend({of:window},a));d||this.uiDialog.hide()},_setOptions:function(a){var g=this,f={},i=!1;b.each(a,function(b,a){g._setOption(b,a);b in +c&&(i=!0);b in d&&(f[b]=a)});i&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",f)},_setOption:function(a,c){var f=this.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":this._createButtons(c);break;case "closeText":this.uiDialogTitlebarCloseText.text(""+c);break;case "dialogClass":f.removeClass(this.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+c);break;case "disabled":c?f.addClass("ui-dialog-disabled"): +f.removeClass("ui-dialog-disabled");break;case "draggable":var d=f.is(":data(draggable)");d&&!c&&f.draggable("destroy");!d&&c&&this._makeDraggable();break;case "position":this._position(c);break;case "resizable":(d=f.is(":data(resizable)"))&&!c&&f.resizable("destroy");d&&"string"===typeof c&&f.resizable("option","handles",c);!d&&!1!==c&&this._makeResizable(c);break;case "title":b(".ui-dialog-title",this.uiDialogTitlebar).html(""+(c||" "))}b.Widget.prototype._setOption.apply(this,arguments)}, +_size:function(){var a=this.options,c,f,d=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});a.minWidth>a.width&&(a.width=a.minWidth);c=this.uiDialog.css({height:"auto",width:a.width}).height();f=Math.max(0,a.minHeight-c);"auto"===a.height?b.support.minHeight?this.element.css({minHeight:f,height:"auto"}):(this.uiDialog.show(),a=this.element.css("height","auto").height(),d||this.uiDialog.hide(),this.element.height(Math.max(a,f))):this.element.height(Math.max(a.height- +c,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});b.extend(b.ui.dialog,{version:"1.8.14",uuid:0,maxZ:0,getTitleId:function(b){b=b.attr("id");b||(b=this.uuid+=1);return"ui-dialog-title-"+b},overlay:function(a){this.$el=b.ui.dialog.overlay.create(a)}});b.extend(b.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:b.map("focus mousedown mouseup keydown keypress click".split(" "),function(b){return b+".dialog-overlay"}).join(" "), +create:function(a){0===this.instances.length&&(setTimeout(function(){b.ui.dialog.overlay.instances.length&&b(document).bind(b.ui.dialog.overlay.events,function(a){if(b(a.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(), +height:this.height()});b.fn.bgiframe&&c.bgiframe();this.instances.push(c);return c},destroy:function(a){var c=b.inArray(a,this.instances);-1!=c&&this.oldInstances.push(this.instances.splice(c,1)[0]);0===this.instances.length&&b([document,window]).unbind(".dialog-overlay");a.remove();var f=0;b.each(this.instances,function(){f=Math.max(f,this.css("z-index"))});this.maxZ=f},height:function(){var a,c;return b.browser.msie&&7>b.browser.version?(a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight), +c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),a").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+("min"===c.range||"max"===c.range?" ui-slider-range-"+c.range:""))}for(var e=d.length;e"); +this.handles=d.add(b(h.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(b){b.preventDefault()}).hover(function(){c.disabled||b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")}).focus(function(){c.disabled?b(this).blur():(b(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),b(this).addClass("ui-state-focus"))}).blur(function(){b(this).removeClass("ui-state-focus")});this.handles.each(function(a){b(this).data("index.ui-slider-handle", +a)});this.handles.keydown(function(c){var d=!0,g=b(this).data("index.ui-slider-handle"),e,h,m;if(!a.options.disabled){switch(c.keyCode){case b.ui.keyCode.HOME:case b.ui.keyCode.END:case b.ui.keyCode.PAGE_UP:case b.ui.keyCode.PAGE_DOWN:case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(d=!1,!a._keySliding&&(a._keySliding=!0,b(this).addClass("ui-state-active"),e=a._start(c,g),!1===e))return}m=a.options.step;e=a.options.values&&a.options.values.length?h=a.values(g): +h=a.value();switch(c.keyCode){case b.ui.keyCode.HOME:h=a._valueMin();break;case b.ui.keyCode.END:h=a._valueMax();break;case b.ui.keyCode.PAGE_UP:h=a._trimAlignValue(e+(a._valueMax()-a._valueMin())/5);break;case b.ui.keyCode.PAGE_DOWN:h=a._trimAlignValue(e-(a._valueMax()-a._valueMin())/5);break;case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:if(e===a._valueMax())return;h=a._trimAlignValue(e+m);break;case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(e===a._valueMin())return;h=a._trimAlignValue(e-m)}a._slide(c, +g,h);return d}}).keyup(function(c){var d=b(this).data("index.ui-slider-handle");a._keySliding&&(a._keySliding=!1,a._stop(c,d),a._change(c,d),b(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=!1},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(a){var c= +this.options,d,g,h,e,f;if(c.disabled)return!1;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();d=this._normValueFromMouse({x:a.pageX,y:a.pageY});g=this._valueMax()-this._valueMin()+1;e=this;this.handles.each(function(a){var c=Math.abs(d-e.values(a));g>c&&(g=c,h=b(this),f=a)});!0===c.range&&this.values(1)===c.min&&(f+=1,h=b(this.handles[f]));if(!1===this._start(a,f))return!1;this._mouseSliding=!0;e._handleIndex=f;h.addClass("ui-state-active").focus(); +c=h.offset();this._clickOffset=!b(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-c.left-h.width()/2,top:a.pageY-c.top-h.height()/2-(parseInt(h.css("borderTopWidth"),10)||0)-(parseInt(h.css("borderBottomWidth"),10)||0)+(parseInt(h.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,f,d);return this._animateOff=!0},_mouseStart:function(){return!0},_mouseDrag:function(b){var c=this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b, +this._handleIndex,c);return!1},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=!1;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(b){var c;"horizontal"===this.orientation?(c=this.elementSize.width,b=b.x-this.elementOffset.left-(this._clickOffset? +this._clickOffset.left:0)):(c=this.elementSize.height,b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));c=b/c;1c&&(c=0);"vertical"===this.orientation&&(c=1-c);b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+c*b)},_start:function(b,c){var d={handle:this.handles[c],value:this.value()};this.options.values&&this.options.values.length&&(d.value=this.values(c),d.values=this.values());return this._trigger("start",b,d)},_slide:function(b, +c,d){var g;if(this.options.values&&this.options.values.length){g=this.values(c?0:1);if(2===this.options.values.length&&!0===this.options.range&&(0===c&&d>g||1===c&&d=this._valueMax())return this._valueMax();var c=0=c&&(alignValue+=0",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
        • #{label}
        • "},_create:function(){this._tabify(!0)},_setOption:function(b,a){"selected"==b?this.options.collapsible&&a==this.options.selected||this.select(a): +(this.options[b]=a,this._tabify())},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+ ++c},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var a=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++d);return b.cookie.apply(null,[a].concat(b.makeArray(arguments)))},_ui:function(b,a){return{tab:b,panel:a,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var a= +b(this);a.html(a.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function d(a,c){a.css("display","");!b.support.opacity&&c.opacity&&a[0].style.removeAttribute("filter")}var e=this,f=this.options,i=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=b(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return b("a",this)[0]});this.panels=b([]);this.anchors.each(function(a,c){var d=b(c).attr("href"),g=d.split("#")[0],h;if(g&&(g===location.toString().split("#")[0]|| +(h=b("base")[0])&&g===h.href))d=c.hash,c.href=d;i.test(d)?e.panels=e.panels.add(e.element.find(e._sanitizeSelector(d))):d&&"#"!==d?(b.data(c,"href.tabs",d),b.data(c,"load.tabs",d.replace(/#.*$/,"")),d=e._tabId(c),c.href="#"+d,g=e.element.find("#"+d),g.length||(g=b(f.panelTemplate).attr("id",d).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(e.panels[a-1]||e.list),g.data("destroy.tabs",!0)),e.panels=e.panels.add(g)):f.disabled.push(a)});c?(this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"), +this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.lis.addClass("ui-state-default ui-corner-top"),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom"),f.selected===a?(location.hash&&this.anchors.each(function(b,a){if(a.hash==location.hash)return f.selected=b,!1}),"number"!==typeof f.selected&&f.cookie&&(f.selected=parseInt(e._cookie(),10)),"number"!==typeof f.selected&&this.lis.filter(".ui-tabs-selected").length&&(f.selected= +this.lis.index(this.lis.filter(".ui-tabs-selected"))),f.selected=f.selected||(this.lis.length?0:-1)):null===f.selected&&(f.selected=-1),f.selected=0<=f.selected&&this.anchors[f.selected]||0>f.selected?f.selected:0,f.disabled=b.unique(f.disabled.concat(b.map(this.lis.filter(".ui-state-disabled"),function(b){return e.lis.index(b)}))).sort(),-1!=b.inArray(f.selected,f.disabled)&&f.disabled.splice(b.inArray(f.selected,f.disabled),1),this.panels.addClass("ui-tabs-hide"),this.lis.removeClass("ui-tabs-selected ui-state-active"), +0<=f.selected&&this.anchors.length&&(e.element.find(e._sanitizeSelector(e.anchors[f.selected].hash)).removeClass("ui-tabs-hide"),this.lis.eq(f.selected).addClass("ui-tabs-selected ui-state-active"),e.element.queue("tabs",function(){e._trigger("show",null,e._ui(e.anchors[f.selected],e.element.find(e._sanitizeSelector(e.anchors[f.selected].hash))[0]))}),this.load(f.selected)),b(window).bind("unload",function(){e.lis.add(e.anchors).unbind(".tabs");e.lis=e.anchors=e.panels=null})):f.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); +this.element[f.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");f.cookie&&this._cookie(f.selected,f.cookie);for(var c=0,j;j=this.lis[c];c++)b(j)[-1!=b.inArray(c,f.disabled)&&!b(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");!1===f.cache&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if("mouseover"!==f.event){var k=function(b,a){a.is(":not(.ui-state-disabled)")&&a.addClass("ui-state-"+b)};this.lis.bind("mouseover.tabs", +function(){k("hover",b(this))});this.lis.bind("mouseout.tabs",function(){b(this).removeClass("ui-state-hover")});this.anchors.bind("focus.tabs",function(){k("focus",b(this).closest("li"))});this.anchors.bind("blur.tabs",function(){b(this).closest("li").removeClass("ui-state-focus")})}var l,m;f.fx&&(b.isArray(f.fx)?(l=f.fx[0],m=f.fx[1]):l=m=f.fx);var p=m?function(a,c){b(a).closest("li").addClass("ui-tabs-selected ui-state-active");c.hide().removeClass("ui-tabs-hide").animate(m,m.duration||"normal", +function(){d(c,m);e._trigger("show",null,e._ui(a,c[0]))})}:function(a,c){b(a).closest("li").addClass("ui-tabs-selected ui-state-active");c.removeClass("ui-tabs-hide");e._trigger("show",null,e._ui(a,c[0]))},n=l?function(b,a){a.animate(l,l.duration||"normal",function(){e.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");d(a,l);e.element.dequeue("tabs")})}:function(b,a){e.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");e.element.dequeue("tabs")}; +this.anchors.bind(f.event+".tabs",function(){var a=this,c=b(a).closest("li"),d=e.panels.filter(":not(.ui-tabs-hide)"),i=e.element.find(e._sanitizeSelector(a.hash));if(c.hasClass("ui-tabs-selected")&&!f.collapsible||c.hasClass("ui-state-disabled")||c.hasClass("ui-state-processing")||e.panels.filter(":animated").length||e._trigger("select",null,e._ui(this,i[0]))===false){this.blur();return false}f.selected=e.anchors.index(this);e.abort();if(f.collapsible){if(c.hasClass("ui-tabs-selected")){f.selected= +-1;f.cookie&&e._cookie(f.selected,f.cookie);e.element.queue("tabs",function(){n(a,d)}).dequeue("tabs");this.blur();return false}if(!d.length){f.cookie&&e._cookie(f.selected,f.cookie);e.element.queue("tabs",function(){p(a,i)});e.load(e.anchors.index(this));this.blur();return false}}f.cookie&&e._cookie(f.selected,f.cookie);if(i.length){d.length&&e.element.queue("tabs",function(){n(a,d)});e.element.queue("tabs",function(){p(a,i)});e.load(e.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; +b.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){"string"==typeof b&&(b=this.anchors.index(this.anchors.filter("[href$="+b+"]")));return b},destroy:function(){var a=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var a= +b.data(this,"href.tabs");a&&(this.href=a);var c=b(this).unbind(".tabs");b.each(["href","load","cache"],function(b,a){c.removeData(a+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){b.data(this,"destroy.tabs")?b(this).remove():b(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});a.cookie&&this._cookie(null,a.cookie);return this},add:function(c, +d,e){e===a&&(e=this.anchors.length);var f=this,i=this.options,d=b(i.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,d)),c=!c.indexOf("#")?c.replace("#",""):this._tabId(b("a",d)[0]);d.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var j=f.element.find("#"+c);j.length||(j=b(i.panelTemplate).attr("id",c).data("destroy.tabs",!0));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");e>=this.lis.length?(d.appendTo(this.list),j.appendTo(this.list[0].parentNode)): +(d.insertBefore(this.lis[e]),j.insertBefore(this.panels[e]));i.disabled=b.map(i.disabled,function(b){return b>=e?++b:b});this._tabify();1==this.anchors.length&&(i.selected=0,d.addClass("ui-tabs-selected ui-state-active"),j.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){f._trigger("show",null,f._ui(f.anchors[0],f.panels[0]))}),this.load(0));this._trigger("add",null,this._ui(this.anchors[e],this.panels[e]));return this},remove:function(a){var a=this._getIndex(a),c=this.options,d=this.lis.eq(a).remove(), +f=this.panels.eq(a).remove();d.hasClass("ui-tabs-selected")&&1=a?--b:b});this._tabify();this._trigger("remove",null,this._ui(d.find("a")[0],f[0]));return this},enable:function(a){var a=this._getIndex(a),c=this.options;if(-1!=b.inArray(a,c.disabled))return this.lis.eq(a).removeClass("ui-state-disabled"),c.disabled=b.grep(c.disabled,function(b){return b!= +a}),this._trigger("enable",null,this._ui(this.anchors[a],this.panels[a])),this},disable:function(b){var b=this._getIndex(b),a=this.options;b!=a.selected&&(this.lis.eq(b).addClass("ui-state-disabled"),a.disabled.push(b),a.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b])));return this},select:function(b){b=this._getIndex(b);if(-1==b)if(this.options.collapsible&&-1!=this.options.selected)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+ +".tabs");return this},load:function(a){var a=this._getIndex(a),c=this,d=this.options,f=this.anchors.eq(a)[0],i=b.data(f,"load.tabs");this.abort();if(!i||0!==this.element.queue("tabs").length&&b.data(f,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(a).addClass("ui-state-processing");if(d.spinner){var j=b("span",f);j.data("label.tabs",j.html()).html(d.spinner)}this.xhr=b.ajax(b.extend({},d.ajaxOptions,{url:i,success:function(i,j){c.element.find(c._sanitizeSelector(f.hash)).html(i);c._cleanup(); +d.cache&&b.data(f,"cache.tabs",!0);c._trigger("load",null,c._ui(c.anchors[a],c.panels[a]));try{d.ajaxOptions.success(i,j)}catch(m){}},error:function(b,i){c._cleanup();c._trigger("load",null,c._ui(c.anchors[a],c.panels[a]));try{d.ajaxOptions.error(b,i,a,f)}catch(m){}}}));c.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(!1,!0);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));this.xhr&&(this.xhr.abort(),delete this.xhr);this._cleanup(); +return this},url:function(b,a){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",a);return this},length:function(){return this.anchors.length}});b.extend(b.ui.tabs,{version:"1.8.14"});b.extend(b.ui.tabs.prototype,{rotation:null,rotate:function(b,a){var c=this,f=this.options,d=c._rotate||(c._rotate=function(a){clearTimeout(c.rotation);c.rotation=setTimeout(function(){var b=f.selected;c.select(++b'))}function d(a){return a.bind("mouseout",function(a){a=b(a.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"); +a.length&&a.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){c=b(c.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!b.datepicker._isDisabledDatepicker(e.inline?a.parent()[0]:e.input[0])&&c.length)c.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),c.addClass("ui-state-hover"),c.hasClass("ui-datepicker-prev")&&c.addClass("ui-datepicker-prev-hover"),c.hasClass("ui-datepicker-next")&& +c.addClass("ui-datepicker-next-hover")})}function g(c,d){b.extend(c,d);for(var e in d)if(null==d[e]||d[e]==a)c[e]=d[e];return c}b.extend(b.ui,{datepicker:{version:"1.8.14"}});var h=(new Date).getTime(),e;b.extend(c.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(b){g(this._defaults,b||{});return this},_attachDatepicker:function(a,c){var d=null,e;for(e in this._defaults){var g= +a.getAttribute("date:"+e);if(g){d=d||{};try{d[e]=eval(g)}catch(m){d[e]=g}}}e=a.nodeName.toLowerCase();g="div"==e||"span"==e;a.id||(this.uuid+=1,a.id="dp"+this.uuid);var h=this._newInst(b(a),g);h.settings=b.extend({},c||{},d||{});"input"==e?this._connectDatepicker(a,h):g&&this._inlineDatepicker(a,h)},_newInst:function(a,c){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:c,dpDiv:!c?this.dpDiv:d(b('
          '))}},_connectDatepicker:function(a,c){var d=b(a);c.append=b([]);c.trigger=b([]);d.hasClass(this.markerClassName)||(this._attachments(d,c),d.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(b,a,f){c.settings[a]=f}).bind("getData.datepicker",function(b,a){return this._get(c,a)}),this._autoSize(c),b.data(a,"datepicker", +c))},_attachments:function(a,c){var d=this._get(c,"appendText"),e=this._get(c,"isRTL");c.append&&c.append.remove();d&&(c.append=b(''+d+""),a[e?"before":"after"](c.append));a.unbind("focus",this._showDatepicker);c.trigger&&c.trigger.remove();d=this._get(c,"showOn");("focus"==d||"both"==d)&&a.focus(this._showDatepicker);if("button"==d||"both"==d){var d=this._get(c,"buttonText"),g=this._get(c,"buttonImage");c.trigger=b(this._get(c,"buttonImageOnly")?b("").addClass(this._triggerClass).attr({src:g, +alt:d,title:d}):b('').addClass(this._triggerClass).html(""==g?d:b("").attr({src:g,alt:d,title:d})));a[e?"before":"after"](c.trigger);c.trigger.click(function(){b.datepicker._datepickerShowing&&b.datepicker._lastInput==a[0]?b.datepicker._hideDatepicker():b.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(b){if(this._get(b,"autoSize")&&!b.inline){var a=new Date(2009,11,20),c=this._get(b,"dateFormat");if(c.match(/[DM]/)){var d=function(b){for(var a= +0,c=0,f=0;fa&&(a=b[f].length,c=f);return c};a.setMonth(d(this._get(b,c.match(/MM/)?"monthNames":"monthNamesShort")));a.setDate(d(this._get(b,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())}b.input.attr("size",this._formatDate(b,a).length)}},_inlineDatepicker:function(a,c){var d=b(a);d.hasClass(this.markerClassName)||(d.addClass(this.markerClassName).append(c.dpDiv).bind("setData.datepicker",function(b,a,f){c.settings[a]=f}).bind("getData.datepicker",function(b, +a){return this._get(c,a)}),b.data(a,"datepicker",c),this._setDate(c,this._getDefaultDate(c),!0),this._updateDatepicker(c),this._updateAlternate(c),c.dpDiv.show())},_dialogDatepicker:function(a,c,d,e,h){a=this._dialogInst;a||(this.uuid+=1,this._dialogInput=b(''),this._dialogInput.keydown(this._doKeyDown),b("body").append(this._dialogInput),a=this._dialogInst=this._newInst(this._dialogInput,!1), +a.settings={},b.data(this._dialogInput[0],"datepicker",a));g(a.settings,e||{});c=c&&c.constructor==Date?this._formatDate(a,c):c;this._dialogInput.val(c);this._pos=h?h.length?h:[h.pageX,h.pageY]:null;this._pos||(this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)]);this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+ +"px");a.settings.onSelect=d;this._inDialog=!0;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);b.blockUI&&b.blockUI(this.dpDiv);b.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();b.removeData(a,"datepicker");"input"==e?(d.append.remove(),d.trigger.remove(),c.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown", +this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"==e||"span"==e)&&c.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if("input"==e)a.disabled=!1,d.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if("div"==e||"span"==e)c=c.children("."+this._inlineClass),c.children().removeClass("ui-state-disabled"), +c.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled");this._disabledInputs=b.map(this._disabledInputs,function(b){return b==a?null:b})}},_disableDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if("input"==e)a.disabled=!0,d.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if("div"==e||"span"==e)c=c.children("."+this._inlineClass), +c.children().addClass("ui-state-disabled"),c.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled");this._disabledInputs=b.map(this._disabledInputs,function(b){return b==a?null:b});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(b){if(!b)return!1;for(var a=0;ae||!d||-1n&&n>e?Math.abs(c.left+e-n):0);c.top-=Math.min(c.top,c.top+g>q&&q>g?Math.abs(g+p):0);return c},_findPos:function(a){for(var c= +this._get(this._getInst(a),"isRTL");a&&("hidden"==a.type||1!=a.nodeType||b.expr.filters.hidden(a));)a=a[c?"previousSibling":"nextSibling"];a=b(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");b&&b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var c=this._curInst;if(c&&!(a&&c!=b.data(a,"datepicker"))&&this._datepickerShowing){var a=this._get(c,"showAnim"),d=this._get(c,"duration"),e=function(){b.datepicker._tidyDialog(c); +this._curInst=null};if(b.effects&&b.effects[a])c.dpDiv.hide(a,b.datepicker._get(c,"showOptions"),d,e);else c.dpDiv["slideDown"==a?"slideUp":"fadeIn"==a?"fadeOut":"hide"](a?d:null,e);a||e();b.datepicker._triggerOnClose(c);this._datepickerShowing=!1;this._lastInput=null;this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),b.blockUI&&(b.unblockUI(),b("body").append(this.dpDiv)));this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")}, +_checkExternalClick:function(a){b.datepicker._curInst&&(a=b(a.target),a[0].id!=b.datepicker._mainDivId&&(0==a.parents("#"+b.datepicker._mainDivId).length&&!a.hasClass(b.datepicker.markerClassName)&&!a.hasClass(b.datepicker._triggerClass)&&b.datepicker._datepickerShowing&&(!b.datepicker._inDialog||!b.blockUI))&&b.datepicker._hideDatepicker())},_adjustDate:function(a,c,d){var a=b(a),e=this._getInst(a[0]);this._isDisabledDatepicker(a[0])||(this._adjustInstDate(e,c+("M"==d?this._get(e,"showCurrentAtPos"): +0),d),this._updateDatepicker(e))},_gotoToday:function(a){var a=b(a),c=this._getInst(a[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate();c.drawMonth=c.selectedMonth=d.getMonth();c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c);this._adjustDate(a)},_selectMonthYear:function(a,c,d){var a=b(a),e=this._getInst(a[0]);e._selectingMonthYear= +!1;e["selected"+("M"==d?"Month":"Year")]=e["draw"+("M"==d?"Month":"Year")]=parseInt(c.options[c.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_clickMonthYear:function(a){var c=this._getInst(b(a)[0]);c.input&&c._selectingMonthYear&&setTimeout(function(){c.input.focus()},0);c._selectingMonthYear=!c._selectingMonthYear},_selectDay:function(a,c,d,e){var g=b(a);!b(e).hasClass(this._unselectableClass)&&!this._isDisabledDatepicker(g[0])&&(g=this._getInst(g[0]),g.selectedDay=g.currentDay= +b("a",e).html(),g.selectedMonth=g.currentMonth=c,g.selectedYear=g.currentYear=d,this._selectDate(a,this._formatDate(g,g.currentDay,g.currentMonth,g.currentYear)))},_clearDate:function(a){a=b(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,c){var d=this._getInst(b(a)[0]),c=null!=c?c:this._formatDate(d);d.input&&d.input.val(c);this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[c,d]):d.input&&d.input.trigger("change");d.inline?this._updateDatepicker(d): +(this._hideDatepicker(),this._lastInput=d.input[0],"object"!=typeof d.input[0]&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var c=this._get(a,"altField");if(c){var d=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),g=this.formatDate(d,e,this._getFormatConfig(a));b(c).each(function(){b(this).val(g)})}},noWeekends:function(a){a=a.getDay();return[0a,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b= +a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,c,d){if(null==a||null==c)throw"Invalid arguments";c="object"==typeof c?c.toString():c+"";if(""==c)return null;for(var e=(d?d.shortYearCutoff:null)||this._defaults.shortYearCutoff,e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),g=(d?d.dayNamesShort:null)||this._defaults.dayNamesShort,h=(d?d.dayNames:null)||this._defaults.dayNames,p=(d?d.monthNamesShort:null)||this._defaults.monthNamesShort, +n=(d?d.monthNames:null)||this._defaults.monthNames,q=d=-1,o=-1,w=-1,r=!1,u=function(b){(b=E+1d&&(d+=(new Date).getFullYear()-(new Date).getFullYear()%100+(d<=e?0:-100));if(-1b.getYear()%100?"0":"")+b.getYear()%100;break;case "@":o+=b.getTime();break;case "!":o+=1E4*b.getTime()+this._ticksTo1970;break;case "'":h("'")?o+="'":w=!0;break;default:o+=a.charAt(r)}return o},_possibleChars:function(a){for(var b= +"",c=!1,d=function(b){(b=e+1n&&(n+=12,s--);if(u)for(var v=this._daylightSavingAdjust(new Date(u.getFullYear(),u.getMonth()-p[0]*p[1]+1,u.getDate())),v=r&&vv;)n--,0>n&&(n=11,s--);a.drawMonth=n;a.drawYear=s;var v=this._get(a,"prevText"),v=!m?v:this.formatDate(v,this._daylightSavingAdjust(new Date(s,n-q,1)),this._getFormatConfig(a)), +v=this._canAdjustMonth(a,-1,s,n)?''+v+"":g?"":''+v+"",z=this._get(a,"nextText"),z=!m?z:this.formatDate(z,this._daylightSavingAdjust(new Date(s, +n+q,1)),this._getFormatConfig(a)),g=this._canAdjustMonth(a,1,s,n)?''+z+"":g?"":''+z+"",q=this._get(a,"currentText"),z=this._get(a,"gotoCurrent")&& +a.currentDay?w:c,q=!m?q:this.formatDate(q,z,this._getFormatConfig(a)),m=!a.inline?'":"",e=e?'
          '+(d?m:"")+(this._isInRange(a,z)?'":"")+(d?"":m)+"
          ":"",m=parseInt(this._get(a,"firstDay"),10),m=isNaN(m)?0:m,q=this._get(a,"showWeek"),z=this._get(a,"dayNames");this._get(a,"dayNamesShort");var B=this._get(a,"dayNamesMin"),E=this._get(a,"monthNames"),C=this._get(a,"monthNamesShort"),O=this._get(a,"beforeShowDay"),K=this._get(a,"showOtherMonths"),S=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var P=this._getDefaultDate(a),G="",H=0;H'+(/all|left/.test(A)&& +0==H?d?g:v:"")+(/all|right/.test(A)&&0==H?d?v:g:"")+this._generateMonthYearHeader(a,n,s,r,u,0
          '),D=q?'":"",A=0;7>A;A++)var x=(A+m)%7,D=D+("'+B[x]+"");y+=D+"";D=this._getDaysInMonth(s,n);s==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay, +D));A=(this._getFirstDayOfMonth(s,n)-m+7)%7;D=Math.ceil((A+D)/7);this.maxRows=D=o?this.maxRows>D?this.maxRows:D:D;for(var x=this._daylightSavingAdjust(new Date(s,n,1-A)),R=0;R",M=!q?"":'",A=0;7>A;A++){var J=O?O.apply(a.input?a.input[0]:null,[x]):[!0,""],F=x.getMonth()!=n,N=F&&!S||!J[0]||r&&xu,M=M+('");x.setDate(x.getDate()+1);x=this._daylightSavingAdjust(x)}y+=M+""}n++;11
          '+this._get(a,"weekHeader")+"
          '+this._get(a,"calculateWeek")(x)+""+(F&&!K? +" ":N?''+x.getDate()+"":''+x.getDate()+"")+"
          "+(o?"

        Pivotal has released an update to Spring Tool Suite (STS) and Groovy/Grails Tool Suite (GGTS), the best Eclipse-powered development environment for building Spring, Groovy, and Grails powered enterprise application.

        "+(0
        ':""):"");L+=y}G+=L}G+=e+(b.browser.msie&& +7>parseInt(b.browser.version,10)&&!a.inline?'':"");a._keyEvent=!1;return G},_generateMonthYearHeader:function(a,b,c,d,e,g,p,n){var q=this._get(a,"changeMonth"),o=this._get(a,"changeYear"),w=this._get(a,"showMonthAfterYear"),r='
        ',u="";if(g||!q)u+=''+p[b]+"";else{for(var p=d&&d.getFullYear()==c,s=e&&e.getFullYear()==c,u=u+('"}w||(r+=u+(g||!q||!o?" ":""));if(!a.yearshtml)if(a.yearshtml="",g||!o)r+=''+c+"";else{var n=this._get(a,"yearRange").split(":"),z=(new Date).getFullYear(),p=function(a){a= +a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?z+parseInt(a,10):parseInt(a,10);return isNaN(a)?z:a},b=p(n[0]),n=Math.max(b,p(n[1]||"")),b=d?Math.max(b,d.getFullYear()):b,n=e?Math.min(n,e.getFullYear()):n;for(a.yearshtml+='";r+=a.yearshtml;a.yearshtml=null}r+=this._get(a,"yearSuffix");w&&(r+=(g||!q||!o?" ":"")+u);return r+"
        "},_adjustInstDate:function(a,b,c){var d=a.drawYear+("Y"==c?b:0),e=a.drawMonth+("M"==c?b:0),b=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+("D"==c?b:0),d=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,b)));a.selectedDay=d.getDate();a.drawMonth=a.selectedMonth=d.getMonth();a.drawYear=a.selectedYear=d.getFullYear();("M"==c|| +"Y"==c)&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),c=c&&bd?d:c},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return null==a?[1,1]:"number"==typeof a?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a, +b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),c=this._daylightSavingAdjust(new Date(c,d+(0>b?b:e[0]*e[1]),1));0>b&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<= +d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff"),b="string"!=typeof b?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);b=b?"object"==typeof b?b:this._daylightSavingAdjust(new Date(d, +c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});b.fn.datepicker=function(a){if(!this.length)return this;b.datepicker.initialized||(b(document).mousedown(b.datepicker._checkExternalClick).find("body").append(b.datepicker.dpDiv),b.datepicker.initialized=!0);var c=Array.prototype.slice.call(arguments,1);return"string"==typeof a&&("isDisabled"==a||"getDate"==a||"widget"==a)||"option"== +a&&2==arguments.length&&"string"==typeof arguments[1]?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this[0]].concat(c)):this.each(function(){typeof a=="string"?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this].concat(c)):b.datepicker._attachDatepicker(this,a)})};b.datepicker=new c;b.datepicker.initialized=!1;b.datepicker.uuid=(new Date).getTime();b.datepicker.version="1.8.14";window["DP_jQuery_"+h]=b})(jQuery); +(function(b,a){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("
        ").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"); +this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(b){if(b===a)return this._value();this._setOption("value",b);return this},_setOption:function(a,d){"value"===a&&(this.options.value=d,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete"));b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;"number"!==typeof a&&(a=0);return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100* +this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change"));this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.14"})})(jQuery); +jQuery.effects||function(b,a){function c(a){var c;return a&&a.constructor==Array&&3==a.length?a:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(a))?[2.55*parseFloat(c[1]),2.55*parseFloat(c[2]),2.55*parseFloat(c[3])]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))?[parseInt(c[1],16),parseInt(c[2], +16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(a))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:/rgba\(0, 0, 0, 0\)/.exec(a)?i.transparent:i[b.trim(a).toLowerCase()]}function d(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]])for(var e=a.length;e--;)c=a[e],"string"==typeof a[c]&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c]);else for(c in a)"string"=== +typeof a[c]&&(b[c]=a[c]);return b}function g(a){var c,d;for(c in a)d=a[c],(null==d||b.isFunction(d)||c in k||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete a[c];return a}function h(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function e(a,c,d,e){"object"==typeof a&&(e=c,d=null,c=a,a=c.effect);b.isFunction(c)&&(e=c,d=null,c={});if("number"==typeof c||b.fx.speeds[c])e=d,d=c,c={};b.isFunction(d)&&(e=d,d=null);c=c||{};d=d||c.duration;d=b.fx.off?0:"number"==typeof d? +d:d in b.fx.speeds?b.fx.speeds[d]:b.fx.speeds._default;e=e||c.complete;return[a,c,d,e]}function f(a){return!a||("number"===typeof a||b.fx.speeds[a])||"string"===typeof a&&!b.effects[a]?!0:!1}b.effects={};b.each("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor borderColor color outlineColor".split(" "),function(a,d){b.fx.step[d]=function(a){if(!a.colorInit){var e;e=a.elem;var f=d,g;do{g=b.curCSS(e,f);if(g!=""&&g!="transparent"||b.nodeName(e,"body"))break;f="backgroundColor"}while(e= +e.parentNode);e=c(g);a.start=e;a.end=c(a.end);a.colorInit=true}a.elem.style[d]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var i={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139], +darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255], +maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},j=["add","remove","toggle"],k={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};b.effects.animateClass=function(a,c,e,f){b.isFunction(e)&&(f=e,e=null);return this.queue(function(){var i=b(this),o=i.attr("style")|| +" ",k=g(d.call(this)),r,u=i.attr("class");b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});r=g(d.call(this));i.attr("class",u);i.animate(h(k,r),{queue:false,duration:c,easing:e,complete:function(){b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});if(typeof i.attr("style")=="object"){i.attr("style").cssText="";i.attr("style").cssText=o}else i.attr("style",o);f&&f.apply(this,arguments);b.dequeue(this)}})})};b.fn.extend({_addClass:b.fn.addClass,addClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this, +[{add:a},c,d,e]):this._addClass(a)},_removeClass:b.fn.removeClass,removeClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this,[{remove:a},c,d,e]):this._removeClass(a)},_toggleClass:b.fn.toggleClass,toggleClass:function(c,d,e,f,g){return"boolean"==typeof d||d===a?e?b.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):b.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(a,c,d,e,f){return b.effects.animateClass.apply(this,[{add:c, +remove:a},d,e,f])}});b.extend(b.effects,{version:"1.8.14",save:function(a,b){for(var c=0;c
        ").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});a.wrap(d);d=a.parent();"static"==a.css("position")?(d.css({position:"relative"}),a.css({position:"relative"})): +(b.extend(c,{position:a.css("position"),zIndex:a.css("z-index")}),b.each(["top","left","bottom","right"],function(b,d){c[d]=a.css(d);isNaN(parseInt(c[d],10))&&(c[d]="auto")}),a.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"}));return d.css(c).show()},removeWrapper:function(a){return a.parent().is(".ui-effects-wrapper")?a.parent().replaceWith(a):a},setTransition:function(a,c,d,e){e=e||{};b.each(c,function(b,c){unit=a.cssUnit(c);0(b/=e/2)?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},easeInCubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeOutCubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeInOutCubic:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},easeInQuart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c}, +easeOutQuart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeInOutQuart:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b+c:-d/2*((b-=2)*b*b*b-2)+c},easeInQuint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeOutQuint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeInOutQuint:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c},easeInSine:function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c},easeOutSine:function(a,b,c,d,e){return d*Math.sin(b/ +e*(Math.PI/2))+c},easeInOutSine:function(a,b,c,d,e){return-d/2*(Math.cos(Math.PI*b/e)-1)+c},easeInExpo:function(a,b,c,d,e){return 0==b?c:d*Math.pow(2,10*(b/e-1))+c},easeOutExpo:function(a,b,c,d,e){return b==e?c+d:d*(-Math.pow(2,-10*b/e)+1)+c},easeInOutExpo:function(a,b,c,d,e){return 0==b?c:b==e?c+d:1>(b/=e/2)?d/2*Math.pow(2,10*(b-1))+c:d/2*(-Math.pow(2,-10*--b)+2)+c},easeInCirc:function(a,b,c,d,e){return-d*(Math.sqrt(1-(b/=e)*b)-1)+c},easeOutCirc:function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)* +b)+c},easeInOutCirc:function(a,b,c,d,e){return 1>(b/=e/2)?-d/2*(Math.sqrt(1-b*b)-1)+c:d/2*(Math.sqrt(1-(b-=2)*b)+1)+c},easeInElastic:function(a,b,c,d,e){var a=1.70158,f=0,g=d;if(0==b)return c;if(1==(b/=e))return c+d;f||(f=0.3*e);gb?-0.5*g*Math.pow(2,10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+c:0.5*g*Math.pow(2,-10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+d+c},easeInBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return e*(c/=f)*c*((g+1)*c-g)+d},easeOutBack:function(b,c,d,e, +f,g){g==a&&(g=1.70158);return e*((c=c/f-1)*c*((g+1)*c+g)+1)+d},easeInOutBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return 1>(c/=f/2)?e/2*c*c*(((g*=1.525)+1)*c-g)+d:e/2*((c-=2)*c*(((g*=1.525)+1)*c+g)+2)+d},easeInBounce:function(a,c,d,e,f){return e-b.easing.easeOutBounce(a,f-c,0,e,f)+d},easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:b<2/2.75?d*(7.5625*(b-=1.5/2.75)*b+0.75)+c:b<2.5/2.75?d*(7.5625*(b-=2.25/2.75)*b+0.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+0.984375)+c},easeInOutBounce:function(a, +c,d,e,f){return c").css({position:"absolute",visibility:"visible",left:-j*(e/d),top:-i*(f/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:e/d,height:f/c,left:h.left+j*(e/d)+("show"==a.options.mode?(j-Math.floor(d/2))*(e/d):0),top:h.top+i*(f/c)+("show"==a.options.mode?(i-Math.floor(c/2))*(f/c):0),opacity:"show"==a.options.mode?0:1}).animate({left:h.left+j*(e/d)+("show"==a.options.mode?0:(j-Math.floor(d/2))*(e/d)),top:h.top+ +i*(f/c)+("show"==a.options.mode?0:(i-Math.floor(c/2))*(f/c)),opacity:"show"==a.options.mode?1:0},a.duration||500);setTimeout(function(){"show"==a.options.mode?g.css({visibility:"visible"}):g.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(g[0]);g.dequeue();b("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery); +(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.fold=function(a){return this.queue(function(){var c=b(this),d=["position","top","bottom","left","right"],g=b.effects.setMode(c,a.options.mode||"hide"),h=a.options.size||15,e=!!a.options.horizFirst,f=a.duration?a.duration/2:b.fx.speeds._default/2;b.effects.save(c,d);c.show();var i=b.effects.createWrapper(c).css({overflow:"hidden"}),j="show"==g!=e,k=j?["width","height"]:["height","width"],j=j?[i.width(),i.height()]:[i.height(),i.width()],l=/([0-9]+)%/.exec(h);l&&(h=parseInt(l[1], +10)/100*j["hide"==g?0:1]);"show"==g&&i.css(e?{height:0,width:h}:{height:h,width:0});e={};l={};e[k[0]]="show"==g?j[0]:h;l[k[1]]="show"==g?j[1]:0;i.animate(e,f,a.options.easing).animate(l,f,a.options.easing,function(){"hide"==g&&c.hide();b.effects.restore(c,d);b.effects.removeWrapper(c);a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +(function(b){b.effects.highlight=function(a){return this.queue(function(){var c=b(this),d=["backgroundImage","backgroundColor","opacity"],g=b.effects.setMode(c,a.options.mode||"show"),h={backgroundColor:c.css("backgroundColor")};"hide"==g&&(h.opacity=0);b.effects.save(c,d);c.show().css({backgroundImage:"none",backgroundColor:a.options.color||"#ffff99"}).animate(h,{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){g=="hide"&&c.hide();b.effects.restore(c,d);g=="show"&&!b.support.opacity&& +this.style.removeAttribute("filter");a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.pulsate=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"show");times=2*(a.options.times||5)-1;duration=a.duration?a.duration/2:b.fx.speeds._default/2;isVisible=c.is(":visible");animateTo=0;isVisible||(c.css("opacity",0).show(),animateTo=1);("hide"==d&&isVisible||"show"==d&&!isVisible)&×--;for(d=0;d').appendTo(document.body).addClass(a.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(d,a.duration,a.options.easing,function(){h.remove();a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +/* + * jQuery Highlight plugin + * Based on highlight v3 by Johann Burkard + * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html + * Copyright (c) 2009 Bartek Szopka http://bartaz.github.com/sandbox.js/jquery.highlight.html + * Licensed under MIT license. + */ +jQuery.extend({highlight:function(a,c,b,e){if(a.nodeType===3){if(c=a.data.match(c)){b=document.createElement(b||"span");b.className=e||"highlight";a=a.splitText(c.index);a.splitText(c[0].length);e=a.cloneNode(true);b.appendChild(e);a.parentNode.replaceChild(b,a);return 1}}else if(a.nodeType===1&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&!(a.tagName===b.toUpperCase()&&a.className===e))for(var d=0;d').appendTo("body"); + var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight }; + $c.remove(); + window.scrollbarWidth = d.width; + window.scrollbarHeight = d.height; + return dim.match(/^(width|height)$/) ? d[dim] : d; + } + + + /** + * Returns hash container 'display' and 'visibility' + * + * @see $.swap() - swaps CSS, runs callback, resets CSS + */ +, showInvisibly: function ($E, force) { + if (!$E) return {}; + if (!$E.jquery) $E = $($E); + var CSS = { + display: $E.css('display') + , visibility: $E.css('visibility') + }; + if (force || CSS.display === "none") { // only if not *already hidden* + $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured + return CSS; + } + else return {}; + } + + /** + * Returns data for setting size of an element (container or a pane). + * + * @see _create(), onWindowResize() for container, plus others for pane + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc + */ +, getElementDimensions: function ($E) { + var + d = {} // dimensions hash + , x = d.css = {} // CSS hash + , i = {} // TEMP insets + , b, p // TEMP border, padding + , N = $.layout.cssNum + , off = $E.offset() + ; + d.offsetLeft = off.left; + d.offsetTop = off.top; + + $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge + b = x["border" + e] = $.layout.borderWidth($E, e); + p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e); + i[e] = b + p; // total offset of content from outer side + d["inset"+ e] = p; + }); + + d.offsetWidth = $E.innerWidth(); // offsetWidth is used in calc when doing manual resize + d.offsetHeight = $E.innerHeight(); // ditto + d.outerWidth = $E.outerWidth(); + d.outerHeight = $E.outerHeight(); + d.innerWidth = max(0, d.outerWidth - i.Left - i.Right); + d.innerHeight = max(0, d.outerHeight - i.Top - i.Bottom); + + x.width = $E.width(); + x.height = $E.height(); + x.top = N($E,"top",true); + x.bottom = N($E,"bottom",true); + x.left = N($E,"left",true); + x.right = N($E,"right",true); + + //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0; + + return d; + } + +, getElementCSS: function ($E, list) { + var + CSS = {} + , style = $E[0].style + , props = list.split(",") + , sides = "Top,Bottom,Left,Right".split(",") + , attrs = "Color,Style,Width".split(",") + , p, s, a, i, j, k + ; + for (i=0; i < props.length; i++) { + p = props[i]; + if (p.match(/(border|padding|margin)$/)) + for (j=0; j < 4; j++) { + s = sides[j]; + if (p === "border") + for (k=0; k < 3; k++) { + a = attrs[k]; + CSS[p+s+a] = style[p+s+a]; + } + else + CSS[p+s] = style[p+s]; + } + else + CSS[p] = style[p]; + }; + return CSS + } + + /** + * Return the innerWidth for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerWidth of the elem by subtracting padding and borders + */ +, cssWidth: function ($E, outerWidth) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerWidth <= 0) return 0; + + if (!$.support.boxModel) return outerWidth; + + // strip border and padding from outerWidth to get CSS Width + var W = outerWidth + - b($E, "Left") + - b($E, "Right") + - n($E, "paddingLeft") + - n($E, "paddingRight") + ; + + return max(0,W); + } + + /** + * Return the innerHeight for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerHeight of the elem by subtracting padding and borders + */ +, cssHeight: function ($E, outerHeight) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerHeight <= 0) return 0; + + if (!$.support.boxModel) return outerHeight; + + // strip border and padding from outerHeight to get CSS Height + var H = outerHeight + - b($E, "Top") + - b($E, "Bottom") + - n($E, "paddingTop") + - n($E, "paddingBottom") + ; + + return max(0,H); + } + + /** + * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist + * + * @see Called by many methods + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {string} prop The name of the CSS property, eg: top, width, etc. + * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0 + * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width) + */ +, cssNum: function ($E, prop, allowAuto) { + if (!$E.jquery) $E = $($E); + var CSS = $.layout.showInvisibly($E) + , p = $.curCSS($E[0], prop, true) + , v = allowAuto && p=="auto" ? p : (parseInt(p, 10) || 0); + $E.css( CSS ); // RESET + return v; + } + +, borderWidth: function (el, side) { + if (el.jquery) el = el[0]; + var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left + return $.curCSS(el, b+"Style", true) === "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0); + } + + /** + * Mouse-tracking utility - FUTURE REFERENCE + * + * init: if (!window.mouse) { + * window.mouse = { x: 0, y: 0 }; + * $(document).mousemove( $.layout.trackMouse ); + * } + * + * @param {Object} evt + * +, trackMouse: function (evt) { + window.mouse = { x: evt.clientX, y: evt.clientY }; + } + */ + + /** + * SUBROUTINE for preventPrematureSlideClose option + * + * @param {Object} evt + * @param {Object=} el + */ +, isMouseOverElem: function (evt, el) { + var + $E = $(el || this) + , d = $E.offset() + , T = d.top + , L = d.left + , R = L + $E.outerWidth() + , B = T + $E.outerHeight() + , x = evt.pageX // evt.clientX ? + , y = evt.pageY // evt.clientY ? + ; + // if X & Y are < 0, probably means is over an open SELECT + return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B)); + } + + /** + * Message/Logging Utility + * + * @example $.layout.msg("My message"); // log text + * @example $.layout.msg("My message", true); // alert text + * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title + * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR- + * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data + * + * @param {(Object|string)} info String message OR Hash/Array + * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped + * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped + * @param {Object=} [debutOpts={}] Extra options for debug output + */ +, msg: function (info, popup, debugTitle, debugOpts) { + if ($.isPlainObject(info) && window.debugData) { + if (typeof popup === "string") { + debugOpts = debugTitle; + debugTitle = popup; + } + else if (typeof debugTitle === "object") { + debugOpts = debugTitle; + debugTitle = null; + } + var t = debugTitle || "log( )" + , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts); + if (popup === true || o.display) + debugData( info, t, o ); + else if (window.console) + console.log(debugData( info, t, o )); + } + else if (popup) + alert(info); + else if (window.console) + console.log(info); + else { + var id = "#layoutLogger" + , $l = $(id); + if (!$l.length) + $l = createLog(); + $l.children("ul").append('
      • '+ info.replace(/\/g,">") +'
      • '); + } + + function createLog () { + var pos = $.support.fixedPosition ? 'fixed' : 'absolute' + , $e = $('
        ' + + '
        ' + + 'XLayout console.log
        ' + + '
          ' + + '
          ' + ).appendTo("body"); + $e.css('left', $(window).width() - $e.outerWidth() - 5) + if ($.ui.draggable) $e.draggable({ handle: ':first-child' }); + return $e; + }; + } + +}; + +var lang = $.layout.language; // alias used in defaults... + +// DEFAULT OPTIONS - CHANGE IF DESIRED +$.layout.defaults = { +/* + * LAYOUT & LAYOUT-CONTAINER OPTIONS + * - none of these options are applicable to individual panes + */ + name: "" // Not required, but useful for buttons and used for the state-cookie +, containerSelector: "" // ONLY used when specifying a childOptions - to find container-element that is NOT directly-nested +, containerClass: "ui-layout-container" // layout-container element +, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark) +, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event +, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky +, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized +, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific +, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific +, onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements +, onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized +, onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload +, onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload +, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them +, initPanes: true // false = DO NOT initialize the panes onLoad - will init later +, showErrorMessages: true // enables fatal error messages to warn developers of common errors +, showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code! +// Changing this zIndex value will cause other zIndex values to automatically change +, zIndex: null // the PANE zIndex - resizers and masks will be +1 +// DO NOT CHANGE the zIndex values below unless you clearly understand their relationships +, zIndexes: { // set _default_ z-index values here... + pane_normal: 0 // normal z-index for panes + , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing + , resizer_normal: 2 // normal z-index for resizer-bars + , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open' + , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer + , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged' + } +/* + * PANE DEFAULT SETTINGS + * - settings under the 'panes' key become the default settings for *all panes* + * - ALL pane-options can also be set specifically for each panes, which will override these 'default values' + */ +, panes: { // default options for 'all panes' - will be overridden by 'per-pane settings' + applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity + , closable: true // pane can open & close + , resizable: true // when open, pane can be resized + , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out + , initClosed: false // true = init pane as 'closed' + , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing + // SELECTORS + //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane + , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane! + , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content' + , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector) + // GENERIC ROOT-CLASSES - for auto-generated classNames + , paneClass: "ui-layout-pane" // Layout Pane + , resizerClass: "ui-layout-resizer" // Resizer Bar + , togglerClass: "ui-layout-toggler" // Toggler Button + , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin' + // ELEMENT SIZE & SPACING + //, size: 100 // MUST be pane-specific -initial size of pane + , minSize: 0 // when manually resizing a pane + , maxSize: 0 // ditto, 0 = no limit + , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open' + , spacing_closed: 6 // ditto - when pane is 'closed' + , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides + , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden' + , togglerAlign_open: "center" // top/left, bottom/right, center, OR... + , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right + , togglerTip_open: lang.Close // Toggler tool-tip (title) + , togglerTip_closed: lang.Open // ditto + , togglerContent_open: "" // text or HTML to put INSIDE the toggler + , togglerContent_closed: "" // ditto + // RESIZING OPTIONS + , resizerDblClickToggle: true // + , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes + , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed + , resizerDragOpacity: 1 // option for ui.draggable + //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar + , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES + , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask + , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes + , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20] + , livePaneResizing: false // true = LIVE Resizing as resizer is dragged + , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged + , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance + // TIPS & MESSAGES - also see lang object + , noRoomToOpenTip: lang.noRoomToOpenTip + , resizerTip: lang.Resize // Resizer tool-tip (title) + , sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed + , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding' + , slideTrigger_open: "click" // click, dblclick, mouseenter + , slideTrigger_close: "mouseleave"// click, mouseleave + , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open + , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!) + , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show? + , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening + , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + // HOT-KEYS & MISC + , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver + , enableCursorHotkey: true // enabled 'cursor' hotkeys + //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character + , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT' + // PANE ANIMATION + // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed + , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size' + , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration + , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 } + , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation + , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called + /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set: + fxName_open: "slide" // 'Open' pane animation + fnName_close: "slide" // 'Close' pane animation + fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true + fxSpeed_open: null + fxSpeed_close: null + fxSpeed_size: null + fxSettings_open: {} + fxSettings_close: {} + fxSettings_size: {} + */ + // CHILD/NESTED LAYOUTS + , childOptions: null // Layout-options for nested/child layout - even {} is valid as options + , initChildLayout: true // true = child layout will be created as soon as _this_ layout completes initialization + , destroyChildLayout: true // true = destroy child-layout if this pane is destroyed + , resizeChildLayout: true // true = trigger child-layout.resizeAll() when this pane is resized + // PANE CALLBACKS + , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes + , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true + , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start + , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end + , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start + , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end + , onopen_start: null // CALLBACK when pane STARTS to Open + , onopen_end: null // CALLBACK when pane ENDS being Opened + , onclose_start: null // CALLBACK when pane STARTS to Close + , onclose_end: null // CALLBACK when pane ENDS being Closed + , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON*** + , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON*** + , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS + , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS + , onswap_start: null // CALLBACK when pane STARTS to Swap + , onswap_end: null // CALLBACK when pane ENDS being Swapped + , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized + , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized + } +/* + * PANE-SPECIFIC SETTINGS + * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes' + * - all options under the 'panes' key can also be set specifically for any pane + * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane + */ +, north: { + paneSelector: ".ui-layout-north" + , size: "auto" // eg: "auto", "30%", .30, 200 + , resizerCursor: "n-resize" // custom = url(myCursor.cur) + , customHotkey: "" // EITHER a charCode (43) OR a character ("o") + } +, south: { + paneSelector: ".ui-layout-south" + , size: "auto" + , resizerCursor: "s-resize" + , customHotkey: "" + } +, east: { + paneSelector: ".ui-layout-east" + , size: 200 + , resizerCursor: "e-resize" + , customHotkey: "" + } +, west: { + paneSelector: ".ui-layout-west" + , size: 200 + , resizerCursor: "w-resize" + , customHotkey: "" + } +, center: { + paneSelector: ".ui-layout-center" + , minWidth: 0 + , minHeight: 0 + } +}; + +$.layout.optionsMap = { + // layout/global options - NOT pane-options + layout: ("stateManagement,effects,zIndexes," + + "name,zIndex,scrollToBookmarkOnLoad,showErrorMessages," + + "resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay," + + "onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons").split(",") +// borderPanes: [ ALL options that are NOT specified as 'layout' ] + // default.panes options that apply to the center-pane (most options apply _only_ to border-panes) +, center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad," + + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing," + + "childOptions,initChildLayout,resizeChildLayout,destroyChildLayout," + + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",") + // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key +, noDefault: ("paneSelector,resizerCursor,customHotkey").split(",") +}; + +/** + * Processes options passed in converts flat-format data into subkey (JSON) format + * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName + * Plugins may also call this method so they can transform their own data + * + * @param {!Object} hash Data/options passed by user - may be a single level or nested levels + * @return {Object} Returns hash of minWidth & minHeight + */ +$.layout.transformData = function (hash) { + var json = { panes: {}, center: {} } // init return object + , data, branch, optKey, keys, key, val, i, c; + + if (typeof hash !== "object") return json; // no options passed + + // convert all 'flat-keys' to 'sub-key' format + for (optKey in hash) { + branch = json; + data = $.layout.optionsMap.layout; + val = hash[ optKey ]; + keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration + c = keys.length - 1; + // convert underscore-delimited to subkeys + for (i=0; i <= c; i++) { + key = keys[i]; + if (i === c) + branch[key] = val; + else if (!branch[key]) + branch[key] = {}; // create the subkey + // recurse to sub-key for next loop - if not done + branch = branch[key]; + } + } + + return json; +} + +// INTERNAL CONFIG DATA - DO NOT CHANGE THIS! +$.layout.backwardCompatibility = { + // data used by renameOldOptions() + map: { + // OLD Option Name: NEW Option Name + applyDefaultStyles: "applyDemoStyles" + , resizeNestedLayout: "resizeChildLayout" + , resizeWhileDragging: "livePaneResizing" + , resizeContentWhileDragging: "liveContentResizing" + , triggerEventsWhileDragging: "triggerEventsDuringLiveResize" + , maskIframesOnResize: "maskContents" + , useStateCookie: "stateManagement.enabled" + , "cookie.autoLoad": "stateManagement.autoLoad" + , "cookie.autoSave": "stateManagement.autoSave" + , "cookie.keys": "stateManagement.stateKeys" + , "cookie.name": "stateManagement.cookie.name" + , "cookie.domain": "stateManagement.cookie.domain" + , "cookie.path": "stateManagement.cookie.path" + , "cookie.expires": "stateManagement.cookie.expires" + , "cookie.secure": "stateManagement.cookie.secure" + } + /** + * @param {Object} opts + */ +, renameOptions: function (opts) { + var map = $.layout.backwardCompatibility.map + , oldData, newData, value + ; + for (var itemPath in map) { + oldData = getBranch( itemPath ); + value = oldData.branch[ oldData.key ] + if (value !== undefined) { + newData = getBranch( map[itemPath], true ) + newData.branch[ newData.key ] = value; + delete oldData.branch[ oldData.key ]; + } + } + + /** + * @param {string} path + * @param {boolean=} [create=false] Create path if does not exist + */ + function getBranch (path, create) { + var a = path.split(".") // split keys into array + , c = a.length - 1 + , D = { branch: opts, key: a[c] } // init branch at top & set key (last item) + , i = 0, k, undef; + for (; i 0) { + if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + // make hidden, then visible to 'refresh' display after animation + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerHeight + * @param {boolean=} [autoHide=false] + */ +, setOuterHeight = function (el, outerHeight, autoHide) { + var $E = el, h; + if (isStr(el)) $E = $Ps[el]; // west + else if (!el.jquery) $E = $(el); + h = cssH($E, outerHeight); + $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent + if (h > 0 && $E.innerWidth() > 0) { + if (autoHide && $E.data('autoHidden')) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerSize + * @param {boolean=} [autoHide=false] + */ +, setOuterSize = function (el, outerSize, autoHide) { + if (_c[pane].dir=="horz") // pane = north or south + setOuterHeight(el, outerSize, autoHide); + else // pane = east or west + setOuterWidth(el, outerSize, autoHide); + } + + + /** + * Converts any 'size' params to a pixel/integer size, if not already + * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated + * + /** + * @param {string} pane + * @param {(string|number)=} size + * @param {string=} [dir] + * @return {number} + */ +, _parseSize = function (pane, size, dir) { + if (!dir) dir = _c[pane].dir; + + if (isStr(size) && size.match(/%/)) + size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal + + if (size === 0) + return 0; + else if (size >= 1) + return parseInt(size, 10); + + var o = options, avail = 0; + if (dir=="horz") // north or south or center.minHeight + avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0); + else if (dir=="vert") // east or west or center.minWidth + avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0); + + if (size === -1) // -1 == 100% + return avail; + else if (size > 0) // percentage, eg: .25 + return round(avail * size); + else if (pane=="center") + return 0; + else { // size < 0 || size=='auto' || size==Missing || size==Invalid + // auto-size the pane + var dim = (dir === "horz" ? "height" : "width") + , $P = $Ps[pane] + , $C = dim === 'height' ? $Cs[pane] : false + , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden + , szP = $P.css(dim) // SAVE current pane size + , szC = $C ? $C.css(dim) : 0 // SAVE current content size + ; + $P.css(dim, "auto"); + if ($C) $C.css(dim, "auto"); + size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE + $P.css(dim, szP).css(vis); // RESET size & visibility + if ($C) $C.css(dim, szC); + return size; + } + } + + /** + * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added + * + * @param {(string|!Object)} pane + * @param {boolean=} [inclSpace=false] + * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser + */ +, getPaneSize = function (pane, inclSpace) { + var + $P = $Ps[pane] + , o = options[pane] + , s = state[pane] + , oSp = (inclSpace ? o.spacing_open : 0) + , cSp = (inclSpace ? o.spacing_closed : 0) + ; + if (!$P || s.isHidden) + return 0; + else if (s.isClosed || (s.isSliding && inclSpace)) + return cSp; + else if (_c[pane].dir === "horz") + return $P.outerHeight() + oSp; + else // dir === "vert" + return $P.outerWidth() + oSp; + } + + /** + * Calculate min/max pane dimensions and limits for resizing + * + * @param {string} pane + * @param {boolean=} [slide=false] + */ +, setSizeLimits = function (pane, slide) { + if (!isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , dir = c.dir + , side = c.side.toLowerCase() + , type = c.sizeType.toLowerCase() + , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param + , $P = $Ps[pane] + , paneSpacing = o.spacing_open + // measure the pane on the *opposite side* from this pane + , altPane = _c.oppositeEdge[pane] + , altS = state[altPane] + , $altP = $Ps[altPane] + , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth())) + , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0) + // limitSize prevents this pane from 'overlapping' opposite pane + , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth) + , minCenterDims = cssMinDims("center") + , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth) + // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them + , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing))) + , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize ) + , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize ) + , r = s.resizerPosition = {} // used to set resizing limits + , top = sC.insetTop + , left = sC.insetLeft + , W = sC.innerWidth + , H = sC.innerHeight + , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east + ; + switch (pane) { + case "north": r.min = top + minSize; + r.max = top + maxSize; + break; + case "west": r.min = left + minSize; + r.max = left + maxSize; + break; + case "south": r.min = top + H - maxSize - rW; + r.max = top + H - minSize - rW; + break; + case "east": r.min = left + W - maxSize - rW; + r.max = left + W - minSize - rW; + break; + }; + } + + /** + * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes + * + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height + */ +, calcNewCenterPaneDims = function () { + var d = { + top: getPaneSize("north", true) // true = include 'spacing' value for pane + , bottom: getPaneSize("south", true) + , left: getPaneSize("west", true) + , right: getPaneSize("east", true) + , width: 0 + , height: 0 + }; + + // NOTE: sC = state.container + // calc center-pane outer dimensions + d.width = sC.innerWidth - d.left - d.right; // outerWidth + d.height = sC.innerHeight - d.bottom - d.top; // outerHeight + // add the 'container border/padding' to get final positions relative to the container + d.top += sC.insetTop; + d.bottom += sC.insetBottom; + d.left += sC.insetLeft; + d.right += sC.insetRight; + + return d; + } + + + /** + * @param {!Object} el + * @param {boolean=} [allStates=false] + */ +, getHoverClasses = function (el, allStates) { + var + $El = $(el) + , type = $El.data("layoutRole") + , pane = $El.data("layoutEdge") + , o = options[pane] + , root = o[type +"Class"] + , _pane = "-"+ pane // eg: "-west" + , _open = "-open" + , _closed = "-closed" + , _slide = "-sliding" + , _hover = "-hover " // NOTE the trailing space + , _state = $El.hasClass(root+_closed) ? _closed : _open + , _alt = _state === _closed ? _open : _closed + , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover) + ; + if (allStates) // when 'removing' classes, also remove alternate-state classes + classes += (root+_alt+_hover) + (root+_pane+_alt+_hover); + + if (type=="resizer" && $El.hasClass(root+_slide)) + classes += (root+_slide+_hover) + (root+_pane+_slide+_hover); + + return $.trim(classes); + } +, addHover = function (evt, el) { + var $E = $(el || this); + if (evt && $E.data("layoutRole") === "toggler") + evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar + $E.addClass( getHoverClasses($E) ); + } +, removeHover = function (evt, el) { + var $E = $(el || this); + $E.removeClass( getHoverClasses($E, true) ); + } + +, onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter + if ($.fn.disableSelection) + $("body").disableSelection(); + } +, onResizerLeave = function (evt, el) { + var + e = el || this // el is only passed when called by the timer + , pane = $(e).data("layoutEdge") + , name = pane +"ResizerLeave" + ; + timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set + timer.clear(name); // cancel enableSelection timer - may re/set below + // this method calls itself on a timer because it needs to allow + // enough time for dragging to kick-in and set the isResizing flag + // dragging has a 100ms delay set, so this delay must be >100 + if (!el) // 1st call - mouseleave event + timer.set(name, function(){ onResizerLeave(evt, e); }, 200); + // if user is resizing, then dragStop will enableSelection(), so can skip it here + else if (!state[pane].isResizing && $.fn.enableSelection) // 2nd call - by timer + $("body").enableSelection(); + } + +/* + * ########################### + * INITIALIZATION METHODS + * ########################### + */ + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see none - triggered onInit + * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort + */ +, _create = function () { + // initialize config/options + initOptions(); + var o = options; + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // init plugins for this layout, if there are any (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onCreate ); + + // options & state have been initialized, so now run beforeLoad callback + // onload will CANCEL layout creation if it returns false + if (false === _runCallbacks("onload_start")) + return 'cancel'; + + // initialize the container element + _initContainer(); + + // bind hotkey function - keyDown - if required + initHotkeys(); + + // bind window.onunload + $(window).bind("unload."+ sID, unload); + + // init plugins for this layout, if there are any (eg: customButtons) + runPluginCallbacks( Instance, $.layout.onLoad ); + + // if layout elements are hidden, then layout WILL NOT complete initialization! + // initLayoutElements will set initialized=true and run the onload callback IF successful + if (o.initPanes) _initLayoutElements(); + + delete state.creatingLayout; + + return state.initialized; + } + + /** + * Initialize the layout IF not already + * + * @see All methods in Instance run this test + * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet) + */ +, isInitialized = function () { + if (state.initialized || state.creatingLayout) return true; // already initialized + else return _initLayoutElements(); // try to init panes NOW + } + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see _create() & isInitialized + * @return An object pointer to the instance created + */ +, _initLayoutElements = function (retry) { + // initialize config/options + var o = options; + + // CANNOT init panes inside a hidden container! + if (!$N.is(":visible")) { + // handle Chrome bug where popup window 'has no height' + // if layout is BODY element, try again in 50ms + // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html + if ( !retry && browser.webkit && $N[0].tagName === "BODY" ) + setTimeout(function(){ _initLayoutElements(true); }, 50); + return false; + } + + // a center pane is required, so make sure it exists + if (!getPane("center").length) { + if (options.showErrorMessages) + _log( lang.errCenterPaneMissing, true ); + return false; + } + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // update Container dims + $.extend(sC, elDims( $N )); + + // initialize all layout elements + initPanes(); // size & position panes - calls initHandles() - which calls initResizable() + + if (o.scrollToBookmarkOnLoad) { + var l = self.location; + if (l.hash) l.replace( l.hash ); // scrollTo Bookmark + } + + // check to see if this layout 'nested' inside a pane + if (Instance.hasParentLayout) + o.resizeWithWindow = false; + // bind resizeAll() for 'this layout instance' to window.resize event + else if (o.resizeWithWindow) + $(window).bind("resize."+ sID, windowResize); + + delete state.creatingLayout; + state.initialized = true; + + // init plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onReady ); + + // now run the onload callback, if exists + _runCallbacks("onload_end"); + + return true; // elements initialized successfully + } + + /** + * Initialize nested layouts - called when _initLayoutElements completes + * + * NOT CURRENTLY USED + * + * @see _initLayoutElements + * @return An object pointer to the instance created + */ +, _initChildLayouts = function () { + $.each(_c.allPanes, function (idx, pane) { + if (options[pane].initChildLayout) + createChildLayout( pane ); + }); + } + + /** + * Initialize nested layouts for a specific pane - can optionally pass layout-options + * + * @see _initChildLayouts + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].childOptions + * @return An object pointer to the layout instance created - or null + */ +, createChildLayout = function (evt_or_pane, opts) { + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , C = children + ; + if ($P) { + var $C = $Cs[pane] + , o = opts || options[pane].childOptions + , d = "layout" + // determine which element is supposed to be the 'child container' + // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane + , $Cont = o.containerSelector ? $P.find( o.containerSelector ) : ($C || $P) + , containerFound = $Cont.length + // see if a child-layout ALREADY exists on this element + , child = containerFound ? (C[pane] = $Cont.data(d) || null) : null + ; + // if no layout exists, but childOptions are set, try to create the layout now + if (!child && containerFound && o) + child = C[pane] = $Cont.eq(0).layout(o) || null; + if (child) + child.hasParentLayout = true; // set parent-flag in child + } + Instance[pane].child = C[pane]; // ALWAYS set pane-object pointer, even if null + } + +, windowResize = function () { + var delay = Number(options.resizeWithWindowDelay); + if (delay < 10) delay = 100; // MUST have a delay! + // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway + timer.clear("winResize"); // if already running + timer.set("winResize", function(){ + timer.clear("winResize"); + timer.clear("winResizeRepeater"); + var dims = elDims( $N ); + // only trigger resizeAll() if container has changed size + if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight) + resizeAll(); + }, delay); + // ALSO set fixed-delay timer, if not already running + if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater(); + } + +, setWindowResizeRepeater = function () { + var delay = Number(options.resizeWithWindowMaxDelay); + if (delay > 0) + timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay); + } + +, unload = function () { + var o = options; + + _runCallbacks("onunload_start"); + + // trigger plugin callabacks for this layout (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onUnload ); + + _runCallbacks("onunload_end"); + } + + /** + * Validate and initialize container CSS and events + * + * @see _create() + */ +, _initContainer = function () { + var + N = $N[0] + , tag = sC.tagName = N.tagName + , id = sC.id = N.id + , cls = sC.className = N.className + , o = options + , name = o.name + , fullPage= (tag === "BODY") + , props = "overflow,position,margin,padding,border" + , css = "layoutCSS" + , CSS = {} + , hid = "hidden" // used A LOT! + // see if this container is a 'pane' inside an outer-layout + , parent = $N.data("parentLayout") // parent-layout Instance + , pane = $N.data("layoutEdge") // pane-name in parent-layout + , isChild = parent && pane + ; + // sC -> state.container + sC.selector = $N.selector.split(".slice")[0]; + sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages + + $N .data({ + layout: Instance + , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID + }) + .addClass(o.containerClass) + ; + var layoutMethods = { + destroy: '' + , initPanes: '' + , resizeAll: 'resizeAll' + , resize: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in layoutMethods) { + $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]); + } + + // if this container is another layout's 'pane', then set child/parent pointers + if (isChild) { + // update parent flag + Instance.hasParentLayout = true; + // set pointers to THIS child-layout (Instance) in parent-layout + // NOTE: parent.PANE.child is an ALIAS to parent.children.PANE + parent[pane].child = parent.children[pane] = $N.data("layout"); + } + + // SAVE original container CSS for use in destroy() + if (!$N.data(css)) { + // handle props like overflow different for BODY & HTML - has 'system default' values + if (fullPage) { + CSS = $.extend( elCSS($N, props), { + height: $N.css("height") + , overflow: $N.css("overflow") + , overflowX: $N.css("overflowX") + , overflowY: $N.css("overflowY") + }); + // ALSO SAVE CSS + var $H = $("html"); + $H.data(css, { + height: "auto" // FF would return a fixed px-size! + , overflow: $H.css("overflow") + , overflowX: $H.css("overflowX") + , overflowY: $H.css("overflowY") + }); + } + else // handle props normally for non-body elements + CSS = elCSS($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"); + + $N.data(css, CSS); + } + + try { // format html/body if this is a full page layout + if (fullPage) { + $("html").css({ + height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + }); + $("body").css({ + position: "relative" + , height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + , margin: 0 + , padding: 0 // TODO: test whether body-padding could be handled? + , border: "none" // a body-border creates problems because it cannot be measured! + }); + + // set current layout-container dimensions + $.extend(sC, elDims( $N )); + } + else { // set required CSS for overflow and position + // ENSURE container will not 'scroll' + CSS = { overflow: hid, overflowX: hid, overflowY: hid } + var + p = $N.css("position") + , h = $N.css("height") + ; + // if this is a NESTED layout, then container/outer-pane ALREADY has position and height + if (!isChild) { + if (!p || !p.match(/fixed|absolute|relative/)) + CSS.position = "relative"; // container MUST have a 'position' + /* + if (!h || h=="auto") + CSS.height = "100%"; // container MUST have a 'height' + */ + } + $N.css( CSS ); + + // set current layout-container dimensions + if ( $N.is(":visible") ) { + $.extend(sC, elDims( $N )); + if (o.showErrorMessages && sC.innerHeight < 1) + _log( lang.errContainerHeight.replace(/CONTAINER/, sC.ref), true ); + } + } + } catch (ex) {} + } + + /** + * Bind layout hotkeys - if options enabled + * + * @see _create() and addPane() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHotkeys = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + // bind keyDown to capture hotkeys, if option enabled for ANY pane + $.each(panes, function (i, pane) { + var o = options[pane]; + if (o.enableCursorHotkey || o.customHotkey) { + $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE + return false; // BREAK - binding was done + } + }); + } + + /** + * Build final OPTIONS data + * + * @see _create() + */ +, initOptions = function () { + var data, d, pane, key, val, i, c, o; + + // reprocess user's layout-options to have correct options sub-key structure + opts = $.layout.transformData( opts ); // panes = default subkey + + // auto-rename old options for backward compatibility + opts = $.layout.backwardCompatibility.renameAllOptions( opts ); + + // if user-options has 'panes' key (pane-defaults), process it... + if (!$.isEmptyObject(opts.panes)) { + // REMOVE any pane-defaults that MUST be set per-pane + data = $.layout.optionsMap.noDefault; + for (i=0, c=data.length; i 0) { + z.pane_normal = zo; + z.content_mask = max(zo+1, z.content_mask); // MIN = +1 + z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2 + } + + function createFxOptions ( pane ) { + var o = options[pane] + , d = options.panes; + // ensure fxSettings key to avoid errors + if (!o.fxSettings) o.fxSettings = {}; + if (!d.fxSettings) d.fxSettings = {}; + + $.each(["_open","_close","_size"], function (i,n) { + var + sName = "fxName"+ n + , sSpeed = "fxSpeed"+ n + , sSettings = "fxSettings"+ n + // recalculate fxName according to specificity rules + , fxName = o[sName] = + o[sName] // options.west.fxName_open + || d[sName] // options.panes.fxName_open + || o.fxName // options.west.fxName + || d.fxName // options.panes.fxName + || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0 + ; + // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects + if (fxName === "none" || !$.effects || !$.effects[fxName] || !options.effects[fxName]) + fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName + + // set vars for effects subkeys to simplify logic + var fx = options.effects[fxName] || {} // effects.slide + , fx_all = fx.all || null // effects.slide.all + , fx_pane = fx[pane] || null // effects.slide.west + ; + // create fxSpeed[_open|_close|_size] + o[sSpeed] = + o[sSpeed] // options.west.fxSpeed_open + || d[sSpeed] // options.west.fxSpeed_open + || o.fxSpeed // options.west.fxSpeed + || d.fxSpeed // options.panes.fxSpeed + || null // DEFAULT - let fxSetting.duration control speed + ; + // create fxSettings[_open|_close|_size] + o[sSettings] = $.extend( + {} + , fx_all // effects.slide.all + , fx_pane // effects.slide.west + , d.fxSettings // options.panes.fxSettings + , o.fxSettings // options.west.fxSettings + , d[sSettings] // options.panes.fxSettings_open + , o[sSettings] // options.west.fxSettings_open + ); + }); + + // DONE creating action-specific-settings for this pane, + // so DELETE generic options - are no longer meaningful + delete o.fxName; + delete o.fxSpeed; + delete o.fxSettings; + } + + // DELETE 'panes' key now that we are done - values were copied to EACH pane + delete options.panes; + } + + /** + * Initialize module objects, styling, size and position for all panes + * + * @see _initElements() + * @param {string} pane The pane to process + */ +, getPane = function (pane) { + var sel = options[pane].paneSelector + if (sel.substr(0,1)==="#") // ID selector + // NOTE: elements selected 'by ID' DO NOT have to be 'children' + return $N.find(sel).eq(0); + else { // class or other selector + var $P = $N.children(sel).eq(0); + // look for the pane nested inside a 'form' element + return $P.length ? $P : $N.children("form:first").children(sel).eq(0); + } + } + +, initPanes = function () { + // NOTE: do north & south FIRST so we can measure their height - do center LAST + $.each(_c.allPanes, function (idx, pane) { + addPane( pane, true ); + }); + + // init the pane-handles NOW in case we have to hide or close the pane below + initHandles(); + + // now that all panes have been initialized and initially-sized, + // make sure there is really enough space available for each pane + $.each(_c.borderPanes, function (i, pane) { + if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN + setSizeLimits(pane); + makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit() + } + }); + // size center-pane AGAIN in case we 'closed' a border-pane in loop above + sizeMidPanes("center"); + + // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing! + // Before RC30.3, there was a 10ms delay here, but that caused layout + // to load asynchrously, which is BAD, so try skipping delay for now + + // process pane contents and callbacks, and init/resize child-layout if exists + $.each(_c.allPanes, function (i, pane) { + var o = options[pane]; + if ($Ps[pane]) { + if (state[pane].isVisible) { // pane is OPEN + sizeContent(pane); + // trigger pane.onResize if triggerEventsOnLoad = true + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); + } + // init childLayout - even if pane is not visible + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + }); + } + + /** + * Add a pane to the layout - subroutine of initPanes() + * + * @see initPanes() + * @param {string} pane The pane to process + * @param {boolean=} [force=false] Size content after init + */ +, addPane = function (pane, force) { + if (!force && !isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , fx = s.fx + , dir = c.dir + , spacing = o.spacing_open || 0 + , isCenter = (pane === "center") + , CSS = {} + , $P = $Ps[pane] + , size, minSize, maxSize + ; + // if pane-pointer already exists, remove the old one first + if ($P) + removePane( pane, false, true, false ); + else + $Cs[pane] = false; // init + + $P = $Ps[pane] = getPane(pane); + if (!$P.length) { + $Ps[pane] = false; // logic + return; + } + + // SAVE original Pane CSS + if (!$P.data("layoutCSS")) { + var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border"; + $P.data("layoutCSS", elCSS($P, props)); + } + + // create alias for pane data in Instance - initHandles will add more + Instance[pane] = { name: pane, pane: $Ps[pane], content: $Cs[pane], options: options[pane], state: state[pane], child: children[pane] }; + + // add classes, attributes & events + $P .data({ + parentLayout: Instance // pointer to Layout Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "pane" + }) + .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal) + .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles + .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector' + .bind("mouseenter."+ sID, addHover ) + .bind("mouseleave."+ sID, removeHover ) + ; + var paneMethods = { + hide: '' + , show: '' + , toggle: '' + , close: '' + , open: '' + , slideOpen: '' + , slideClose: '' + , slideToggle: '' + , size: 'manualSizePane' + , sizePane: 'manualSizePane' + , sizeContent: '' + , sizeHandles: '' + , enableClosable: '' + , disableClosable: '' + , enableSlideable: '' + , disableSlideable: '' + , enableResizable: '' + , disableResizable: '' + , swapPanes: 'swapPanes' + , swap: 'swapPanes' + , move: 'swapPanes' + , removePane: 'removePane' + , remove: 'removePane' + , createChildLayout: '' + , resizeChildLayout: '' + , resizeAll: 'resizeAll' + , resizeLayout: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in paneMethods) { + $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]); + } + + // see if this pane has a 'scrolling-content element' + initContent(pane, false); // false = do NOT sizeContent() - called later + + if (!isCenter) { + // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden) + // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size' + size = s.size = _parseSize(pane, o.size); + minSize = _parseSize(pane,o.minSize) || 1; + maxSize = _parseSize(pane,o.maxSize) || 100000; + if (size > 0) size = max(min(size, maxSize), minSize); + + // state for border-panes + s.isClosed = false; // true = pane is closed + s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes + s.isResizing= false; // true = pane is in process of being resized + s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible! + + // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close + if (!s.pins) s.pins = []; + } + // states common to ALL panes + s.tagName = $P[0].tagName; + s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going) + s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically + s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic + + // set css-position to account for container borders & padding + switch (pane) { + case "north": CSS.top = sC.insetTop; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "south": CSS.bottom = sC.insetBottom; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes() + break; + case "east": CSS.right = sC.insetRight; // ditto + break; + case "center": // top, left, width & height set by sizeMidPanes() + } + + if (dir === "horz") // north or south pane + CSS.height = cssH($P, size); + else if (dir === "vert") // east or west pane + CSS.width = cssW($P, size); + //else if (isCenter) {} + + $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes + if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback + + // close or hide the pane if specified in settings + if (o.initClosed && o.closable && !o.initHidden) + close(pane, true, true); // true, true = force, noAnimation + else if (o.initHidden || o.initClosed) + hide(pane); // will be completely invisible - no resizer or spacing + else if (!s.noRoom) + // make the pane visible - in case was initially hidden + $P.css("display","block"); + // ELSE setAsOpen() - called later by initHandles() + + // RESET visibility now - pane will appear IF display:block + $P.css("visibility","visible"); + + // check option for auto-handling of pop-ups & drop-downs + if (o.showOverflowOnHover) + $P.hover( allowOverflow, resetOverflow ); + + // if manually adding a pane AFTER layout initialization, then... + if (state.initialized) { + initHandles( pane ); + initHotkeys( pane ); + resizeAll(); // will sizeContent if pane is visible + if (s.isVisible) { // pane is OPEN + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); // a previously existing childLayout + } + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + } + + /** + * Initialize module objects, styling, size and position for all resize bars and toggler buttons + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHandles = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + + // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV + $.each(panes, function (i, pane) { + var $P = $Ps[pane]; + $Rs[pane] = false; // INIT + $Ts[pane] = false; + if (!$P) return; // pane does not exist - skip + + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , rClass = o.resizerClass + , tClass = o.togglerClass + , side = c.side.toLowerCase() + , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed) + , _pane = "-"+ pane // used for classNames + , _state = (s.isVisible ? "-open" : "-closed") // used for classNames + , I = Instance[pane] + // INIT RESIZER BAR + , $R = I.resizer = $Rs[pane] = $("
          ") + // INIT TOGGLER BUTTON + , $T = I.toggler = (o.closable ? $Ts[pane] = $("
          ") : false) + ; + + //if (s.isVisible && o.resizable) ... handled by initResizable + if (!s.isVisible && o.slidable) + $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor); + + $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "resizer" + }) + .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal) + .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles + .addClass(rClass +" "+ rClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead + .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter + .appendTo($N) // append DIV to container + ; + + if ($T) { + $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "toggler" + }) + .css(_c.togglers.cssReq) // add base/required styles + .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles + .addClass(tClass +" "+ tClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead + .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer + .appendTo($R) // append SPAN to resizer DIV + ; + // ADD INNER-SPANS TO TOGGLER + if (o.togglerContent_open) // ui-layout-open + $(""+ o.togglerContent_open +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .data("layoutRole", "togglerContent") + .data("layoutEdge", pane) + .addClass("content content-open") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead! + ; + if (o.togglerContent_closed) // ui-layout-closed + $(""+ o.togglerContent_closed +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .addClass("content content-closed") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead! + ; + // ADD TOGGLER.click/.hover + enableClosable(pane); + } + + // add Draggable events + initResizable(pane); + + // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open" + if (s.isVisible) + setAsOpen(pane); // onOpen will be called, but NOT onResize + else { + setAsClosed(pane); // onClose will be called + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + }); + + // SET ALL HANDLE DIMENSIONS + sizeHandles(); + } + + + /** + * Initialize scrolling ui-layout-content div - if exists + * + * @see initPane() - or externally after an Ajax injection + * @param {string} [pane] The pane to process + * @param {boolean=} [resize=true] Size content after init + */ +, initContent = function (pane, resize) { + if (!isInitialized()) return; + var + o = options[pane] + , sel = o.contentSelector + , I = Instance[pane] + , $P = $Ps[pane] + , $C + ; + if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent) + ? $P.find(sel).eq(0) // match 1-element only + : $P.children(sel).eq(0) + ; + if ($C && $C.length) { + $C.data("layoutRole", "content"); + // SAVE original Pane CSS + if (!$C.data("layoutCSS")) + $C.data("layoutCSS", elCSS($C, "height")); + $C.css( _c.content.cssReq ); + if (o.applyDemoStyles) { + $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div + $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane + } + state[pane].content = {}; // init content state + if (resize !== false) sizeContent(pane); + // sizeContent() is called AFTER init of all elements + } + else + I.content = $Cs[pane] = false; + } + + + /** + * Add resize-bars to all panes that specify it in options + * -dependancy: $.fn.resizable - will skip if not found + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initResizable = function (panes) { + var draggingAvailable = $.layout.plugins.draggable + , side // set in start() + ; + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (idx, pane) { + var o = options[pane]; + if (!draggingAvailable || !$Ps[pane] || !o.resizable) { + o.resizable = false; + return true; // skip to next + } + + var s = state[pane] + , z = options.zIndexes + , c = _c[pane] + , side = c.dir=="horz" ? "top" : "left" + , opEdge = _c.oppositeEdge[pane] + , masks = pane +",center,"+ opEdge + (c.dir=="horz" ? ",west,east" : "") + , $P = $Ps[pane] + , $R = $Rs[pane] + , base = o.resizerClass + , lastPos = 0 // used when live-resizing + , r, live // set in start because may change + // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process + , resizerClass = base+"-drag" // resizer-drag + , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag + // 'helper' class is applied to the CLONED resizer-bar while it is being dragged + , helperClass = base+"-dragging" // resizer-dragging + , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging + , helperLimitClass = base+"-dragging-limit" // resizer-drag + , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag + , helperClassesSet = false // logic var + ; + + if (!s.isClosed) + $R.attr("title", o.resizerTip) + .css("cursor", o.resizerCursor); // n-resize, s-resize, etc + + $R.draggable({ + containment: $N[0] // limit resizing to layout container + , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis + , delay: 0 + , distance: 1 + , grid: o.resizingGrid + // basic format for helper - style it using class: .ui-draggable-dragging + , helper: "clone" + , opacity: o.resizerDragOpacity + , addClasses: false // avoid ui-state-disabled class when disabled + //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed + , zIndex: z.resizer_drag + + , start: function (e, ui) { + // REFRESH options & state pointers in case we used swapPanes + o = options[pane]; + s = state[pane]; + // re-read options + live = o.livePaneResizing; + + // ondrag_start callback - will CANCEL hide if returns false + // TODO: dragging CANNOT be cancelled like this, so see if there is a way? + if (false === _runCallbacks("ondrag_start", pane)) return false; + + s.isResizing = true; // prevent pane from closing while resizing + timer.clear(pane+"_closeSlider"); // just in case already triggered + + // SET RESIZER LIMITS - used in drag() + setSizeLimits(pane); // update pane/resizer state + r = s.resizerPosition; + lastPos = ui.position[ side ] + + $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes + helperClassesSet = false; // reset logic var - see drag() + + // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver) + $('body').disableSelection(); + + // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS + showMasks( masks ); + } + + , drag: function (e, ui) { + if (!helperClassesSet) { // can only add classes after clone has been added to the DOM + //$(".ui-draggable-dragging") + ui.helper + .addClass( helperClass +" "+ helperPaneClass ) // add helper classes + .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue + .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar + ; + helperClassesSet = true; + // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane! + if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding); + } + // CONTAIN RESIZER-BAR TO RESIZING LIMITS + var limit = 0; + if (ui.position[side] < r.min) { + ui.position[side] = r.min; + limit = -1; + } + else if (ui.position[side] > r.max) { + ui.position[side] = r.max; + limit = 1; + } + // ADD/REMOVE dragging-limit CLASS + if (limit) { + ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit + window.defaultStatus = (limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? lang.maxSizeWarning : lang.minSizeWarning; + } + else { + ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit + window.defaultStatus = ""; + } + // DYNAMICALLY RESIZE PANES IF OPTION ENABLED + // won't trigger unless resizer has actually moved! + if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) { + lastPos = ui.position[side]; + resizePanes(e, ui, pane) + } + } + + , stop: function (e, ui) { + $('body').enableSelection(); // RE-ENABLE TEXT SELECTION + window.defaultStatus = ""; // clear 'resizing limit' message from statusbar + $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer + s.isResizing = false; + resizePanes(e, ui, pane, true, masks); // true = resizingDone + } + + }); + }); + + /** + * resizePanes + * + * Sub-routine called from stop() - and drag() if livePaneResizing + * + * @param {!Object} evt + * @param {!Object} ui + * @param {string} pane + * @param {boolean=} [resizingDone=false] + */ + var resizePanes = function (evt, ui, pane, resizingDone, masks) { + var dragPos = ui.position + , c = _c[pane] + , o = options[pane] + , s = state[pane] + , resizerPos + ; + switch (pane) { + case "north": resizerPos = dragPos.top; break; + case "west": resizerPos = dragPos.left; break; + case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break; + case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break; + }; + // remove container margin from resizer position to get the pane size + var newSize = resizerPos - sC["inset"+ c.side]; + + // Disable OR Resize Mask(s) created in drag.start + if (!resizingDone) { + // ensure we meet liveResizingTolerance criteria + if (Math.abs(newSize - s.size) < o.liveResizingTolerance) + return; // SKIP resize this time + // resize the pane + manualSizePane(pane, newSize, false, true); // true = noAnimation + sizeMasks(); // resize all visible masks + } + else { // resizingDone + // ondrag_end callback + if (false !== _runCallbacks("ondrag_end", pane)) + manualSizePane(pane, newSize, false, true); // true = noAnimation + hideMasks(); // hide all masks, which include panes with 'content/iframe-masks' + if (s.isSliding && masks) // RE-SHOW only 'object-masks' so objects won't show through sliding pane + showMasks( masks, true ); // true = onlyForObjects + } + }; + } + + /** + * sizeMask + * + * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane + * Called when mask created, and during livePaneResizing + */ +, sizeMask = function () { + var $M = $(this) + , pane = $M.data("layoutMask") // eg: "west" + , s = state[pane] + ; + // only masks over an IFRAME-pane need manual resizing + if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes + $M.css({ + top: s.offsetTop + , left: s.offsetLeft + , width: s.outerWidth + , height: s.outerHeight + }); + /* ALT Method... + var $P = $Ps[pane]; + $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight }); + */ + } +, sizeMasks = function () { + $Ms.each( sizeMask ); // resize all 'visible' masks + } + +, showMasks = function (panes, onlyForObjects) { + var a = panes ? panes.split(",") : $.layout.config.allPanes + , z = options.zIndexes + , o, s; + $.each(a, function(i,p){ + s = state[p]; + o = options[p]; + if (s.isVisible && ( (!onlyForObjects && o.maskContents) || o.maskObjects )) { + getMasks(p).each(function(){ + sizeMask.call(this); + this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1 + this.style.display = "block"; + }); + } + }); + } + +, hideMasks = function () { + // ensure no pane is resizing - could be a timing issue + var skip; + $.each( $.layout.config.borderPanes, function(i,p){ + if (state[p].isResizing) { + skip = true; + return false; // BREAK + } + }); + if (!skip) + $Ms.hide(); // hide ALL masks + } + +, getMasks = function (pane) { + var $Masks = $([]) + , $M, i = 0, c = $Ms.length + ; + for (; i CSS + if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET CSS + $N.css( $N.data(css) ).removeData(css); + + // trigger plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onDestroy ); + + // trigger state-management and onunload callback + unload(); + + // clear the Instance of everything except for container & options (so could recreate) + // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options ); + for (n in Instance) + if (!n.match(/^(container|options)$/)) delete Instance[ n ]; + // add a 'destroyed' flag to make it easy to check + Instance.destroyed = true; + + // if this is a child layout, CLEAR the child-pointer in the parent + /* for now the pointer REMAINS, but with only container, options and destroyed keys + if (parentPane) { + var layout = parentPane.pane.data("parentLayout"); + parentPane.child = layout.children[ parentPane.name ] = null; + } + */ + + return Instance; // for coding convenience + } + + /** + * Remove a pane from the layout - subroutine of destroy() + * + * @see destroy() + * @param {string} pane The pane to process + * @param {boolean=} [remove=false] Remove the DOM element? + * @param {boolean=} [skipResize=false] Skip calling resizeAll()? + */ +, removePane = function (evt_or_pane, remove, skipResize, destroyChild) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $C = $Cs[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + ; + //alert( '$P.length = '+ $P.length ); + // NOTE: elements can still exist even after remove() + // so check for missing data(), which is cleared by removed() + if ($P && $.isEmptyObject( $P.data() )) $P = false; + if ($C && $.isEmptyObject( $C.data() )) $C = false; + if ($R && $.isEmptyObject( $R.data() )) $R = false; + if ($T && $.isEmptyObject( $T.data() )) $T = false; + + if ($P) $P.stop(true, true); + + // check for a child layout + var o = options[pane] + , s = state[pane] + , d = "layout" + , css = "layoutCSS" + , child = children[pane] || ($P ? $P.data(d) : 0) || ($C ? $C.data(d) : 0) || null + , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildLayout + ; + + // FIRST destroy the child-layout(s) + if (destroy && child && !child.destroyed) { + child.destroy(true); // tell child-layout to destroy ALL its child-layouts too + if (child.destroyed) // destroy was successful + child = null; // clear pointer for logic below + } + + if ($P && remove && !child) + $P.remove(); + else if ($P && $P[0]) { + // create list of ALL pane-classes that need to be removed + var root = o.paneClass // default="ui-layout-pane" + , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west" + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes + pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes + ; + $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes + // remove all Layout classes from pane-element + $P .removeClass( classes.join(" ") ) // remove ALL pane-classes + .removeData("parentLayout") + .removeData("layoutPane") + .removeData("layoutRole") + .removeData("layoutEdge") + .removeData("autoHidden") // in case set + .unbind("."+ sID) // remove ALL Layout events + // TODO: remove these extra unbind commands when jQuery is fixed + //.unbind("mouseenter"+ sID) + //.unbind("mouseleave"+ sID) + ; + // do NOT reset CSS if this pane/content is STILL the container of a nested layout! + // the nested layout will reset its 'container' CSS when/if it is destroyed + if ($C && $C.data(d)) { + // a content-div may not have a specific width, so give it one to contain the Layout + $C.width( $C.width() ); + child.resizeAll(); // now resize the Layout + } + else if ($C) + $C.css( $C.data(css) ).removeData(css).removeData("layoutRole"); + // remove pane AFTER content in case there was a nested layout + if (!$P.data(d)) + $P.css( $P.data(css) ).removeData(css); + } + + // REMOVE pane resizer and toggler elements + if ($T) $T.remove(); + if ($R) $R.remove(); + + // CLEAR all pointers and state data + Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = children[pane] = false; + s = { removed: true }; + + if (!skipResize) + resizeAll(); + } + + +/* + * ########################### + * ACTION METHODS + * ########################### + */ + +, _hidePane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , s = $P[0].style + ; + if (o.useOffscreenClose) { + if (!$P.data(_c.offscreenReset)) + $P.data(_c.offscreenReset, { left: s.left, right: s.right }); + $P.css( _c.offscreenCSS ); + } + else + $P.hide().removeData(_c.offscreenReset); + } + +, _showPane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , off = _c.offscreenCSS + , old = $P.data(_c.offscreenReset) + , s = $P[0].style + ; + $P .show() // ALWAYS show, just in case + .removeData(_c.offscreenReset); + if (o.useOffscreenClose && old) { + if (s.left == off.left) + s.left = old.left; + if (s.right == off.right) + s.right = old.right; + } + } + + + /** + * Completely 'hides' a pane, including its spacing - as if it does not exist + * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it + * + * @param {string} pane The pane being hidden, ie: north, south, east, or west + * @param {boolean=} [noAnimation=false] + */ +, hide = function (evt_or_pane, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || s.isHidden) return; // pane does not exist OR is already hidden + + // onhide_start callback - will CANCEL hide if returns false + if (state.initialized && false === _runCallbacks("onhide_start", pane)) return; + + s.isSliding = false; // just in case + + // now hide the elements + if ($R) $R.hide(); // hide resizer-bar + if (!state.initialized || s.isClosed) { + s.isClosed = true; // to trigger open-animation on show() + s.isHidden = true; + s.isVisible = false; + if (!state.initialized) + _hidePane(pane); // no animation when loading page + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center"); + if (state.initialized || o.triggerEventsOnLoad) + _runCallbacks("onhide_end", pane); + } + else { + s.isHiding = true; // used by onclose + close(pane, false, noAnimation); // adjust all panes to fit + } + } + + /** + * Show a hidden pane - show as 'closed' by default unless openPane = true + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [openPane=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, show = function (evt_or_pane, openPane, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden + + // onshow_start callback - will CANCEL show if returns false + if (false === _runCallbacks("onshow_start", pane)) return; + + s.isSliding = false; // just in case + s.isShowing = true; // used by onopen/onclose + //s.isHidden = false; - will be set by open/close - if not cancelled + + // now show the elements + //if ($R) $R.show(); - will be shown by open/close + if (openPane === false) + close(pane, true); // true = force + else + open(pane, false, noAnimation, noAlert); // adjust all panes to fit + } + + + /** + * Toggles a pane open/closed by calling either open or close + * + * @param {string} pane The pane being toggled, ie: north, south, east, or west + * @param {boolean=} [slide=false] + */ +, toggle = function (evt_or_pane, slide) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + ; + if (evt) // called from to $R.dblclick OR triggerPaneEvent + evt.stopImmediatePropagation(); + if (s.isHidden) + show(pane); // will call 'open' after unhiding it + else if (s.isClosed) + open(pane, !!slide); + else + close(pane); + } + + + /** + * Utility method used during init or other auto-processes + * + * @param {string} pane The pane being closed + * @param {boolean=} [setHandles=false] + */ +, _closePane = function (pane, setHandles) { + var + $P = $Ps[pane] + , s = state[pane] + ; + _hidePane(pane); + s.isClosed = true; + s.isVisible = false; + // UNUSED: if (setHandles) setAsClosed(pane, true); // true = force + } + + /** + * Close the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being closed, ie: north, south, east, or west + * @param {boolean=} [force=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [skipCallback=false] + */ +, close = function (evt_or_pane, force, noAnimation, skipCallback) { + var pane = evtPane.call(this, evt_or_pane); + // if pane has been initialized, but NOT the complete layout, close pane instantly + if (!state.initialized && $Ps[pane]) { + _closePane(pane); // INIT pane as closed + return; + } + if (!isInitialized()) return; + + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing, isHiding, wasSliding; + + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ??? + || (!force && s.isClosed && !s.isShowing) // already closed + ) return queueNext(); + + // onclose_start callback - will CANCEL hide if returns false + // SKIP if just 'showing' a hidden pane as 'closed' + var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane); + + // transfer logic vars to temp vars + isShowing = s.isShowing; + isHiding = s.isHiding; + wasSliding = s.isSliding; + // now clear the logic vars (REQUIRED before aborting) + delete s.isShowing; + delete s.isHiding; + + if (abort) return queueNext(); + + doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none"); + s.isMoving = true; + s.isClosed = true; + s.isVisible = false; + // update isHidden BEFORE sizing panes + if (isHiding) s.isHidden = true; + else if (isShowing) s.isHidden = false; + + if (s.isSliding) // pane is being closed, so UNBIND trigger events + bindStopSlidingEvents(pane, false); // will set isSliding=false + else // resize panes adjacent to this one + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback + + // if this pane has a resizer bar, move it NOW - before animation + setAsClosed(pane); + + // CLOSE THE PANE + if (doFX) { // animate the close + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () { + lockPaneForFX(pane, false); // undo + if (s.isClosed) close_2(); + queueNext(); + }); + } + else { // hide the pane without animation + _hidePane(pane); + close_2(); + queueNext(); + }; + }); + + // SUBROUTINE + function close_2 () { + s.isMoving = false; + bindStartSlidingEvent(pane, true); // will enable if o.slidable = true + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane ); + } + + // hide any masks shown while closing + hideMasks(); + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) { + // onclose callback - UNLESS just 'showing' a hidden pane as 'closed' + if (!isShowing) _runCallbacks("onclose_end", pane); + // onhide OR onshow callback + if (isShowing) _runCallbacks("onshow_end", pane); + if (isHiding) _runCallbacks("onhide_end", pane); + } + } + } + + /** + * @param {string} pane The pane just closed, ie: north, south, east, or west + */ +, setAsClosed = function (pane) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + ; + $R + .css(side, sC[inset]) // move the resizer + .removeClass( rClass+_open +" "+ rClass+_pane+_open ) + .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + .addClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .unbind("dblclick."+ sID) + ; + // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent? + if (o.resizable && $.layout.plugins.draggable) + $R + .draggable("disable") + .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here + .css("cursor", "default") + .attr("title","") + ; + + // if pane has a toggler button, adjust that too + if ($T) { + $T + .removeClass( tClass+_open +" "+ tClass+_pane+_open ) + .addClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .attr("title", o.togglerTip_closed) // may be blank + ; + // toggler-content - if exists + $T.children(".content-open").hide(); + $T.children(".content-closed").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, false); + + if (state.initialized) { + // resize 'length' and position togglers for adjacent panes + sizeHandles(); + } + } + + /** + * Open the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [slide=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, open = function (evt_or_pane, slide, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.resizable && !o.closable && !s.isShowing) // invalid request + || (s.isVisible && !s.isSliding) // already open + ) return queueNext(); + + // pane can ALSO be unhidden by just calling show(), so handle this scenario + if (s.isHidden && !s.isShowing) { + queueNext(); // call before show() because it needs the queue free + show(pane, true); + return; + } + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else + // make sure there is enough space available to open the pane + setSizeLimits(pane, slide); + + // onopen_start callback - will CANCEL open if returns false + var cbReturn = _runCallbacks("onopen_start", pane); + + if (cbReturn === "abort") + return queueNext(); + + // update pane-state again in case options were changed in onopen_start + if (cbReturn !== "NC") // NC = "No Callback" + setSizeLimits(pane, slide); + + if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN! + syncPinBtns(pane, false); // make sure pin-buttons are reset + if (!noAlert && o.noRoomToOpenTip) + alert(o.noRoomToOpenTip); + return queueNext(); // ABORT + } + + if (slide) // START Sliding - will set isSliding=true + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead + bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false + else if (o.slidable) + bindStartSlidingEvent(pane, false); // UNBIND trigger events + + s.noRoom = false; // will be reset by makePaneFit if 'noRoom' + makePaneFit(pane); + + // transfer logic var to temp var + isShowing = s.isShowing; + // now clear the logic var + delete s.isShowing; + + doFX = !noAnimation && s.isClosed && (o.fxName_open != "none"); + s.isMoving = true; + s.isVisible = true; + s.isClosed = false; + // update isHidden BEFORE sizing panes - WHY??? Old? + if (isShowing) s.isHidden = false; + + if (doFX) { // ANIMATE + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + if (s.isSliding) masks += ","+ _c.oppositeEdge[pane]; + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() { + lockPaneForFX(pane, false); // undo + if (s.isVisible) open_2(); // continue + queueNext(); + }); + } + else { // no animation + _showPane(pane);// just show pane and... + open_2(); // continue + queueNext(); + }; + }); + + // SUBROUTINE + function open_2 () { + s.isMoving = false; + + // cure iframe display issues + _fixIframe(pane); + + // NOTE: if isSliding, then other panes are NOT 'resized' + if (!s.isSliding) { // resize all panes adjacent to this one + hideMasks(); // remove any masks shown while opening + sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback + } + + // set classes, position handles and execute callbacks... + setAsOpen(pane); + }; + + } + + /** + * @param {string} pane The pane just opened, ie: north, south, east, or west + * @param {boolean=} [skipCallback=false] + */ +, setAsOpen = function (pane, skipCallback) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _closed = "-closed" + , _sliding= "-sliding" + ; + $R + .css(side, sC[inset] + getPaneSize(pane)) // move the resizer + .removeClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .addClass( rClass+_open +" "+ rClass+_pane+_open ) + ; + if (s.isSliding) + $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + else // in case 'was sliding' + $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + + if (o.resizerDblClickToggle) + $R.bind("dblclick", toggle ); + removeHover( 0, $R ); // remove hover classes + if (o.resizable && $.layout.plugins.draggable) + $R .draggable("enable") + .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + else if (!s.isSliding) + $R.css("cursor", "default"); // n-resize, s-resize, etc + + // if pane also has a toggler button, adjust that too + if ($T) { + $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .addClass( tClass+_open +" "+ tClass+_pane+_open ) + .attr("title", o.togglerTip_open); // may be blank + removeHover( 0, $T ); // remove hover classes + // toggler-content - if exists + $T.children(".content-closed").hide(); + $T.children(".content-open").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, !s.isSliding); + + // update pane-state dimensions - BEFORE resizing content + $.extend(s, elDims($P)); + + if (state.initialized) { + // resize resizer & toggler sizes for all panes + sizeHandles(); + // resize content every time pane opens - to be sure + sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving' + } + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) { + // onopen callback + _runCallbacks("onopen_end", pane); + // onshow callback - TODO: should this be here? + if (s.isShowing) _runCallbacks("onshow_end", pane); + + // ALSO call onresize because layout-size *may* have changed while pane was closed + if (state.initialized) + _runCallbacks("onresize_end", pane); + } + + // TODO: Somehow sizePane("north") is being called after this point??? + } + + + /** + * slideOpen / slideClose / slideToggle + * + * Pass-though methods for sliding + */ +, slideOpen = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + , delay = options[pane].slideDelay_open + ; + // prevent event from triggering on NEW resizer binding created below + if (evt) evt.stopImmediatePropagation(); + + if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0) + // trigger = mouseenter - use a delay + timer.set(pane+"_openSlider", open_NOW, delay); + else + open_NOW(); // will unbind events if is already open + + /** + * SUBROUTINE for timed open + */ + function open_NOW () { + if (!s.isClosed) // skip if no longer closed! + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (!s.isMoving) + open(pane, true); // true = slide - open() will handle binding + }; + } + +, slideClose = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override + ; + if (s.isClosed || s.isResizing) + return; // skip if already closed OR in process of resizing + else if (o.slideTrigger_close === "click") + close_NOW(); // close immediately onClick + else if (o.preventQuickSlideClose && s.isMoving) + return; // handle Chrome quick-close on slide-open + else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane])) + return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + else if (evt) // trigger = mouseleave - use a delay + // 1 sec delay if 'opening', else .3 sec + timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay)); + else // called programically + close_NOW(); + + /** + * SUBROUTINE for timed close + */ + function close_NOW () { + if (s.isClosed) // skip 'close' if already closed! + bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here? + else if (!s.isMoving) + close(pane); // close will handle unbinding + }; + } + + /** + * @param {string} pane The pane being opened, ie: north, south, east, or west + */ +, slideToggle = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + toggle(pane, true); + } + + + /** + * Must set left/top on East/South panes so animation will work properly + * + * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored! + * @param {boolean} doLock true = set left/top, false = remove + */ +, lockPaneForFX = function (pane, doLock) { + var $P = $Ps[pane] + , s = state[pane] + , o = options[pane] + , z = options.zIndexes + ; + if (doLock) { + $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation + if (pane=="south") + $P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() }); + else if (pane=="east") + $P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() }); + } + else { // animation DONE - RESET CSS + // TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + if (pane=="south") + $P.css({ top: "auto" }); + // if pane is positioned 'off-screen', then DO NOT screw with it! + else if (pane=="east" && !$P.css("left").match(/\-99999/)) + $P.css({ left: "auto" }); + // fix anti-aliasing in IE - only needed for animations that change opacity + if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1) + $P[0].style.removeAttribute('filter'); + } + } + + + /** + * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger + * + * @see open(), close() + * @param {string} pane The pane to enable/disable, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable sliding? + */ +, bindStartSlidingEvent = function (pane, enable) { + var o = options[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , evtName = o.slideTrigger_open.toLowerCase() + ; + if (!$R || (enable && !o.slidable)) return; + + // make sure we have a valid event + if (evtName.match(/mouseover/)) + evtName = o.slideTrigger_open = "mouseenter"; + else if (!evtName.match(/click|dblclick|mouseenter/)) + evtName = o.slideTrigger_open = "click"; + + $R + // add or remove event + [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen) + // set the appropriate cursor & title/tip + .css("cursor", enable ? o.sliderCursor : "default") + .attr("title", enable ? o.sliderTip : "") + ; + } + + /** + * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed + * Also increases zIndex when pane is sliding open + * See bindStartSlidingEvent for code to control 'slide open' + * + * @see slideOpen(), slideClose() + * @param {string} pane The pane to process, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable events? + */ +, bindStopSlidingEvents = function (pane, enable) { + var o = options[pane] + , s = state[pane] + , c = _c[pane] + , z = options.zIndexes + , evtName = o.slideTrigger_close.toLowerCase() + , action = (enable ? "bind" : "unbind") + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + s.isSliding = enable; // logic + timer.clear(pane+"_closeSlider"); // just in case + + // remove 'slideOpen' event from resizer + // ALSO will raise the zIndex of the pane & resizer + if (enable) bindStartSlidingEvent(pane, false); + + // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not + $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal); + $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1 + + // make sure we have a valid event + if (!evtName.match(/click|mouseleave/)) + evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout' + + // add/remove slide triggers + $R[action](evtName, slideClose); // base event on resize + // need extra events for mouseleave + if (evtName === "mouseleave") { + // also close on pane.mouseleave + $P[action]("mouseleave."+ sID, slideClose); + // cancel timer when mouse moves between 'pane' and 'resizer' + $R[action]("mouseenter."+ sID, cancelMouseOut); + $P[action]("mouseenter."+ sID, cancelMouseOut); + } + + if (!enable) + timer.clear(pane+"_closeSlider"); + else if (evtName === "click" && !o.resizable) { + // IF pane is not resizable (which already has a cursor and tip) + // then set the a cursor & title/tip on resizer when sliding + $R.css("cursor", enable ? o.sliderCursor : "default"); + $R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane" + } + + // SUBROUTINE for mouseleave timer clearing + function cancelMouseOut (evt) { + timer.clear(pane+"_closeSlider"); + evt.stopPropagation(); + } + } + + + /** + * Hides/closes a pane if there is insufficient room - reverses this when there is room again + * MUST have already called setSizeLimits() before calling this method + * + * @param {string} pane The pane being resized + * @param {boolean=} [isOpening=false] Called from onOpen? + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, makePaneFit = function (pane, isOpening, skipCallback, force) { + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isSidePane = c.dir==="vert" + , hasRoom = false + ; + // special handling for center & east/west panes + if (pane === "center" || (isSidePane && s.noVerticalRoom)) { + // see if there is enough room to display the pane + // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth); + hasRoom = (s.maxHeight >= 0); + if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now + _showPane(pane); + if ($R) $R.show(); + s.isVisible = true; + s.noRoom = false; + if (isSidePane) s.noVerticalRoom = false; + _fixIframe(pane); + } + else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now + _hidePane(pane); + if ($R) $R.hide(); + s.isVisible = false; + s.noRoom = true; + } + } + + // see if there is enough room to fit the border-pane + if (pane === "center") { + // ignore center in this block + } + else if (s.minSize <= s.maxSize) { // pane CAN fit + hasRoom = true; + if (s.size > s.maxSize) // pane is too big - shrink it + sizePane(pane, s.maxSize, skipCallback, force, true); // true = noAnimation + else if (s.size < s.minSize) // pane is too small - enlarge it + sizePane(pane, s.minSize, skipCallback, force, true); + // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen + else if ($R && s.isVisible && $P.is(":visible")) { + // make sure resizer-bar is positioned correctly + // handles situation where nested layout was 'hidden' when initialized + var side = c.side.toLowerCase() + , pos = s.size + sC["inset"+ c.side] + ; + if ($.layout.cssNum($R, side) != pos) $R.css( side, pos ); + } + + // if was previously hidden due to noRoom, then RESET because NOW there is room + if (s.noRoom) { + // s.noRoom state will be set by open or show + if (s.wasOpen && o.closable) { + if (o.autoReopen) + open(pane, false, true, true); // true = noAnimation, true = noAlert + else // leave the pane closed, so just update state + s.noRoom = false; + } + else + show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert + } + } + else { // !hasRoom - pane CANNOT fit + if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now... + s.noRoom = true; // update state + s.wasOpen = !s.isClosed && !s.isSliding; + if (s.isClosed){} // SKIP + else if (o.closable) // 'close' if possible + close(pane, true, true); // true = force, true = noAnimation + else // 'hide' pane if cannot just be closed + hide(pane, true); // true = noAnimation + } + } + } + + + /** + * sizePane / manualSizePane + * sizePane is called only by internal methods whenever a pane needs to be resized + * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized' + * + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [noAnimation=false] + */ +, manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete... + , forceResize = o.livePaneResizing && !s.isResizing + ; + // ANY call to manualSizePane disables autoResize - ie, percentage sizing + o.autoResize = false; + // flow-through... + sizePane(pane, size, skipCallback, forceResize, noAnimation); // will animate resize if option enabled + } + + /** + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] Force resizing even if does not seem necessary + * @param {boolean=} [noAnimation=false] + */ +, sizePane = function (evt_or_pane, size, skipCallback, force, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event? + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , side = _c[pane].side.toLowerCase() + , dimName = _c[pane].sizeType.toLowerCase() + , inset = "inset"+ _c[pane].side + , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize + , doFX = noAnimation !== true && o.animatePaneSizing + , oldSize, newSize + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + // calculate 'current' min/max sizes + setSizeLimits(pane); // update pane-state + oldSize = s.size; + size = _parseSize(pane, size); // handle percentages & auto + size = max(size, _parseSize(pane, o.minSize)); + size = min(size, s.maxSize); + if (size < s.minSize) { // not enough room for pane! + queueNext(); // call before makePaneFit() because it needs the queue free + makePaneFit(pane, false, skipCallback); // will hide or close pane + return; + } + + // IF newSize is same as oldSize, then nothing to do - abort + if (!force && size === oldSize) + return queueNext(); + + // onresize_start callback CANNOT cancel resizing because this would break the layout! + if (!skipCallback && state.initialized && s.isVisible) + _runCallbacks("onresize_start", pane); + + // resize the pane, and make sure its visible + newSize = cssSize(pane, size); + + if (doFX && $P.is(":visible")) { // ANIMATE + var fx = $.layout.effects.size[pane] || $.layout.effects.size.all + , easing = o.fxSettings_size.easing || fx.easing + , z = options.zIndexes + , props = {}; + props[ dimName ] = newSize +'px'; + s.isMoving = true; + // overlay all elements during animation + $P.css({ zIndex: z.pane_animate }) + .show().animate( props, o.fxSpeed_size, easing, function(){ + // reset zIndex after animation + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + s.isMoving = false; + sizePane_2(); // continue + queueNext(); + }); + } + else { // no animation + $P.css( dimName, newSize ); // resize pane + // if pane is visible, then + if ($P.is(":visible")) + sizePane_2(); // continue + else { + // pane is NOT VISIBLE, so just update state data... + // when pane is *next opened*, it will have the new size + s.size = size; // update state.size + $.extend(s, elDims($P)); // update state dimensions + } + queueNext(); + }; + + }); + + // SUBROUTINE + function sizePane_2 () { + /* Panes are sometimes not sized precisely in some browsers!? + * This code will resize the pane up to 3 times to nudge the pane to the correct size + */ + var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight() + , tries = [{ + pane: pane + , count: 1 + , target: size + , actual: actual + , correct: (size === actual) + , attempt: size + , cssSize: newSize + }] + , lastTry = tries[0] + , msg = 'Inaccurate size after resizing the '+ pane +'-pane.' + ; + while ( !lastTry.correct ) { + thisTry = { pane: pane, count: lastTry.count+1, target: size }; + + if (lastTry.actual > size) + thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size)); + else // lastTry.actual < size + thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual)); + + thisTry.cssSize = cssSize(pane, thisTry.attempt); + $P.css( dimName, thisTry.cssSize ); + + thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight(); + thisTry.correct = (size === thisTry.actual); + + // if showDebugMessages, log attempts and alert the user of this *non-fatal error* + if (options.showDebugMessages) { + if ( tries.length === 1) { + _log(msg, false); + _log(lastTry, false); + } + _log(thisTry, false); + } + + // after 4 tries, is as close as its gonna get! + if (tries.length > 3) break; + + tries.push( thisTry ); + lastTry = tries[ tries.length - 1 ]; + } + // END TESTING CODE + + // update pane-state dimensions + s.size = size; + $.extend(s, elDims($P)); + + if (s.isVisible && $P.is(":visible")) { + // reposition the resizer-bar + if ($R) $R.css( side, size + sC[inset] ); + // resize the content-div + sizeContent(pane); + } + + if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible) + _runCallbacks("onresize_end", pane); + + // resize all the adjacent panes, and adjust their toggler buttons + // when skipCallback passed, it means the controlling method will handle 'other panes' + if (!skipCallback) { + // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize + if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force); + sizeHandles(); + } + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (size < oldSize && state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane, false, skipCallback ); + } + + // DEBUG - ALERT user/developer so they know there was a sizing problem + if (options.showDebugMessages && tries.length > 1) + _log(msg +'\nSee the Error Console for details.', true); + } + } + + /** + * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide() + * @param {string} panes The pane(s) being resized, comma-delmited string + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, sizeMidPanes = function (panes, skipCallback, force) { + panes = (panes ? panes : "east,west,center").split(","); + + $.each(panes, function (i, pane) { + if (!$Ps[pane]) return; // NO PANE - skip + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isCenter= (pane=="center") + , hasRoom = true + , CSS = {} + , newCenter = calcNewCenterPaneDims() + ; + // update pane-state dimensions + $.extend(s, elDims($P)); + + if (pane === "center") { + if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // set state for makePaneFit() logic + $.extend(s, cssMinDims(pane), { + maxWidth: newCenter.width + , maxHeight: newCenter.height + }); + CSS = newCenter; + // convert OUTER width/height to CSS width/height + CSS.width = cssW($P, CSS.width); + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, CSS.height); + hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW + // during layout init, try to shrink east/west panes to make room for center + if (!state.initialized && o.minWidth > s.outerWidth) { + var + reqPx = o.minWidth - s.outerWidth + , minE = options.east.minSize || 0 + , minW = options.west.minSize || 0 + , sizeE = state.east.size + , sizeW = state.west.size + , newE = sizeE + , newW = sizeW + ; + if (reqPx > 0 && state.east.isVisible && sizeE > minE) { + newE = max( sizeE-minE, sizeE-reqPx ); + reqPx -= sizeE-newE; + } + if (reqPx > 0 && state.west.isVisible && sizeW > minW) { + newW = max( sizeW-minW, sizeW-reqPx ); + reqPx -= sizeW-newW; + } + // IF we found enough extra space, then resize the border panes as calculated + if (reqPx === 0) { + if (sizeE != minE) + sizePane('east', newE, true, force, true); // true = skipCallback/noAnimation - initPanes will handle when done + if (sizeW != minW) + sizePane('west', newW, true, force, true); + // now start over! + sizeMidPanes('center', skipCallback, force); + return; // abort this loop + } + } + } + else { // for east and west, set only the height, which is same as center height + // set state.min/maxWidth/Height for makePaneFit() logic + if (s.isVisible && !s.noVerticalRoom) + $.extend(s, elDims($P), cssMinDims(pane)) + if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // east/west have same top, bottom & height as center + CSS.top = newCenter.top; + CSS.bottom = newCenter.bottom; + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, newCenter.height); + s.maxHeight = CSS.height; + hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW + if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic + } + + if (hasRoom) { + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_start", pane); + + $P.css(CSS); // apply the CSS to pane + sizeHandles(pane); // also update resizer length + if (s.noRoom && !s.isClosed && !s.isHidden) + makePaneFit(pane); // will re-open/show auto-closed/hidden pane + if (s.isVisible) { + $.extend(s, elDims($P)); // update pane dimensions + if (state.initialized) sizeContent(pane); // also resize the contents, if exists + } + } + else if (!s.noRoom && s.isVisible) // no room for pane + makePaneFit(pane); // will hide or close pane + + if (!s.isVisible) + return true; // DONE - next pane + + /* + * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes + * Normally these panes have only 'left' & 'right' positions so pane auto-sizes + * ALSO required when pane is an IFRAME because will NOT default to 'full width' + */ + if (pane === "center") { // finished processing midPanes + var b = $.layout.browser; + var fix = b.isIE6 || (b.msie && !$.support.boxModel); + if ($Ps.north && (fix || state.north.tagName=="IFRAME")) + $Ps.north.css("width", cssW($Ps.north, sC.innerWidth)); + if ($Ps.south && (fix || state.south.tagName=="IFRAME")) + $Ps.south.css("width", cssW($Ps.south, sC.innerWidth)); + } + + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_end", pane); + }); + } + + + /** + * @see window.onresize(), callbacks or custom code + */ +, resizeAll = function () { + if (!state.initialized) { + _initLayoutElements(); + return; // no need to resize since we just initialized! + } + var oldW = sC.innerWidth + , oldH = sC.innerHeight + ; + // cannot size layout when 'container' is hidden or collapsed + if (!$N.is(":visible:") ) return; + $.extend( state.container, elDims( $N ) ); // UPDATE container dimensions + if (!sC.outerHeight) return; + + // onresizeall_start will CANCEL resizing if returns false + // state.container has already been set, so user can access this info for calcuations + if (false === _runCallbacks("onresizeall_start")) return false; + + var // see if container is now 'smaller' than before + shrunkH = (sC.innerHeight < oldH) + , shrunkW = (sC.innerWidth < oldW) + , $P, o, s, dir + ; + // NOTE special order for sizing: S-N-E-W + $.each(["south","north","east","west"], function (i, pane) { + if (!$Ps[pane]) return; // no pane - SKIP + s = state[pane]; + o = options[pane]; + dir = _c[pane].dir; + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else { + setSizeLimits(pane); + makePaneFit(pane, false, true, true); // true=skipCallback/forceResize + } + }); + + sizeMidPanes("", true, true); // true=skipCallback, true=forceResize + sizeHandles(); // reposition the toggler elements + + // trigger all individual pane callbacks AFTER layout has finished resizing + o = options; // reuse alias + $.each(_c.allPanes, function (i, pane) { + $P = $Ps[pane]; + if (!$P) return; // SKIP + if (state[pane].isVisible) // undefined for non-existent panes + _runCallbacks("onresize_end", pane); // callback - if exists + }); + + _runCallbacks("onresizeall_end"); + //_triggerLayoutEvent(pane, 'resizeall'); + } + + /** + * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll + * + * @param {string} pane The pane just resized or opened + */ +, resizeChildLayout = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + if (!options[pane].resizeChildLayout) return; + var $P = $Ps[pane] + , $C = $Cs[pane] + , d = "layout" + , P = Instance[pane] + , L = children[pane] + ; + // user may have manually set EITHER instance pointer, so handle that + if (P.child && !L) { + // have to reverse the pointers! + var el = P.child.container; + L = children[pane] = (el ? el.data(d) : 0) || null; // set pointer _directly_ to layout instance + } + + // if a layout-pointer exists, see if child has been destroyed + if (L && L.destroyed) + L = children[pane] = null; // clear child pointers + // no child layout pointer is set - see if there is a child layout NOW + if (!L) L = children[pane] = $P.data(d) || ($C ? $C.data(d) : 0) || null; // set/update child pointers + + // ALWAYS refresh the pane.child alias + P.child = children[pane]; + + if (L) L.resizeAll(); + } + + + /** + * IF pane has a content-div, then resize all elements inside pane to fit pane-height + * + * @param {string=} [panes=""] The pane(s) being resized + * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured? + */ +, sizeContent = function (evt_or_panes, remeasure) { + if (!isInitialized()) return; + + var panes = evtPane.call(this, evt_or_panes); + panes = panes ? panes.split(",") : _c.allPanes; + + $.each(panes, function (idx, pane) { + var + $P = $Ps[pane] + , $C = $Cs[pane] + , o = options[pane] + , s = state[pane] + , m = s.content // m = measurements + ; + if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip + + // if content-element was REMOVED, update OR remove the pointer + if (!$C.length) { + initContent(pane, false); // false = do NOT sizeContent() - already there! + if (!$C) return; // no replacement element found - pointer have been removed + } + + // onsizecontent_start will CANCEL resizing if returns false + if (false === _runCallbacks("onsizecontent_start", pane)) return; + + // skip re-measuring offsets if live-resizing + if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) { + _measure(); + // if any footers are below pane-bottom, they may not measure correctly, + // so allow pane overflow and re-measure + if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") { + $P.css("overflow", "visible"); + _measure(); // remeasure while overflowing + $P.css("overflow", "hidden"); + } + } + // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders + var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom); + + if (!$C.is(":visible") || m.height != newH) { + // size the Content element to fit new pane-size - will autoHide if not enough room + setOuterHeight($C, newH, true); // true=autoHide + m.height = newH; // save new height + }; + + if (state.initialized) + _runCallbacks("onsizecontent_end", pane); + + function _below ($E) { + return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0)); + }; + + function _measure () { + var + ignore = options[pane].contentIgnoreSelector + , $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL + , $Fs_vis = $Fs.filter(':visible') + , $F = $Fs_vis.filter(':last') + ; + m = { + top: $C[0].offsetTop + , height: $C.outerHeight() + , numFooters: $Fs.length + , hiddenFooters: $Fs.length - $Fs_vis.length + , spaceBelow: 0 // correct if no content footer ($E) + } + m.spaceAbove = m.top; // just for state - not used in calc + m.bottom = m.top + m.height; + if ($F.length) + //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom) + m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F); + else // no footer - check marginBottom on Content element itself + m.spaceBelow = _below($C); + }; + }); + } + + + /** + * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary + * + * @see initHandles(), open(), close(), resizeAll() + * @param {string=} [panes=""] The pane(s) being resized + */ +, sizeHandles = function (evt_or_panes) { + var panes = evtPane.call(this, evt_or_panes) + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (i, pane) { + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , $TC + ; + if (!$P || !$R) return; + + var + dir = _c[pane].dir + , _state = (s.isClosed ? "_closed" : "_open") + , spacing = o["spacing"+ _state] + , togAlign = o["togglerAlign"+ _state] + , togLen = o["togglerLength"+ _state] + , paneLen + , left + , offset + , CSS = {} + ; + + if (spacing === 0) { + $R.hide(); + return; + } + else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason + $R.show(); // in case was previously hidden + + // Resizer Bar is ALWAYS same width/height of pane it is attached to + if (dir === "horz") { // north/south + //paneLen = $P.outerWidth(); // s.outerWidth || + paneLen = sC.innerWidth; // handle offscreen-panes + s.resizerLength = paneLen; + left = $.layout.cssNum($P, "left") + $R.css({ + width: cssW($R, paneLen) // account for borders & padding + , height: cssH($R, spacing) // ditto + , left: left > -9999 ? left : sC.insetLeft // handle offscreen-panes + }); + } + else { // east/west + paneLen = $P.outerHeight(); // s.outerHeight || + s.resizerLength = paneLen; + $R.css({ + height: cssH($R, paneLen) // account for borders & padding + , width: cssW($R, spacing) // ditto + , top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane? + //, top: $.layout.cssNum($Ps["center"], "top") + }); + } + + // remove hover classes + removeHover( o, $R ); + + if ($T) { + if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) { + $T.hide(); // always HIDE the toggler when 'sliding' + return; + } + else + $T.show(); // in case was previously hidden + + if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) { + togLen = paneLen; + offset = 0; + } + else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed + if (isStr(togAlign)) { + switch (togAlign) { + case "top": + case "left": offset = 0; + break; + case "bottom": + case "right": offset = paneLen - togLen; + break; + case "middle": + case "center": + default: offset = round((paneLen - togLen) / 2); // 'default' catches typos + } + } + else { // togAlign = number + var x = parseInt(togAlign, 10); // + if (togAlign >= 0) offset = x; + else offset = paneLen - togLen + x; // NOTE: x is negative! + } + } + + if (dir === "horz") { // north/south + var width = cssW($T, togLen); + $T.css({ + width: width // account for borders & padding + , height: cssH($T, spacing) // ditto + , left: offset // TODO: VERIFY that toggler positions correctly for ALL values + , top: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative + }); + } + else { // east/west + var height = cssH($T, togLen); + $T.css({ + height: height // account for borders & padding + , width: cssW($T, spacing) // ditto + , top: offset // POSITION the toggler + , left: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative + }); + } + + // remove ALL hover classes + removeHover( 0, $T ); + } + + // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now + if (!state.initialized && (o.initHidden || s.noRoom)) { + $R.hide(); + if ($T) $T.hide(); + } + }); + } + + + /** + * @param {string} pane + */ +, enableClosable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + , o = options[pane] + ; + if (!$T) return; + o.closable = true; + $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); }) + .css("visibility", "visible") + .css("cursor", "pointer") + .attr("title", state[pane].isClosed ? o.togglerTip_closed : o.togglerTip_open) // may be blank + .show(); + } + /** + * @param {string} pane + * @param {boolean=} [hide=false] + */ +, disableClosable = function (evt_or_pane, hide) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + ; + if (!$T) return; + options[pane].closable = false; + // is closable is disable, then pane MUST be open! + if (state[pane].isClosed) open(pane, false, true); + $T .unbind("."+ sID) + .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues + .css("cursor", "default") + .attr("title", ""); + } + + + /** + * @param {string} pane + */ +, enableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].slidable = true; + if (s.isClosed) + bindStartSlidingEvent(pane, true); + } + /** + * @param {string} pane + */ +, disableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R) return; + options[pane].slidable = false; + if (state[pane].isSliding) + close(pane, false, true); + else { + bindStartSlidingEvent(pane, false); + $R .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + } + + + /** + * @param {string} pane + */ +, enableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + , o = options[pane] + ; + if (!$R || !$R.data('draggable')) return; + o.resizable = true; + $R.draggable("enable"); + if (!state[pane].isClosed) + $R .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + } + /** + * @param {string} pane + */ +, disableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].resizable = false; + $R .draggable("disable") + .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + + + /** + * Move a pane from source-side (eg, west) to target-side (eg, east) + * If pane exists on target-side, move that to source-side, ie, 'swap' the panes + * + * @param {string} pane1 The pane/edge being swapped + * @param {string} pane2 ditto + */ +, swapPanes = function (evt_or_pane1, pane2) { + if (!isInitialized()) return; + var pane1 = evtPane.call(this, evt_or_pane1); + // change state.edge NOW so callbacks can know where pane is headed... + state[pane1].edge = pane2; + state[pane2].edge = pane1; + // run these even if NOT state.initialized + if (false === _runCallbacks("onswap_start", pane1) + || false === _runCallbacks("onswap_start", pane2) + ) { + state[pane1].edge = pane1; // reset + state[pane2].edge = pane2; + return; + } + + var + oPane1 = copy( pane1 ) + , oPane2 = copy( pane2 ) + , sizes = {} + ; + sizes[pane1] = oPane1 ? oPane1.state.size : 0; + sizes[pane2] = oPane2 ? oPane2.state.size : 0; + + // clear pointers & state + $Ps[pane1] = false; + $Ps[pane2] = false; + state[pane1] = {}; + state[pane2] = {}; + + // ALWAYS remove the resizer & toggler elements + if ($Ts[pane1]) $Ts[pane1].remove(); + if ($Ts[pane2]) $Ts[pane2].remove(); + if ($Rs[pane1]) $Rs[pane1].remove(); + if ($Rs[pane2]) $Rs[pane2].remove(); + $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false; + + // transfer element pointers and data to NEW Layout keys + move( oPane1, pane2 ); + move( oPane2, pane1 ); + + // cleanup objects + oPane1 = oPane2 = sizes = null; + + // make panes 'visible' again + if ($Ps[pane1]) $Ps[pane1].css(_c.visible); + if ($Ps[pane2]) $Ps[pane2].css(_c.visible); + + // fix any size discrepancies caused by swap + resizeAll(); + + // run these even if NOT state.initialized + _runCallbacks("onswap_end", pane1); + _runCallbacks("onswap_end", pane2); + + return; + + function copy (n) { // n = pane + var + $P = $Ps[n] + , $C = $Cs[n] + ; + return !$P ? false : { + pane: n + , P: $P ? $P[0] : false + , C: $C ? $C[0] : false + , state: $.extend(true, {}, state[n]) + , options: $.extend(true, {}, options[n]) + } + }; + + function move (oPane, pane) { + if (!oPane) return; + var + P = oPane.P + , C = oPane.C + , oldPane = oPane.pane + , c = _c[pane] + , side = c.side.toLowerCase() + , inset = "inset"+ c.side + // save pane-options that should be retained + , s = $.extend({}, state[pane]) + , o = options[pane] + // RETAIN side-specific FX Settings - more below + , fx = { resizerCursor: o.resizerCursor } + , re, size, pos + ; + $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) { + fx[k +"_open"] = o[k +"_open"]; + fx[k +"_close"] = o[k +"_close"]; + fx[k +"_size"] = o[k +"_size"]; + }); + + // update object pointers and attributes + $Ps[pane] = $(P) + .data({ + layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + }) + .css(_c.hidden) + .css(c.cssReq) + ; + $Cs[pane] = C ? $(C) : false; + + // set options and state + options[pane] = $.extend({}, oPane.options, fx); + state[pane] = $.extend({}, oPane.state); + + // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west + re = new RegExp(o.paneClass +"-"+ oldPane, "g"); + P.className = P.className.replace(re, o.paneClass +"-"+ pane); + + // ALWAYS regenerate the resizer & toggler elements + initHandles(pane); // create the required resizer & toggler + + // if moving to different orientation, then keep 'target' pane size + if (c.dir != _c[oldPane].dir) { + size = sizes[pane] || 0; + setSizeLimits(pane); // update pane-state + size = max(size, state[pane].minSize); + // use manualSizePane to disable autoResize - not useful after panes are swapped + manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation + } + else // move the resizer here + $Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0)); + + + // ADD CLASSNAMES & SLIDE-BINDINGS + if (oPane.state.isVisible && !s.isVisible) + setAsOpen(pane, true); // true = skipCallback + else { + setAsClosed(pane); + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + // DESTROY the object + oPane = null; + }; + } + + + /** + * INTERNAL method to sync pin-buttons when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), setAsOpen(), setAsClosed() + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns = function (pane, doPin) { + if ($.layout.plugins.buttons) + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(Instance, $(selector), pane, doPin); + }); + } + +; // END var DECLARATIONS + + /** + * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed + * + * @see document.keydown() + */ + function keyDown (evt) { + if (!evt) return true; + var code = evt.keyCode; + if (code < 33) return true; // ignore special keys: ENTER, TAB, etc + + var + PANE = { + 38: "north" // Up Cursor - $.ui.keyCode.UP + , 40: "south" // Down Cursor - $.ui.keyCode.DOWN + , 37: "west" // Left Cursor - $.ui.keyCode.LEFT + , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT + } + , ALT = evt.altKey // no worky! + , SHIFT = evt.shiftKey + , CTRL = evt.ctrlKey + , CURSOR = (CTRL && code >= 37 && code <= 40) + , o, k, m, pane + ; + + if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey + pane = PANE[code]; + else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey + $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey + o = options[p]; + k = o.customHotkey; + m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT" + if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches + if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches + pane = p; + return false; // BREAK + } + } + }); + + // validate pane + if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden) + return true; + + toggle(pane); + + evt.stopPropagation(); + evt.returnValue = false; // CANCEL key + return false; + }; + + +/* + * ###################################### + * UTILITY METHODS + * called externally or by initButtons + * ###################################### + */ + + /** + * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work + * + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function allowOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + ; + + // if pane is already raised, then reset it before doing it again! + // this would happen if allowOverflow is attached to BOTH the pane and an element + if (s.cssSaved) + resetOverflow(pane); // reset previous CSS before continuing + + // if pane is raised by sliding or resizing, or its closed, then abort + if (s.isSliding || s.isResizing || s.isClosed) { + s.cssSaved = false; + return; + } + + var + newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) } + , curCSS = {} + , of = $P.css("overflow") + , ofX = $P.css("overflowX") + , ofY = $P.css("overflowY") + ; + // determine which, if any, overflow settings need to be changed + if (of != "visible") { + curCSS.overflow = of; + newCSS.overflow = "visible"; + } + if (ofX && !ofX.match(/visible|auto/)) { + curCSS.overflowX = ofX; + newCSS.overflowX = "visible"; + } + if (ofY && !ofY.match(/visible|auto/)) { + curCSS.overflowY = ofX; + newCSS.overflowY = "visible"; + } + + // save the current overflow settings - even if blank! + s.cssSaved = curCSS; + + // apply new CSS to raise zIndex and, if necessary, make overflow 'visible' + $P.css( newCSS ); + + // make sure the zIndex of all other panes is normal + $.each(_c.allPanes, function(i, p) { + if (p != pane) resetOverflow(p); + }); + + }; + /** + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function resetOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + , CSS = s.cssSaved || {} + ; + // reset the zIndex + if (!s.isSliding && !s.isResizing) + $P.css("zIndex", options.zIndexes.pane_normal); + + // reset Overflow - if necessary + $P.css( CSS ); + + // clear var + s.cssSaved = false; + }; + +/* + * ##################### + * CREATE/RETURN LAYOUT + * ##################### + */ + + // validate that container exists + var $N = $(this).eq(0); // FIRST matching Container element + if (!$N.length) { + if (options.showErrorMessages) + _log( lang.errContainerMissing, true ); + return null; + }; + + // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout") + // return the Instance-pointer if layout has already been initialized + if ($N.data("layoutContainer") && $N.data("layout")) + return $N.data("layout"); // cached pointer + + // init global vars + var + $Ps = {} // Panes x5 - set in initPanes() + , $Cs = {} // Content x5 - set in initPanes() + , $Rs = {} // Resizers x4 - set in initHandles() + , $Ts = {} // Togglers x4 - set in initHandles() + , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV) + // aliases for code brevity + , sC = state.container // alias for easy access to 'container dimensions' + , sID = state.id // alias for unique layout ID/namespace - eg: "layout435" + ; + + // create Instance object to expose data & option Properties, and primary action Methods + var Instance = { + // layout data + options: options // property - options hash + , state: state // property - dimensions hash + // object pointers + , container: $N // property - object pointers for layout container + , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center + , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center + , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north + , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north + // border-pane open/close + , hide: hide // method - ditto + , show: show // method - ditto + , toggle: toggle // method - pass a 'pane' ("north", "west", etc) + , open: open // method - ditto + , close: close // method - ditto + , slideOpen: slideOpen // method - ditto + , slideClose: slideClose // method - ditto + , slideToggle: slideToggle // method - ditto + // pane actions + , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data + , _sizePane: sizePane // method -intended for user by plugins only! + , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto' + , sizeContent: sizeContent // method - pass a 'pane' + , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them + // pane element methods + , initContent: initContent // method - ditto + , addPane: addPane // method - pass a 'pane' + , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem + , createChildLayout: createChildLayout// method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].childOptions + // special pane option setting + , enableClosable: enableClosable // method - pass a 'pane' + , disableClosable: disableClosable // method - ditto + , enableSlidable: enableSlidable // method - ditto + , disableSlidable: disableSlidable // method - ditto + , enableResizable: enableResizable // method - ditto + , disableResizable: disableResizable// method - ditto + // utility methods for panes + , allowOverflow: allowOverflow // utility - pass calling element (this) + , resetOverflow: resetOverflow // utility - ditto + // layout control + , destroy: destroy // method - no parameters + , initPanes: isInitialized // method - no parameters + , resizeAll: resizeAll // method - no parameters + // callback triggering + , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west") + // alias collections of options, state and children - created in addPane and extended elsewhere + , hasParentLayout: false // set by initContainer() + , children: children // pointers to child-layouts, eg: Instance.children["west"] + , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], child: children[pane] } + , south: false // ditto + , west: false // ditto + , east: false // ditto + , center: false // ditto + }; + + // create the border layout NOW + if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation + return null; + else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later + return Instance; // return the Instance object + +} + + + + +/** + * jquery.layout.state 1.0 + * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * @dependancies: $.ui.cookie (above) + * + * @support: http://groups.google.com/group/jquery-ui-layout + */ +/* + * State-management options stored in options.stateManagement, which includes a .cookie hash + * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden + * + * // STATE/COOKIE OPTIONS + * @example $(el).layout({ + stateManagement: { + enabled: true + , stateKeys: "east.size,west.size,east.isClosed,west.isClosed" + , cookie: { name: "appLayout", path: "/" } + } + }) + * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies + * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } }) + * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" }) + * + * // STATE/COOKIE METHODS + * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} ); + * @example myLayout.loadCookie(); + * @example myLayout.deleteCookie(); + * @example var JSON = myLayout.readState(); // CURRENT Layout State + * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie) + * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash) + * + * CUSTOM STATE-MANAGEMENT (eg, saved in a database) + * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" ); + * @example myLayout.loadState( JSON ); + */ + +/** + * UI COOKIE UTILITY + * + * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then... + * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin + * NOTE: This utility is REQUIRED by the layout.state plugin + * + * Cookie methods in Layout are created as part of State Management + */ +if (!$.ui) $.ui = {}; +$.ui.cookie = { + + // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6 + acceptsCookies: !!navigator.cookieEnabled + +, read: function (name) { + var + c = document.cookie + , cs = c ? c.split(';') : [] + , pair // loop var + ; + for (var i=0, n=cs.length; i < n; i++) { + pair = $.trim(cs[i]).split('='); // name=value pair + if (pair[0] == name) // found the layout cookie + return decodeURIComponent(pair[1]); + + } + return null; + } + +, write: function (name, val, cookieOpts) { + var + params = '' + , date = '' + , clear = false + , o = cookieOpts || {} + , x = o.expires + ; + if (x && x.toUTCString) + date = x; + else if (x === null || typeof x === 'number') { + date = new Date(); + if (x > 0) + date.setDate(date.getDate() + x); + else { + date.setFullYear(1970); + clear = true; + } + } + if (date) params += ';expires='+ date.toUTCString(); + if (o.path) params += ';path='+ o.path; + if (o.domain) params += ';domain='+ o.domain; + if (o.secure) params += ';secure'; + document.cookie = name +'='+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie + } + +, clear: function (name) { + $.ui.cookie.write(name, '', {expires: -1}); + } + +}; +// if cookie.jquery.js is not loaded, create an alias to replicate it +// this may be useful to other plugins or code dependent on that plugin +if (!$.cookie) $.cookie = function (k, v, o) { + var C = $.ui.cookie; + if (v === null) + C.clear(k); + else if (v === undefined) + return C.read(k); + else + C.write(k, v, o); +}; + + +// tell Layout that the state plugin is available +$.layout.plugins.stateManagement = true; + +// Add State-Management options to layout.defaults +$.layout.config.optionRootKeys.push("stateManagement"); +$.layout.defaults.stateManagement = { + enabled: false // true = enable state-management, even if not using cookies +, autoSave: true // Save a state-cookie when page exits? +, autoLoad: true // Load the state-cookie when Layout inits? + // List state-data to save - must be pane-specific +, stateKeys: "north.size,south.size,east.size,west.size,"+ + "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+ + "north.isHidden,south.isHidden,east.isHidden,west.isHidden" +, cookie: { + name: "" // If not specified, will use Layout.name, else just "Layout" + , domain: "" // blank = current domain + , path: "" // blank = current page, '/' = entire website + , expires: "" // 'days' to keep cookie - leave blank for 'session cookie' + , secure: false + } +}; +// Set stateManagement as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("stateManagement"); + +/* + * State Management methods + */ +$.layout.state = { + + /** + * Get the current layout state and save it to a cookie + * + * myLayout.saveCookie( keys, cookieOpts ) + * + * @param {Object} inst + * @param {(string|Array)=} keys + * @param {Object=} opts + */ + saveCookie: function (inst, keys, cookieOpts) { + var o = inst.options + , oS = o.stateManagement + , oC = $.extend(true, {}, oS.cookie, cookieOpts || null) + , data = inst.state.stateData = inst.readState( keys || oS.stateKeys ) // read current panes-state + ; + $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC ); + return $.extend(true, {}, data); // return COPY of state.stateData data + } + + /** + * Remove the state cookie + * + * @param {Object} inst + */ +, deleteCookie: function (inst) { + var o = inst.options; + $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" ); + } + + /** + * Read & return data from the cookie - as JSON + * + * @param {Object} inst + */ +, readCookie: function (inst) { + var o = inst.options; + var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" ); + // convert cookie string back to a hash and return it + return c ? $.layout.state.decodeJSON(c) : {}; + } + + /** + * Get data from the cookie and USE IT to loadState + * + * @param {Object} inst + */ +, loadCookie: function (inst) { + var c = $.layout.state.readCookie(inst); // READ the cookie + if (c) { + inst.state.stateData = $.extend(true, {}, c); // SET state.stateData + inst.loadState(c); // LOAD the retrieved state + } + return c; + } + + /** + * Update layout options from the cookie, if one exists + * + * @param {Object} inst + * @param {Object=} stateData + * @param {boolean=} animate + */ +, loadState: function (inst, stateData, animate) { + stateData = $.layout.transformData( stateData ); // panes = default subkey + if ($.isEmptyObject( stateData )) return; + $.extend(true, inst.options, stateData); // update layout options + // if layout has already been initialized, then UPDATE layout state + if (inst.state.initialized) { + var pane, vis, o, s, h, c + , noAnimate = (animate===false) + ; + $.each($.layout.config.borderPanes, function (idx, pane) { + state = inst.state[pane]; + o = stateData[ pane ]; + if (typeof o != 'object') return; // no key, continue + s = o.size; + c = o.initClosed; + h = o.initHidden; + vis = state.isVisible; + // resize BEFORE opening + if (!vis) + inst.sizePane(pane, s, false, false); + if (h === true) inst.hide(pane, noAnimate); + else if (c === false) inst.open (pane, false, noAnimate); + else if (c === true) inst.close(pane, false, noAnimate); + else if (h === false) inst.show (pane, false, noAnimate); + // resize AFTER any other actions + if (vis) + inst.sizePane(pane, s, false, noAnimate); // animate resize if option passed + }); + }; + } + + /** + * Get the *current layout state* and return it as a hash + * + * @param {Object=} inst + * @param {(string|Array)=} keys + */ +, readState: function (inst, keys) { + var + data = {} + , alt = { isClosed: 'initClosed', isHidden: 'initHidden' } + , state = inst.state + , panes = $.layout.config.allPanes + , pair, pane, key, val + ; + if (!keys) keys = inst.options.stateManagement.stateKeys; // if called by user + if ($.isArray(keys)) keys = keys.join(","); + // convert keys to an array and change delimiters from '__' to '.' + keys = keys.replace(/__/g, ".").split(','); + // loop keys and create a data hash + for (var i=0, n=keys.length; i < n; i++) { + pair = keys[i].split("."); + pane = pair[0]; + key = pair[1]; + if ($.inArray(pane, panes) < 0) continue; // bad pane! + val = state[ pane ][ key ]; + if (val == undefined) continue; + if (key=="isClosed" && state[pane]["isSliding"]) + val = true; // if sliding, then *really* isClosed + ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val; + } + return data; + } + + /** + * Stringify a JSON hash so can save in a cookie or db-field + */ +, encodeJSON: function (JSON) { + return parse(JSON); + function parse (h) { + var D=[], i=0, k, v, t; // k = key, v = value + for (k in h) { + v = h[k]; + t = typeof v; + if (t == 'string') // STRING - add quotes + v = '"'+ v +'"'; + else if (t == 'object') // SUB-KEY - recurse into it + v = parse(v); + D[i++] = '"'+ k +'":'+ v; + } + return '{'+ D.join(',') +'}'; + }; + } + + /** + * Convert stringified JSON back to a hash object + * @see $.parseJSON(), adding in jQuery 1.4.1 + */ +, decodeJSON: function (str) { + try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; } + catch (e) { return {}; } + } + + +, _create: function (inst) { + var _ = $.layout.state; + // ADD State-Management plugin methods to inst + $.extend( inst, { + // readCookie - update options from cookie - returns hash of cookie data + readCookie: function () { return _.readCookie(inst); } + // deleteCookie + , deleteCookie: function () { _.deleteCookie(inst); } + // saveCookie - optionally pass keys-list and cookie-options (hash) + , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); } + // loadCookie - readCookie and use to loadState() - returns hash of cookie data + , loadCookie: function () { return _.loadCookie(inst); } + // loadState - pass a hash of state to use to update options + , loadState: function (stateData, animate) { _.loadState(inst, stateData, animate); } + // readState - returns hash of current layout-state + , readState: function (keys) { return _.readState(inst, keys); } + // add JSON utility methods too... + , encodeJSON: _.encodeJSON + , decodeJSON: _.decodeJSON + }); + + // init state.stateData key, even if plugin is initially disabled + inst.state.stateData = {}; + + // read and load cookie-data per options + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoLoad) // update the options from the cookie + inst.loadCookie(); + else // don't modify options - just store cookie data in state.stateData + inst.state.stateData = inst.readCookie(); + } + } + +, _unload: function (inst) { + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoSave) // save a state-cookie automatically + inst.saveCookie(); + else // don't save a cookie, but do store state-data in state.stateData key + inst.state.stateData = inst.readState(); + } + } + +}; + +// add state initialization method to Layout's onCreate array of functions +$.layout.onCreate.push( $.layout.state._create ); +$.layout.onUnload.push( $.layout.state._unload ); + + + + +/** + * jquery.layout.buttons 1.0 + * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * Docs: [ to come ] + * Tips: [ to come ] + */ + +// tell Layout that the state plugin is available +$.layout.plugins.buttons = true; + +// Add buttons options to layout.defaults +$.layout.defaults.autoBindCustomButtons = false; +// Specify autoBindCustomButtons as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("autoBindCustomButtons"); + +var lang = $.layout.language; + +/* + * Button methods + */ +$.layout.buttons = { + + /** + * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons + * + * @see _create() + * + * @param {Object} inst Layout Instance object + */ + init: function (inst) { + var pre = "ui-layout-button-" + , layout = inst.options.name || "" + , name; + $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) { + $.each($.layout.config.borderPanes, function (ii, pane) { + $("."+pre+action+"-"+pane).each(function(){ + // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name' + name = $(this).data("layoutName") || $(this).attr("layoutName"); + if (name == undefined || name === layout) + inst.bindButton(this, action, pane); + }); + }); + }); + } + + /** + * Helper function to validate params received by addButton utilities + * + * Two classes are added to the element, based on the buttonClass... + * The type of button is appended to create the 2nd className: + * - ui-layout-button-pin // action btnClass + * - ui-layout-button-pin-west // action btnClass + pane + * - ui-layout-button-toggle + * - ui-layout-button-open + * - ui-layout-button-close + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * + * @return {Array.} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null + */ +, get: function (inst, selector, pane, action) { + var $E = $(selector) + , o = inst.options + , err = o.showErrorMessages + ; + if (!$E.length) { // element not found + if (err) $.layout.msg(lang.errButton + lang.selector +": "+ selector, true); + } + else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified + if (err) $.layout.msg(lang.errButton + lang.pane +": "+ pane, true); + $E = $(""); // NO BUTTON + } + else { // VALID + var btn = o[pane].buttonClass +"-"+ action; + $E .addClass( btn +" "+ btn +"-"+ pane ) + .data("layoutName", o.name); // add layout identifier - even if blank! + } + return $E; + } + + + /** + * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc. + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} action + * @param {string} pane + */ +, bind: function (inst, selector, action, pane) { + var _ = $.layout.buttons; + switch (action.toLowerCase()) { + case "toggle": _.addToggle (inst, selector, pane); break; + case "open": _.addOpen (inst, selector, pane); break; + case "close": _.addClose (inst, selector, pane); break; + case "pin": _.addPin (inst, selector, pane); break; + case "toggle-slide": _.addToggle (inst, selector, pane, true); break; + case "open-slide": _.addOpen (inst, selector, pane, true); break; + } + return inst; + } + + /** + * Add a custom Toggler button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addToggle: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "toggle") + .click(function(evt){ + inst.toggle(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Open button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addOpen: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "open") + .attr("title", lang.Open) + .click(function (evt) { + inst.open(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Close button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + */ +, addClose: function (inst, selector, pane) { + $.layout.buttons.get(inst, selector, pane, "close") + .attr("title", lang.Close) + .click(function (evt) { + inst.close(pane); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Pin button for a pane + * + * Four classes are added to the element, based on the paneClass for the associated pane... + * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin: + * - ui-layout-pane-pin + * - ui-layout-pane-west-pin + * - ui-layout-pane-pin-up + * - ui-layout-pane-west-pin-up + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc. + */ +, addPin: function (inst, selector, pane) { + var _ = $.layout.buttons + , $E = _.get(inst, selector, pane, "pin"); + if ($E.length) { + var s = inst.state[pane]; + $E.click(function (evt) { + _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed)); + if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open + else inst.close( pane ); // slide-closed + evt.stopPropagation(); + }); + // add up/down pin attributes and classes + _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding)); + // add this pin to the pane data so we can 'sync it' automatically + // PANE.pins key is an array so we can store multiple pins for each pane + s.pins.push( selector ); // just save the selector string + } + return inst; + } + + /** + * Change the class of the pin button to make it look 'up' or 'down' + * + * @see addPin(), syncPins() + * + * @param {Object} inst Layout Instance object + * @param {Array.} $Pin The pin-span element in a jQuery wrapper + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin true = set the pin 'down', false = set it 'up' + */ +, setPinState: function (inst, $Pin, pane, doPin) { + var updown = $Pin.attr("pin"); + if (updown && doPin === (updown=="down")) return; // already in correct state + var + pin = inst.options[pane].buttonClass +"-pin" + , side = pin +"-"+ pane + , UP = pin +"-up "+ side +"-up" + , DN = pin +"-down "+side +"-down" + ; + $Pin + .attr("pin", doPin ? "down" : "up") // logic + .attr("title", doPin ? lang.Unpin : lang.Pin) + .removeClass( doPin ? UP : DN ) + .addClass( doPin ? DN : UP ) + ; + } + + /** + * INTERNAL function to sync 'pin buttons' when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), close() + * + * @param {Object} inst Layout Instance object + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns: function (inst, pane, doPin) { + // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(inst, $(selector), pane, doPin); + }); + } + + +, _load: function (inst) { + var _ = $.layout.buttons; + // ADD Button methods to Layout Instance + // Note: sel = jQuery Selector string + $.extend( inst, { + bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); } + // DEPRECATED METHODS + , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); } + , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); } + , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); } + , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); } + }); + + // init state array to hold pin-buttons + for (var i=0; i<4; i++) { + var pane = $.layout.config.borderPanes[i]; + inst.state[pane].pins = []; + } + + // auto-init buttons onLoad if option is enabled + if ( inst.options.autoBindCustomButtons ) + _.init(inst); + } + +, _unload: function (inst) { + // TODO: unbind all buttons??? + } + +}; + +// add initialization method to Layout's onLoad array of functions +$.layout.onLoad.push( $.layout.buttons._load ); +//$.layout.onUnload.push( $.layout.buttons._unload ); + + + +/** + * jquery.layout.browserZoom 1.0 + * $Date: 2011-12-29 08:00:00 (Thu, 29 Dec 2011) $ + * + * Copyright (c) 2012 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * @todo: Extend logic to handle other problematic zooming in browsers + * @todo: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event + */ + +// tell Layout that the plugin is available +$.layout.plugins.browserZoom = true; + +$.layout.defaults.browserZoomCheckInterval = 1000; +$.layout.optionsMap.layout.push("browserZoomCheckInterval"); + +/* + * browserZoom methods + */ +$.layout.browserZoom = { + + _init: function (inst) { + // abort if browser does not need this check + if ($.layout.browserZoom.ratio() !== false) + $.layout.browserZoom._setTimer(inst); + } + +, _setTimer: function (inst) { + // abort if layout destroyed or browser does not need this check + if (inst.destroyed) return; + var o = inst.options + , s = inst.state + // don't need check if inst has parentLayout, but check occassionally in case parent destroyed! + // MINIMUM 100ms interval, for performance + , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 ) + ; + // set the timer + setTimeout(function(){ + if (inst.destroyed || !o.resizeWithWindow) return; + var d = $.layout.browserZoom.ratio(); + if (d !== s.browserZoom) { + s.browserZoom = d; + inst.resizeAll(); + } + // set a NEW timeout + $.layout.browserZoom._setTimer(inst); + } + , ms ); + } + +, ratio: function () { + var w = window + , s = screen + , d = document + , dE = d.documentElement || d.body + , b = $.layout.browser + , v = b.version + , r, sW, cW + ; + // we can ignore all browsers that fire window.resize event onZoom + if ((b.msie && v > 8) + || !b.msie + ) return false; // don't need to track zoom + + if (s.deviceXDPI) + return calc(s.deviceXDPI, s.systemXDPI); + // everything below is just for future reference! + if (b.webkit && (r = d.body.getBoundingClientRect)) + return calc((r.left - r.right), d.body.offsetWidth); + if (b.webkit && (sW = w.outerWidth)) + return calc(sW, w.innerWidth); + if ((sW = s.width) && (cW = dE.clientWidth)) + return calc(sW, cW); + return false; // no match, so cannot - or don't need to - track zoom + + function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); } + } + +}; +// add initialization method to Layout's onLoad array of functions +$.layout.onReady.push( $.layout.browserZoom._init ); + + + +})( jQuery ); \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif new file mode 100644 index 0000000000000000000000000000000000000000..085ccaecaf5fa5c34bc14cd2c2ed5cbbd8e25dcb GIT binary patch literal 1553 zcma)+TTl~c6vwlh>nb99Af5rT)t{mCEg5urg=A(g z{C|6SPb~9Xage|wB`SrZk2FOMYM!buln2sX?5Y+T78iB(Zu9cS7|LZyZ++}u$^oi1 z_j@S}bW9OzU2R+RMy&~OT>X-oZ98$jq#ogNfJ!BM-42wHGZk*6s2KD}U*IA%epmxb zm}|6BK9YoIF;*xSL!+z@<64lB7->LTW2Vi4ostCA(z&2XniwNIv}fFo-`MbG;)u4G z^p@F!)|9HhZprHd_vXjDoxs6WkK-6P0@lfxnGT>*p(QHoUV=u1FAqb@b%*W=a3{`LsH5k^AvQNL>6fPpy#oU(&MuH(*aEX4b35*} zn4n7)`I2U%=+Z=?BVZQ?vjQFW4gD@~XSOO6b{qu81`4&LFuU2(ilxW+1|ZkNMnWe79C$gs zWT?Ele|HR{JGPe)5BTW>0Ey?-Ls6S#GoV0tbt6ku7B&*0 z;i9QM$W1Rj*rRIdceL)rAOSl+sDe3LkB87<%){;ZdHp6|SNlopDXRx< zxBDF9-lTo&v`8$humFygUij@qgT=Qzhj8{ym2-{Xciwqq_Xwk%=O3B-MNAL_6e`3U zyxwmXex4`g0^1RYw~Dth3av3Dl^AAlpO3mG!nLr#&ZZ7c_wUboI+deC+&%TFjK2Lm z!Y&f1h|T_On%RCV&=4bx`!>(YezqGVhl&QpED?N6GV)HmzJ9&rh$x*i?*@o9#6QI< z5ZI_MRX;0+pY8$`j)eF#TlUyG(eE%E7S!rj;mj^M5vhUicPm zVWQ2z+imFyg}SRABmOBY_@osR!>7Ov!ioK`NB6_Rv}7Ud?35ed5Sb@?yND?kv~RCa wqs^a3Sh>&&L4)!LKI?D2&k@))k(LESaga|C278ChSzn3NWVkcuNoY&{0f?~U_5c6? literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100644 index 0000000000000000000000000000000000000000..5b5dab2ab7b1c50dea9cfe73dc5a269a92d2d4b4 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F!3HG1q!d*FscKIb$B>N1x91EQ4=4yQ7#`R^ z$vje}bP0l+XkK DSH>_4 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png new file mode 100644 index 0000000000000000000000000000000000000000..47acaadd737478ddb090f47f618810712163317b GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F!3HG1q!d*Fsaj7L$B>N1x91EQ8x$BA993)+ za~~)OO5|O5sDCi_{N8&XlRv*c;OQ6|AR59NN?mFzWBXJVGojypu|S6~c)I$ztaD0e F0syyrGF|`x literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..9d149b1c61fdee2de5cb342741c243abb9058bb3 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAGVZ#9R3S1u{Kd978O6pI&z4VlotPxp?2+ z_9ElQf7546?+BK3Q+%u|q&R!~TD`8c>Nm?7lq=+T^Fw3At=o;a{QQ?&v0rW43t78u zKLhT~Z`;~2oo9{ezlW>%eD?g@v!}03FhOcY)5-`I-U~CHGCzC3{y9?4*Y0Z~JJ3=F MPgg&ebxsLQ09`{nxc~qF literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..014951529c315d6042e72febc310a4d2db5b4a82 GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAK^akKnouq?|lm978O6-<~(*YA_IRxoBVf zfAX@vsV!R#l$@#*eLnw)_Sv|_?i7P!ORnX)SxaXh+BPpZ!Fw~yjr&#G|Jw^YMHDhV X&EsZx`7bsSXc~j3tDnm{r-UW|&(SK+ literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 0000000000000000000000000000000000000000..4443fdc1a156babad4336f004eaf5ca5dfa0f9ab GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^j6gJjgAK^akKnour0hIh978O6-<~(*YA|4MzBvER z|7}eQtdCVXoUc2b{PaWeaIKu7gJx>{vDV26o)#~38k_!`W=^oo1w6ixmPC4R1b Tyd6G3lNdZ*{an^LB{Ts5`idse literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png new file mode 100644 index 0000000000000000000000000000000000000000..81ecc362d50ef5abbc0420aacd5345822f1f6098 GIT binary patch literal 3457 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..6f4bd87c041453ef037c4a9a1a698f0105d02eba GIT binary patch literal 4369 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..09d1cdc856c292c4ab6dd818c7543ac0828bd616 GIT binary patch literal 4369 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..bd2cf079add1ca236adeb509698adabbffb08acb GIT binary patch literal 4369 zcmd^?`8O2)_s3^p#%>tc^56h z`;7ykFJNMJN#e#ybz9|Ft@x`UI}T5QRij?pZ}6v#Srs793k0w~#4dRsO_y8vaKB*UbCk3l9Lh&v zS5!q|FV83GvJ|wlWy2IQI27&mA~vn>kbZHR1lRB?uEUiLWJ2Rgpr(9;PtX|H61Y%8 z>>Yvu=(<$fHnjpCX`E;Qw8u0=3KGsNhap}(`ul7lx-)UB6U7Rt{a^<^*Xbmf7)2^xf*8T2&U<6)1vO~m1F!2^L zin5`}H)*h3_*XzG*7fMOwuHkuK2hW)$!EE#jpyRaiy2tEzf~(B-PTBkPS$@K|y8w%~JYu8>vRGGA=Z$>guC|z6 zYkPw1&xf?FV0;xWt*`eV2oI-ePL2>on#}}WB8O9XBtD6GWYHw9TuY06(#pZ&TR3xK zNc7;n$4wnDC1?2MVtE1Zp2zT~^LboWF^niS1c$xMo}Gq?!`2q?IncFGB{AFxiTH7M zW6Wg6!H-Orl|zm+8G{^~&Fg2IE-7Q;uqGzAXEz)n_H1kYekmQLMJ)H_N1Ou8dug}I zg*SK#Fw;Fagf;H2=cerAvd2^*^YFJ_1850U&t}@Ts z-Ut9ox+Q;6E(XDZh@X=Gp(SPg)l4tQCH^(ZRf@E#KwlZPL;7ULUU0tSrvtn6Xt=Bl zG)w2|kn&t0Rld8d(t&f+-Jt5c7!Jl(SI2y<(E*K?=rQ%uV%4h0>FKm&7~0UnkICBc z3tgbbnW=GN@m656hHUzj6+go+`f^?6f@&?MiRslUz(!JYo`t%GZBP|O5#B?8Q!s!E z9^Ae>??aVeK~d<8G-`&+;~iK=r$D=se~1hP`y1FFARfPyp)iel=Nft8 znC=6UJHKKc>@v6^BHUgm$;1MCFRkRU9c7-T4r93DR+husFU7$gur@@f0$OZ1L9tGX zFTXe+OLbvyc&y1PF}4L`4x@XUJmE|_sn56h!ty42=@$~}wrWyVWoN^*yMa(A8bATs zAQRl8t3PnEeTy?M>ryqZSZwydvk3EmU|_Uk0Qsgqf@$HLqZ+||@PwmP+C~J3t-;t^A+ZQlqV5wK z%GQPfh`B@R4>AFJqdaImV^e(7#NPh2=V`CA9k=gtO&aqe{dJo=cvqPvaG92p)a~Xp z00|*>BOjuss)}zZTg6iEpZ?)}$XnxQ1Qg_)cP)Z6UQ6-ntKI-zNkl5kLs$#d)vS?t#w z!8oVgTG*33YBWB19B(GJxaF`p4zLTN+P(%31kt_<`l{r>rZ!6_mdb zQ2G)orW{~?O-?TSj+obv!+*!zpy&O)wRPJ8Pk81{)Oy2}-GFV2upGunf@d9Zj*xDj z7qF*O&^J3$XB&xT{P@0?J=lOEoWxAgO<1qa2@7S(ulwn5`u0ZIhxiRM`xz@Lwi5}} zFmUKSu+FHdbWSZRbH=Njjqlg3bI?_^<)xC@N6|xn{jq-rBH;45p?jA-NO#)90~=We z`1WnuC0t?^F?mXMxB<>OFqVHH<;)^|gPGvusmW>aZ#v=NEbmy8<+L~aEq zb?!#AginWl{)d^|4v}nB`B(4jVKZ7Iy1CIhSv^hQOhf!s#z}J5u3$Wazo9+lhXzoV zU?V3N$vi_HH+tN(o4dYLvo%axH{x=B;;WvxFYfHT^zTRZS-)ilGp4vP-#pjR+3 z0%AL(^7El8`jyby7DPOXkyc9c@x89GcL(I`x;OT9C2(7J_wbGq>f4s{1-f8d15uu8 z8f6E6ysykf?j%`qVZfG_d47Alp4Qq)&Ed7VJi!ZzB~Xpz+p&9z!3a}h*ZhBHMI8ME z`sT7cRIrw++gd-2I&ZoXq5sH{RaSX(4>Xgl28_+db^7dda<7Wp{^21-MnKeV;U}j1 zJlbMKy?iK~xdXZZeWGbO-RdG-&TvR$TLq8$SdU1N2V4uxE|G#`^e#F>j_3sou4UZn z{C$_N4Ze9WA?dkJU0fKh9qCKOiFvSv``rOim|N#5oQb^^FtmwEeS9tP@DabN`@-&g zimf*(7!$`vRmhu|WqK+rjfNHtN5|W0pW_z?HkS*h88fw>@(*n6h;?a81CT{n{I7>- zw)`=8;Bv=1(tJ@D7qPxosVY+7!w>N=h7e~49~ZKrd98AX6llP7)?3wvc|(^&|FRC# zm9&_;h5z)KIJl{%c3uuW{QBtIlSS~S52Hh?4HeeoZjq-G;6Cq;^mUA?2&V}!)H5jT zKrwiWx-cfD+5-NhGnt}u5wMMwtfXC-yRp|6MTzZFAQItktp4`(v7X4^_2{~i;(sv8 zGkpL3!V-Ai-ycXut#0|8oe4TJ7QUV~Do&p{zVG3v90J>;eENX2w? z$`}Ppr0ft|Zp)w~g{!onDe?@5CcjhC($cq8IM%2O?{Sub8>170^%I69aO+A8&Z&BD zgG+l-HBZPNSO59Ce~-or33^w(Q*U1mHc-Y7c>~Y9et7S1V$SEVbmSSq9Wv|A@EF?V zoP27TfvhVv%A0&@V8B4UGLGc+dc9a4FJBD)l_bZ##HH_vnc z5uC}#FmQiORque`?w?#K6-*)a9uAKX-OqHY?AUdoQYTafr%B>#SB>Q67K{M@<(#;PhLl`o?5`vwPv z;YkLv3FfS>7&%-e=_!*VvjMU8a!T+$b_h1o9(Qs@^ircOb^M0YY-y!n>Di)^q4Cgj z5IOL{sLD(nyg859i=2xJ;iPM|R!#N0a|vH zI}K@UZv9M*&=i}!VrxAmUNEWCy|T3%5~+mC9{NYcI*9J?VqXjh+Egl5Pm-Gb*!~SO zzW+D8H$3YhoTXOmc=gtYw!k@=oeiMmKJaz8r)%e;z1ORe$@QRI4oCa8Imz(dcoLo8 z^y{}ols#&09(EWKFND_xL z&4gxpi)Mk9t&j{}^_frnHu6jB_}_d{Fugq2t)_RvnL%6WY5;D&m?%xbpLEisZuPhT|(X^A|G5mlj0d)w-`54(J%ZTcX zn6>%!`8%F-ofn_`-MQ~q_jO(x>T8mdvXBA*0P-hVYQ_Kn!9N5X5QF|voqnkIKk>&< z7oqN1{p0`7a<`$p{u$Q~FxEE#Fi}Ym5*v2Lz7gd@_`uy9SZJ_NP6Y-PE$w?&eB#E! z@luJ=-OmTd`eoGEI$FYO8p~6wK7AFqDdxeGLV)RIPTBA3JeP|!l)NG{-Q6d(ZU6vU z`zLD3h~UCMwq(w@CThr_wpC?b>2)6KQ{XOZqC`#TV3HLH{4Jz8;eG{~<#7&z^Fpk7* zQg4k?n)GcUkD-v&_l+N*LmX{U+`_Ijr%kp9GT$4q!IhlwPUmIZ##tU}y2|M-tDBF{ z?(!=qt%pDjKrY6FbI70LBRgdlR5yNF0LB$t)>@6@wq&n+^=jO(?7{JMy6R(98#*2u zGm(7dhEX1h$(cz;r$Xr8<#ZH-B*s`OZ}!DW-eI$YrcFV8^J{cu9jUXNs_6J;uIaYp z+xJ`kH-W0Q(h5|r(!%ZSQY0T1CI^>?>SmZt=_%5ud)Ukw3qOdwxx}h=GMo$`rAxa5 z5n;T7oei=VlU!q)on~=+Q=zx320a>uiKZ>YbYPj)iIfKb%gA;i<`v#Gi%(K`6NIC= z+M)@C`P6{x^FT;8wcXUj>nBWjtRCf4F?$vYy$)|zu6e%dNah!uvHWYK{+9-?lcvo7 zlRgoN{~EP2D<3a;Z#DSTjppxv#L^*Uen~7pxK&$;fkiD4Lcn^?n(+F%H0x0uVly{j8_GF!7 z2T{^v)JMZ;JI|HnV2&Aj5}iDnz6mNq+3vIiiK<|wfDBiA0|J?@&j%Qn^VCZ5AVbe4 z^$Z6L`Khw*RJfPn z?^O6`8*O#=sf>4D4VTkI^)^A387UDbChOS8u>5`ZuwCFySA*==e&`ujmrX4m*^Gt^ zVflUM_*Y_Rakd!qmG45ZvfVBE1>bruP4nT({QOOaAng0A zUGq-m_0_hmEsb9ySSkm{soffYYmIG@7uPt`8z(&#+jbwJN99YM1W|=I^jtk>eq?Nj5;gGSn4ljc4PNnD`A|W@yob4WP zpqrIC4r7^?VUbtzR4|g(SldP}VU?NTo>AcUDggh`^7V z0Muht8w}9C>u<7?U_$}GcadFOnHh99cb3!E9w5z8Ed)eIU0kmXevFrqH%o#S1K+p* zx$PS7q0i#mu?T$+KHvW^8;pcV5Xl64_nKFCU1Lu9$?OU0LgKMx^ z*AU59^l;pwO$A7!(8hCwb~4Rz9yzc8o%rSJ>zgl^8TyMlGX2)hgsQ~g2xw%kxk)!&U6uOGJ6rzmLzENsEeD%bKHn^b*3Gv@ z)A!<6{2*LrvnKEYi~w=X`bl^(tfBZnxcGl^4Mk(?$>|&)<-y(SC%*CWt(U7S(_goc zb)=sU23AC6h`rr-L)lG;jScn(C=zIa8o3%1!72L(d^Y0{nYC2TpgRM|5u3oTRr^KF z5zxrJM$)+skxJOqEsB*2?7LMGRGr+PK5a=jsR@=!T|fxwvsh;+5t5y_S-Jq?maZWy zj|Z#fXn#h8Sv@=3O9}KSnE)@T6&D<7PZhIVPaKw+*w}?ab-}`c8m-qf0qw&&A?`6$ zr?e5z*XLdQ+;}#zl0OxcABrdT7l%RVn0%Frcavu2R9#B)MRWU1yRzpy!WNaw>%5;E z>&HctlyB8%u*R{0vL=d+NLV0y3??a^C~(ndfEbl6nh0x#$SwAT0_t;^`Qz8aYb&Op(nT|Ar5rEEDFbU9R%i%C z-!+KulwwQP(x9m>uw#YPl7nUwqH|8J`V8vy-8$+!x)DC1j+fvA7P3B+8Qefjtdrqr z+~m)gtx444SZYmBa3{hGw-8NPZKb)+O{{;*H4njbVjXS$qZ^Z_3%8s8T1b-)JM`U@ zQOq1(YK9^A&c8Rr@4(PzwL1;w_Fbu?8kX3qXF@}!{F%o~Qe{x`@amM4+%vO8PZ ztvZ~K+*-+9^0ruez5$#^|1K-Ol_@Kim64>ZY0;5-et?A3?^EAZu!Ue~pOuF*!;#|7 z`tza;_3twWM2T3qb#Y* zl!2*O)Sh0^y|)_AY(YYtJ~E&MVjZp+?0PIW{fXrrN9Z%{8|Mm2{;WGUzUY_fJG!{V zfH#F$BESeT;$ipxqbcY}czkysZvn0;m3KvA{1ET0iphDwxxRF0A6#vN`m^NR@WAX2 zpZc( zPk~>((LWxxV3pxm*_TIgT>eC~-p^G{C8?v?-zAXFuI*11FDXzQCHv8hq&f^Tn0nWl zbajk3fH__lg8L;Tzz64!p-B=x+-nB7^>DZ;qV-!*f6?Kc!?npiyWW@$ z0h&zOZK(@&Ot2p*y;3nr-ong$|KQeP<%=bLiN(l}N`mwHM)}Hl1%Hl@?oWafi#fMTi-&-B*2F461zYL2LPA(o?5JKglLWP(}Oa2vkG6%xHIB+nn zLNMdNzuE3z%3istR#2kwu`Zy_Bvxqk=D#7OcSJ_GH5%#^CcY+t2W)hg2D?4)ktv~y z1j54I=X?waQZW2WUJK{@S)U9RO(n4H;c50HR|dD#u|J%{}>rlcb`!GfRwHQTweec4`Ah4 z7zj(IBqfgNzGjNLCe@%3PYVN6X^gI;Qc}`c!v1tczj3m9AZ$}1pwLF+fLh0hAMbeA zrz|m|c~i2rmoR3^if4D++B3z=3DC1QU|ljPKul6w7T~R?0U3eV&l;zm>O|=2O92bi z%LV`+sy=@2XYB>(jYHAfMJ8s8eh#Z6W|p86%7TAUrctc6%_s?~J!L?zJ%}Y?ExtS4 z5>KRG{QQ$TeopXD_TSl9pcm}`DAvqY&^^EO2L{@@yP6v$nn?rL&Ml1%lWu)RptTzq@%^wx+e@+#v(tOM1qXAc zBVA87Pbv54K0BcSE~l`dRl`e~_?VCZ^Huucn2&(2-d^=qFvf4bv9v1WNxNXPag-TA zB2u0308tTnNvEj4xf9hW<2rqxL@;bySmQvX1^$QI0ny6A9C$NfUe&ab)Vkex;Q=ah z!m(xop>!<0{%&Ub`4U3)d61up+p$E=6dmln*=IGA}lKKD@G>u~sr=E)?f zo6n?*2QT3laPuV?I1W4`Ja`pyc7OT8}9@pOoxcud?Y@5{7;QvEWAARfJjoJnJDZi`}v*6q4b(=q( ziYc~W52*Uj%)b5hN+qdx*`D=Fwt1)brQKN^yU2_zdBcn2%w^`Yv5ed z6pL<8xd^fb{Fyf^s|s$@R9+8!By&JN+s&x|;MQc#UZ1S4!WQzWptg6!&t))s6koNP zBc`93Scf|bKuOjVk=qZdbdX*(KDC+w5w34qe%l^6fBg zK6ou368K0C20J5!6Mit`7k!J2@{D%Q_9T#&Ufe6R8(Y{i-$RqNXO$T}J!`>Qi7-U* z#XnlK-%$g+jfHJ(KUBXc$gHACQYi&v5Wvzc=n}0yeqWzt{_TLT_DeA!Sy+i(^t{u} zeeUl5FwU)!$V9#Uwy=%u`d~2;BJGvfeXpZCBG%XkU3o^Hh0i?{c{vVOq$(L1nr9!M zFfB%uwB1eypwCFpLM-ZEr?zcN>I@`Ht9>JqtEqW0KY5ypZ;M(EqaJOiOQc8Dh>Nrr z6G`9@rf0gi8K7ZL0{+l~1J1cKn-;Fe{aG#UphgTi4i07Dpor$!u%KJI@hMhdo8aW- zUY{ZwncM5J=UoKdQ#{(~6Z<5)ApmDmg~zXuVB#$G>Y6>=Fx+z@bbcf7Zqt-{s zPWC4lqrDFMHQGzRy*6ib`n9ag`>Oi&@sqQsvsJ5XqdVU_-gkZAKa!L+#@hWp(=#U6 zHv4=u^X?@8J%cfw58NqJB|rGxE41)yTD;`hfZ~S%OA}^h=3?UW2-N*ch8-MsJ8&46 za}U@_c|ahXVJ4>1_UNQ2x$Zk&n7oi-@PJbETJ=jfLC31!MOOS(!|3&Z`mr_kcwz5Nh&gy7G+@45H9p05OJ)J0CH2owMSaGIN$+5!N; z<11j56?ANg=9hMl-IBGX-T8hf$N$b*H?$f4Xt&I`oABt1nR=k%#z{{*a!Axm|t}hCz zJg0Ln7;M4Zjx{$mwhMW+kWN;|j>qTx_-zNX!GzqEZRa}QF8_0yk6+=w}$QD^&hM4%OkT=uh$q9;5u~NL-I+NQyaVc|3l+iWI5~|(hA-G z08i8AMr@{uY_cWTxo^y|Qyb33mlZLvc7H2Zm~>mB7&=-1X^@|D z&0*~i?GBE&NM(Pv&Vt^zWu_bD3e|R?wTL{cSFwD^Ij9v%g=aLY@1U2Bxn#Te*{>%D zOOW-O-bfnJ7T8jd<*>8`Z2DsFQi~S$%^npJwXam5>>p zMd}QEjM)@~##n$LXpz1Hkl|2UGXi-JFFePXBWL+-5f%!S>L#KL3>Vl0w#d^21Jn<~_7q zWx^Xg1(>PsPGO&cu{S;(pRQ;=Vw2J<9NdQVWx<+g-`ia=Q@puS)75M+?u>DTa95e9 zt#1T?#a)uWC>Mia!K6>g|InPW{&Kp9$tC_3*;R_Xsz6^Eu|xW1$6j#0?XLs7^l+%O zlxddE)h^|=K(2UqS*0ECuDe0ic|H_^t*VOoTCKx0Qmn_^LyJ|b8l$Jvl3{2=3x8&7 z$1ik&YG>w#@x@y~$r`fhlUDo;yXecc6$`30m`3K8s{k8G&3RVp8n#|l6h(Xw`Axw9 z%6Y^J6k0P@4YAuSd%q7=eg)&u8EMoEmq$CWj1GY|rGQWw3ida!FHk&wCqrQh_0Bcw z!ZBS3CbxgZ+}~wzgGIQ#QId%T_TE~_qdUqxjqS#8#jPxdwO@(@-5_nSP&uT?aGYYD z6km36K9=gjUjImwO=5Hl#u85VF?r0HbW)#h^SR|s_L47Tl$&Z&Rz*ksl!t*(2O2;D z+8`6$qpLn}LchhCmv*X}moGMX5?F@juGeHQAddAn}0~r zS_0|d3*0v%Y)8+8K{ zGyoYPb|W9Grm9M4E?vb^@16ePbI4omZv+(NoZ##fLUmKlB(G_jEbtDCM*27t$v`JovAZa+%*Q5dDXF*Ftt*n!O>#ohCM4lZ)h5rdKV-3A za}2AO6@!`W>ROk5FN*>2Zza^Z%}8KT%*jBGH|rml2X1LR{wZhWx8V4>|5i}; zMnLIHn3!^)`87GYh}&Y`KMwyLbA#^pch}Z!`@P_qH&N^LS9SxpEy8mc!wFusq&Z@` zeO}<6PC@VNaII|=n(^cNUiLseig*$;NjG7;IwvfYCBN>kzv@v-V2eBQZ@oIs^)NLqMR935k|1}U;5<{s(Ebdj4r`?QtrrAPfQooq zmPs_(YTy|??+nitNIFDoR7~qLPPFFCf^_~8OUt{#!|9o*3Q{!@9ZAI$7O~piD!;WX8#v&RxNH27i59$`1{o zEYU_zE{bKEI%f3BbE0Fc;f2!4LjUlC`wgh4@R{1?O78r5t$hWKiLV{#QWWq{QZiPx zm3?x$;&DDRVt0SByRiFczw$-e)GSvpCRbzk^=E zz=(+LjEc{Ps_2(OYg=G(93!oS=IeJ|WA8STv+LgI*Oj1c-QC06N~mvJ&KKx{arGp5 zswvJ6{%BvBYo>#2$%O$~TITuh?Rr^jCpAUXh)}m74`O|aOU>w2KI`k<#efwa5=-l4Xx!o>Z9Evg`RLN5W7SQp3$@D3_hY4EV!0( ztMm6>zBcgY{RvHZ{9Ey&&)jr2B4s0qDPBUh1ITaAp&>rj3ng*B=VGXz* zs@eR<;J(XkpD6Q1U3}#FR)wlafiFMU(-=&e9(eQ`isrS-9aNwJ)7frS8RiXM4*SbC zL|4*c?h^jfYvSOpn%Z$W?C|TuZ;uy2pFWHXuGW`ZkGV&kPJsKqJJQ!NswAE!!cb2k zumi=AE$YIkm})cVlg>nn&PBjBRI*@mfhhRMsa5U8k#A!ztfiw)d7I_UyAif8$5sJ9a7WUv5!o%fL z(J7-8EQzv1YIc)BNeWkLK~m%y4vqe&q@|_ZR5;eC3-9rkf*T{_19jtuWKhdW4Bn|~ zZ-YyFLN!k)0AKg{dO)|v3K?=oy+dzb4%T1F4}JsByncB1Z(`2p@O0!E!JQelouN^* z%Q^YfQUh66D$Zx-RDZvLctsr9`_+1p#tz&4SMd@i_-8()tyg3OyhU~?Gt#-a{NKFN z0VGf+AH%@o6;-_*?$$T4QX-f_>Ny-5CV8Ccq+@>gNSeovbFr0@b}RiTcJbLx>ws&r zsvY!rR{4al#MpVKut~?&kTmF>_v3UaC!gvuxgg%5-{l{20}~&F6CUarF9N=u)BG71 zoQDlAwT+T=mfo&$Xy%4-kmW;4wuh6{{ABClybHV6L>t&k4?9_Ny8A_^?)ff#dEjhL z2RbC~cFVbz^fJ`$I0%prYc0g-9(7X3eUp}^#Mzv)Z1EsGW;qr3cY$+e2HU5d_O9L% zpbljP*1!A0PqpzNo3W&y(hD87qgweq5YQWYEkxrOuSain2-q@Z*P`x*ht-9)Fr5Ho zSTKduvc9h6`S^#$i)LgjDi3_PQ+RbaGP!!di^Y;4kB0lGo$y{if)rJIaXTbpRgO#B z1El6|18;s}$0FRjgK-7~ZwmI`_1{a`32+Y>&O_iTpm%vz6hNkjGR(#*! zpfJ2>OAQbTFba9S3j9BlRHXaG{)Zt(J<3ppA?}j+7F#{bV{M7zU)5e@~R&J_xf$+GKK~ z3{R;Y9fZGe^ifEqKL;!VMXv26=R~^TG(#*2!JKCWoo&c^$utAs#Gfq-?t!c&9TH5- zj&i5L4NWbdNs*djvsY}bC&ddUbh=iyc0;3-@Y#d^s8|Ql{ax(yenFcG#i|K%lRxy| zFys4w!@EPXp2AsbMUGc*eP|7uliAq-O6~(+MR>V(EZTd&9G+MY&gF2lZ=I8j*o`OC z`AxrmOGMeD=H_9Cq47clT|h34>-EI=%;E!my;o&wU(aKV&PymBzrV9q2uA62XS@JrjKYANZAU>;8mag#BU?Nv`+ZVhlAPV`HF_gKY_O zhbV2L`8qvR&f=@M5vH~geD+L&*L2s<)|5)clA0yt9TM{X)iWtx@wJO_!{vR#|AD6t z*OAg2&P_i8jjW5y0DdtOGcqvrCHD*1Uq_q1ZQmngPnf!2fHizH%sSX>#$2Rh!>1ur z+s(*-)abDuePc6~XNG8m@|KMXHVM#G4?~+V z1z!An!D0GD-7WqXE8ddUXLkI%u01$fTEhhy&Z`mr_kcwz5Nh&g=McJ3E!;CE1E0ryV5Ro;>nvtvt zk&I==Xd;cVGZ@>q_xtnx{1uvKPTyjZupK9O(_gR$B#XePw@T6a}I(=v3sn`8+ zpUNDyH={w8<6Gn-e=wHS-vog;TPHWQ<6&jYBDZWT)nNd5_PoEhmk1KDrC*E7dj%i{ zf`2$xWA7dl$O2vpYl+q5Wd)u6poy_)Qc_zLqRa~gao)!+`5sM|Tlw)mV-;|gwjUfS zKwwwY#bM9SChM~ownKAZN|{{Bjs{ViwztSXxy?dr_?6e;sz!3*@g)#*0pdqUENlt% zN=o7_f(hulP}?@O0vc(YXaTgxHbe^(Pc26vo;~@O+MdQW3%?$J*cIgGb(s?iVBjh% zehMzl3j>)k7p|Ac6<`ra2g;adv&ERkuUYqrl2c5*jAMn-PE-qjwE5ZM9%cJMzzb|8 zH^hS1@fcoyVv?Tk*nvlC9b zfy7Zav;`)OmS6o5l8JLa`lT!7bVfiNc|rO~URvXsgz{o0*5Oap3X6VgG*d78KMnGC ztv#&!uG`7=2B{jr(N);@rrdm^LaD|9v=*6f^D<5VIR~{tsqu|v_aF3eu$FF@JpK9j zU zI8q(>AW=>Ow|e=;<_{Rxd0|NJX&^)vorf-XiogcPymbh&dc!9{j-p6(C3jvcAnoc( zIJCAW%Kx}e-wGvE;nVwi|ABaan(pEZR;Jrc5TtUsRYww%*+v%4;>&e(I45nKtiDFF zC56Qd-g(&60aI~>Uo2J>0_}MXe>|JdV-w57K@nVza(fP1W=>mMz^6d>S87R-CP>8h z+Z$tMGfn{%hP(oDq{)=Ux!JOQw&{W@CLU{Mc5`;a8SDsM>kmlnC@o^Yt2p8kWZ6r< zQ7*c{SBRPJ=@RuF9DnW0_3@JSLk<~(qM>a_e>SX{{;k6uGtHkTGgHF>n~<{S=TyN}Jq3m~whCai zb^go{s&Qp)oLIaOoT4S4F=ZpjbcnfFSGk~Gi)mtgu?n!0)}CjltzjF~#Zkm}kY7{` zpn^}LP^m3*)fl_Yw)g8$?PmxMotaL{bbGi1%j^_tR|yQ0qhfyn`-3DCb~2TwQE%O& z&;6zQ!0gt~*n7K7Ua%Oi4@x?z(9uUHWo$>4uc^ZnuDq4)wDwbZum_|I7O8*~8&6Pe zlM~9%&&Sc+I2#^nb4ZPC!Pp`gzGjcOlaCt;Y(BHT&RP1IjJm0woL$-3Fzsn1(uoF8 zfp*A5kC^KB+|aM_mStV)mKBT5UIcbgJ{A}V?Hok8ZirxAI3w*DRH$>3m$0kTrv?TE z5P)21=_&-)f!pth^e4687_-ONGiC^p(Qn|37B~)1f#O)a$YvOT3y8^zpE4%&eGLdL zUP~k$e1`i)hVK}d5vV=sf(EnhwZYZN0W2v8_?s+cR=5T{Q$#1I04y!O8BTbjB^iG{ zN}{0daE1?^mL5;c>D&d;tSEi(NREML#%#>CslvKy8#w~;XqCPZ#R6?G^;JqLVkyz| z3lE33VE_`I;QE6sz}_ey+Q8JD&@{2PKka?e=XA%-+dPw|{K!E4<_`WiOW()iy;!(b?L^4nT zO<)K71j2ozW3kJAHfmX4xKFb*LLANuEemjnT1y*j_UMbH_K;lA^hs$rOO4r6?00$W zmt5nTW#tf7hx)c-GAF<-r?TkA5iF_-_P&6bL75E4~(% zzZO#Y94?_6WO+qFA@Y`l&-cTB$K0sr-JP{{`vGrw)^*f+!=>GzZL5e}=18J<9chl3 z;g}z^r&riFJ5pyKjb?uTwwE*5fFd5pOfk$jF3*XIWGk)*7;gIa;vB;QhS>s4m6h8` z#A+BQ{0>NO)Lb^VmV+(xMefG8tG2o5D*EzL$?Suep+AAx-vd!_#k}yni(ceg?UBKa z>;nS(cI{Gbamtu{6$ktPcO3}J%xJcc?%rK;;=C!NqKxN4J@(qfqxJ+?@7`=b7sQib zh*B|7!z>U}oPs8v%VA483vRspo9jVZe5&%&OcX)kEWwph&D8w_rj2N2_^%fRQh~~N zd$uVw*=F!5BmWfN7DzT!XG}up6HdJL)Piim5?kxrp~D$U_7#h%^mzJ+)arBQwF45b zl8Yv9BU;L@!?57}OkRgr4yyc%@70JIoe}-K7`^PCCQz0!VJh=DrE6C>fhpL~p88!2 zC{MIgP>5!mp^clo^qTA(Z+xzDyeJ^z;9eu@37k^bQpH;^ud}bjHTk6zU4{bwPENt9 zw{cF*R6Z(TMeOb`_7wFT?N>cdpPuE(%qZQYEBSNOpAf>EY}c(F__S(UVBLqs2X@da z7#I<;omu(mP#yh3WNiy9iDRah(*69eYVF-(adqDt`?3;XIKF|T zNHfPdz#s0b@=!X-);t)HwRL{L-mbT;ZgO*EZ606fLQ)AtE9GX~UQ#H++|<3`-&v7F zKZ3lzs0b0RrRlfU52MbSuS6L>aORL#-P~iD$TC4tT5qUolrttSG58$06M+R_0OG4{Z# zVcIRfjqbVK@{P7!)W=7yZ&j*`75WK+y-dNRnZbvzplE)ZydfnzFoWYpwQ>H?#qd8I z!weN2)^5??eP&J`>S>)9!wYWE{W2GzU=jN{Mwc)67T}mVp{I$)WzCMm)1-o8dmr?@{ zM)`*CzFSxV%?AboDX7&gzmt<_1@?MgO@@XcsQWOdxG1n_<;@Icja{7&G>_~ln+klW zKlriKW(x1P3^r#nv2MEfA-6P9zytB=O&3a&Xx0{U^}DxL_6|^m1ftx3LMY=tSvi8Ai;h%G z$E1!?u_WpaspX~|N?No^2a>ADbZQDXAuB6;Q;lnlw(t&bExa*0F<3ugOa`^C#Nu75 z_cnNRC)M*s0`c{qt_JpKt&kzNH9HOV6<`Bpg5cNitgDB2{v_poipW5o65gS3>!T00!~UM5JH;h*}JwOx`E@)6smQe^Y;1iyM` z07#%L0j81XOPXc}{AT~;N~v%vsrPVrgyeaui-Gy>D{UD!!NXBT+O6`ZIwa({tOKsd zt9LRI*cB7M5aZ@u!l#^9L(`$R-%T)NTzqTB6@vMPe^tEC3re~lL3m(bx(N7sM*By6 zNIo{C%syJ$Rd&19sf8EDMOF+g-5yES@Rx6Z^DpdP5pU!yJM3c5?HLfCzU#O2`M#?q z1L%~r+oRxK+Q-zm?Ic7#th172c-G7O?VGGDHQw%wb*m@g5!;ENKMULx3btQ2{cVFa zKoiOiYm&pdIl;|8loTGvYe2){1jdsKzUlG61Xipoz<}zDaDO`HGsAOn7 z{0vwDbTFzm6Ay3BC-oxdaADjGoz}|9;El{fuGCVr<5UJD1O{YOd`ptuJ_xr(+GTO0 zj8AAB9Ynl#_Ekz_JOeBO#jfn65~hUG2yQDRd*hq#vyd9zpD-ol-2z z&I%{Njm@o}NKx7nvzP2`rz8s}^}1KKcEh4o@Hs>Os8}cQ{ax&{0b#pJVZ%Y@3sg+)W@e z1kJyEO+q=M=H_9CVF@AxeLxOrB-{uyE)y*M$b@ z)yG+oEMM_#kg5%m$*(!{QP56tX`S#(00%S3ci(DyE1DIul|dPTu%6Z(=U}2zLhK21 zhbUd5{!JKDcBW57e z+bzg{)aYM5`r2+f-vZGD}6Inrb9S8Ze9W0XB!s+erFh~~i p;S?2Q$?L?{?X#Wxr1tlYN#A^+gtTF>?cc9H!1650yvht6^M8WPw>kg- literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..c7c53cb11904843e176e4ce1f4e7247cd90b3590 GIT binary patch literal 5355 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 t>_S@PWkKlK01oMw@pjEVpN literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder-closed.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder-closed.gif new file mode 100644 index 0000000000000000000000000000000000000000..be6b59c2bafc37724de6a8904caf8ddb52185f07 GIT binary patch literal 631 zcmV--0*L)bNk%w1VGsZi0OoZ7Zc+gM@owbb(D(J~{kRkV=)C^@`FC9q$-khblVJYv z)5ozv$hAcOfX1|Jz_gHwZxsLR$M*H` z)5VgcjVaB&g#X~Bn}|^6)K>kvApXNk{?U8w>frwL-;#Ym&AMUr=V$)PW&YTa>#Gp{ z$5^hOaMH=J$FMm5$62+73I57t#-KOer4h}bD~WS3yQMU?q;vkxak`{N&AEBc#G?Jc zKK|H{jB+E}qY%KYW|e?Jt%4WhuRrYIzx}uttbPdi>1gcRT)?bi*~ygsy)VYKbl=sl z!LDb`w?4L^YVzd5|KO(4ze~WaWw4)Z<=wvhxEIZ>RsZvV+R0MBjTPX{P^5)3t(IEZ zo(`LK71O>%%$yd@ws6O^WdH2Q^sy2D_NBk8J;AJDcUuPR<<6~{Vg0!m{?dHMvTC`j zfZ5BO|NGMa|Nj6000000000000000000000000000000000000A^8LW004CWEC2ui z01yBW06+)SfOUcbFM}==AarS4f^`T0To+{@4nGeh6)G`B2p9kiNn<+@0|r=5Yepst zIgKY#WJd%9EJPL?t^m4h5ez8-Aqy8z25mic2N?k#R&i4b8U+nh4l7`S2^}ajGc6+$ z6C!V6UyXu5K{9S7=8Z222f8;D0KLCn3s7|l^;H1@N?@2FHGqSVIadS#=nw*efr3kz ztU4o2N*xdYmhp(zfYOQwaCBG@bU+OXEtfKR^UfI%4+*Z?OY3oS7i+9AMEg8&*N RE^xJLBxeY_p@ISd06U6)DM0`L literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder-closed2.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder-closed2.gif new file mode 100644 index 0000000000000000000000000000000000000000..541107888e6739a7b367ad3d208e1efa933f877d GIT binary patch literal 105 zcmZ?wbhEHb6ky4lrdiO0bk3ZcRLy6E?4f Hg~1vCyv-@{ literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..be6b59c2bafc37724de6a8904caf8ddb52185f07 GIT binary patch literal 631 zcmV--0*L)bNk%w1VGsZi0OoZ7Zc+gM@owbb(D(J~{kRkV=)C^@`FC9q$-khblVJYv z)5ozv$hAcOfX1|Jz_gHwZxsLR$M*H` z)5VgcjVaB&g#X~Bn}|^6)K>kvApXNk{?U8w>frwL-;#Ym&AMUr=V$)PW&YTa>#Gp{ z$5^hOaMH=J$FMm5$62+73I57t#-KOer4h}bD~WS3yQMU?q;vkxak`{N&AEBc#G?Jc zKK|H{jB+E}qY%KYW|e?Jt%4WhuRrYIzx}uttbPdi>1gcRT)?bi*~ygsy)VYKbl=sl z!LDb`w?4L^YVzd5|KO(4ze~WaWw4)Z<=wvhxEIZ>RsZvV+R0MBjTPX{P^5)3t(IEZ zo(`LK71O>%%$yd@ws6O^WdH2Q^sy2D_NBk8J;AJDcUuPR<<6~{Vg0!m{?dHMvTC`j zfZ5BO|NGMa|Nj6000000000000000000000000000000000000A^8LW004CWEC2ui z01yBW06+)SfOUcbFM}==AarS4f^`T0To+{@4nGeh6)G`B2p9kiNn<+@0|r=5Yepst zIgKY#WJd%9EJPL?t^m4h5ez8-Aqy8z25mic2N?k#R&i4b8U+nh4l7`S2^}ajGc6+$ z6C!V6UyXu5K{9S7=8Z222f8;D0KLCn3s7|l^;H1@N?@2FHGqSVIadS#=nw*efr3kz ztU4o2N*xdYmhp(zfYOQwaCBG@bU+OXEtfKR^UfI%4+*Z?OY3oS7i+9AMEg8&*N RE^xJLBxeY_p@ISd06U6)DM0`L literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder2.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/folder2.gif new file mode 100644 index 0000000000000000000000000000000000000000..2b31631ca2bfec3a8afb1bfdd4f8ed4c5bcc3a18 GIT binary patch literal 106 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 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-gray-line.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-gray-line.gif new file mode 100644 index 0000000000000000000000000000000000000000..37600447dc002bbc0dd16e1391b711360aae2e34 GIT binary patch literal 1877 zcmeH``8OK|0LL@bF~qSc#n50?JXNI+k>{#)#go3O{g`&sTA06+?`JRv{%1VB*=kSggPTmbZ?E2@Hm10RaqGJr~M_swEK9(fuU z9bXMur@nY#Xn3Qp;v6X2AT> zA>EM+>y@m1^a49s_E1X&+bZH^!_a=e{N6Su)s&U>sDnd!~=b?JFEB#FT8 zioZMFaK52~t&52oqdWW~2MJ1ue%%?en#qCfU7u!nC|sSJi5E`}X3h8)ly{+5*|mp+ zYqNE`8MkZN-)k};oze-j%*tB&sNuZif|=0wM%!=l0sXF(V)Zg+3_ zjbW;EBEX2ytHG=$Dx2Ha{HE%5V3a1hHnd2R32m%R*9#gFWf^4tEW&~!6yIiV)*e*l zireg~b4-8KL1b9Tn<4TQc-aUN7>=bBxE!0Aep)ES$dA>bZ zlac_>GSf$}Amq|xpG2f_X<$)PU0E=BExZ&}FuYP8&bwD%fgJCOsK5%!A}jIpO{>+( zGV75wBp|A>JOyOlNY1dq-7SE-P1iq3bVQx6%Yk<{*5}84F?-+_`Yq}S#U}_=SCzX? zX`+&GsCqhDsvFh7AWWM#ck=(Rps}W(-f3)-hf$w$i>58wymeug)RAsnbE^=j9L-?f zpi-Z);Tuuyqj4L}9YcZxTIWO&p4K%*X3?0-?f4ef8jtm%XgkyEBd6Ds8uOK?%`{)>0D(Cr`A4IcZoG`&U18YKqjoYtzQo|Dt=**7zk597IbK9sJXFyhNi zwtW@gRcSW?gGKMW@kxrlG#OY-do~qJ*-V&3Js8`Y3GYwom_@$iB+g=ml}U5>1u1QR zAzAiA(jrL>&74Uwwqm}`xJ1AT;O_GsONn5#!*ULyhq;oEIkp%2g#mF(6lf@Jxhn4i zV~t87;8y4{2KZG5ao+KL=SUTJlQq*4|E@_PjJ3`!o(GG)^}?JsMpy*)mQYPCf1;Sk`8-A8at@Xm#Gb>oe(v%3b{156)aykj?nu&|IbZfh z!lZx$?iVd}BHwuNSkmco3iwy5Drr$xV-lid6PqT(u95$N>8c#Jm2RMN_SB1WJe9Oq z(x$uU@TQLQX@QVr>U~Sa;vEmbZ_QL7odp^*-BsqVXSqmf)oqYES3tl*66F0YO=#d1 rlgk$~puxAlhuJ^ZHqgioD1o1DVtQEUit~KllU0$5nh)jV0N{TCC3Zqn literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-gray.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-gray.gif new file mode 100644 index 0000000000000000000000000000000000000000..cfb8a2f0961b880d9ecc9e59f831d0c0bf9d06db GIT binary patch literal 1230 zcmZ?wbhEHbOkikb_|5F}1vNN-#bFE}n2rob1X65+pkEe*DZwLSXy)sc-G6LrLE|#j%ny@ltx#{|>*k3`b zudj+f+$8$@s#fHh^zF++cYjOsT#=i)PgZ*SBbQFk<=6g7TzYe_x%fYqoR5WW_>5Nf zsIRkcJbHA@c(c>D3XzqU)=k#8J9nngIK5|{y|vw$2$RE?mT4~XtDRLEe|<_~c?_?$ zLGJZ!!S{W4%zp58Z=>w%X})`Qe0&`0sXRUALwVLJuj#KvHA1S2+ow&BYJYdfr2O^1 zna!)!@5=7^`T51=)#j2iwbhrWRX*39_q(R{^Y??#w#k`8!n#b?Ah=gT4^b_6Je!p-pqnUi6)T{Kw4)JLb3tD)cb}Z;R&ALM=NKo^J zQum3S7LQAK7iB!^v-vhdvhxz-&N&k%mqtvOXdV2 literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-red-line.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-red-line.gif new file mode 100644 index 0000000000000000000000000000000000000000..df9e749a8f1f58862588efc64988003efad01d51 GIT binary patch literal 1877 zcmeH``BxGK0LPh{$5cGF%CuRcF0W^1+Eb91Y0har@ns%QJPI-bCps}CP-u#GY96he zH{=x}8cR_?6wMSBHp}~@d8B5Ec_ztT`#0A2hwu02&*#0br`JzT&Np-c8>+j2FWJW9 z|J$$i)xiJGfXTkfHvoVFVDp9i%O?Qp3V=f6d5==7Sk4KMl>Ucik`YxtvJ<)$%#TPKR% zdeBegW3Nr-TZ$_DvX!7#=EQu`)|{{_NO4?Hnuz--`I}N3UjF&+?uwLk+=>GJd{B_Tc2OKbjN9H> z96NPSF%oo|+^NT@plDh-RsN>!ws$&N>eV+-RSK`GN-+xQlcpP|{VXMbZmGY?Sg+bE z&yqDeRb-m~Xn;($Rkc9os0lNWR0x7V&viYtFw425?`)O{#Xnxi^Z-rV%z`xuPf1K3U`ignx^9LiY{9RF`M1 z((4&CBBq9gRTxIqvdNQH4XvU-teM=&r#I{BRpE@Mf`UowW*aYDTj; zR~d}wJj7bmv%$EvhL%3@95+YnP@jZFjkyaK?LZqem&Cp}E@#J}7%>obDszfKXbSed{!N zqe%A5h1G9<<|OWgt(pyPNUi%mt_OllWQ$!DHV#9VzJogSLla83`aMi%;zcml$vXr7 zf<%YcL08HgN8s@2tufz(==0;jh0Ny@q4f1T-P5MdE9;FzHSA-Pm3Wn^KX5K-#%-h+YndE*c}A#} z97|nymmXX*xOhw~p_=<#*Rp;q1c;i_)TkyvQ;xgVtY5mTyh_&|ZEzU`%%?)%UDt;N sUpBjNE)^Df<9oQ%i{r+6SwTgJWAz*lYeQMK?>m|{T3!EviV6VoFXq=mv;Y7A literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-red.gif b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/images/treeview-red.gif new file mode 100644 index 0000000000000000000000000000000000000000..3bbb3a157f1568d59d6db02b55a3b3fe9a1ff7a7 GIT binary patch literal 1230 zcmZ?wbhEHbOkikb_|5q9rFMYXq;dkzBCUd%AXV z7f->2WoKqf=UU0E5MF-1&C2oHA5RfQ-wyu&du5`wWCYCfT`X0jHDP7Qa?|x$vA=>= zUtbk}xJmT)RjtT1>D!lu?*5kMxgs}ppRDxuM=qV7%dh>Fxb)^;bMb#JIUft%@ENV{ zQD0}@c=YI)@n)xQ6(TDyt(&ZGckWD~aeB`@duzKh5hjN(Ez?}&S39dT{`!=}@)%xg zgWT)eg75q8nEl}G-bUHi(|q^r`1m-~Q+ayKhw`jdUejNTYJ^l3w@;fM)&A~|N%`x2 zGn-ed-<93-^Ye?#tIZ{4YO60#t9-6I?{`h@=kEuf$II8+R(@HSYaUSgyf$2+OgK}0 zZsRjUi+L5dHILtK5edt9=qI|b{eIzIMl<7PRm>?O4!tnstX#kf7!b zrS20uEgqNfF3Nb+XY*}_WalNuopUBkE{&Kl(L5+ZuF(6`HI*Fyu5b4nE$kweHiYk+ hA)Dse=Ki!azG~*body { + font-size: 16px; + font-size: 68.75%; +} Reset Base Font Size */ + /* +body { + font-family: Verdana, helvetica, arial, sans-serif; + font-size: 68.75%; + background: #fff; + color: #333; +} */ + +a img { border: none; } \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/jquery.treeview.min.js b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/jquery.treeview.min.js new file mode 100644 index 000000000000..e693321dd0bd --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/jquery/treeview/jquery.treeview.min.js @@ -0,0 +1,16 @@ +/* + * Treeview 1.4 - jQuery plugin to hide and show branches of a tree + * + * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ + * http://docs.jquery.com/Plugins/Treeview + * + * Copyright (c) 2007 Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $ + * kasunbg: changed the cookieid name + * + */;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("

          ").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){if(typeof(window.treeCookieId) === 'undefined' || window.treeCookieId === ""){treeCookieId = "treeview";} settings=$.extend({cookieId: treeCookieId},settings);if(settings.add){return this.trigger("add",[settings.add]);}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}function serialize(){function binary(arg){return arg?1:0;}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}break;}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery); \ No newline at end of file diff --git a/core-java/src/test/resources/docbook-xsl/webhelp/template/common/main.js b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/main.js new file mode 100644 index 000000000000..5957fb435d69 --- /dev/null +++ b/core-java/src/test/resources/docbook-xsl/webhelp/template/common/main.js @@ -0,0 +1,276 @@ +/** + * Miscellaneous js functions for WebHelp + * Kasun Gajasinghe, http://kasunbg.blogspot.com + * David Cramer, http://www.thingbag.net + * + */ + +//Turn ON and OFF the animations for Show/Hide Sidebar. Extend this to other anime as well if any. +var noAnimations=false; + +$(document).ready(function() { + // When you click on a link to an anchor, scroll down + // 105 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link within a page. + $('a[href*=#]').click(function() { + if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') + && location.hostname == this.hostname) { + var $target = $(this.hash); + $target = $target.length && $target + || $('[name=' + this.hash.slice(1) +']'); + if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv" || this.hash == "") && $target.length) { + var targetOffset = $target.offset().top - 120; + $('html,body') + .animate({scrollTop: targetOffset}, 200); + return false; + } + } + }); + + // $("#showHideHighlight").button(); //add jquery button styling to 'Go' button + //Generate tabs in nav-pane with JQuery + $(function() { + $("#tabs").tabs({ + cookie: { + expires: 2 // store cookie for 2 days. + } + }); + }); + + //Generate the tree + $("#ulTreeDiv").attr("style", ""); + $("#tree").treeview({ + collapsed: true, + animated: "medium", + control: "#sidetreecontrol", + persist: "cookie" + }); + + //after toc fully styled, display it. Until loading, a 'loading' image will be displayed + $("#tocLoading").attr("style", "display:none;"); + // $("#ulTreeDiv").attr("style","display:block;"); + + //.searchButton is the css class applied to 'Go' button + $(function() { + $("button", ".searchButton").button(); + + $("button", ".searchButton").click(function() { + return false; + }); + }); + + //'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('ui-tabs-1') === '1') { //search tab is active + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + searchHighlight($.cookie('textToSearch')); + $("#showHideHighlight").css("display", "block"); + } + } + + syncToc(); //Synchronize the toc tree with the content pane, when loading the page. + //$("#doSearch").button(); //add jquery button styling to 'Go' button + + // When you click on a link to an anchor, scroll down + // 120 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link from another page. + var hash = window.location.hash; + if(hash){ + var targetOffset = $(hash).offset().top - 120; + $('html,body').animate({scrollTop: targetOffset}, 200); + return false; + } +}); + + +/** + * If an user moved to another page by clicking on a toc link, and then clicked on #searchDiv, + * search should be performed if the cookie textToSearch is not empty. + */ +function doSearch() { +//'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + } +} + +/** + * Synchronize with the tableOfContents + */ +function syncToc() { + var a = document.getElementById("webhelp-currentid"); + if (a != undefined) { + //Expanding the child sections of the selected node. + var nodeClass = a.getAttribute("class"); + if (nodeClass != null && !nodeClass.match(/collapsable/)) { + a.setAttribute("class", "collapsable"); + //remove display:none; css style from